@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | /** |
| 158 | 158 | * @param string $query |
| 159 | 159 | * |
| 160 | - * @return mixed|string |
|
| 160 | + * @return string |
|
| 161 | 161 | */ |
| 162 | 162 | public function replaceTablePlaceholders($query) { |
| 163 | 163 | $sql = $query; |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
| 174 | - * @param $query |
|
| 174 | + * @param string $query |
|
| 175 | 175 | */ |
| 176 | 176 | protected function logQuery($query) { |
| 177 | 177 | if (!classSupernova::$config->debug) { |
@@ -301,10 +301,16 @@ discard block |
||
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | |
| 304 | + /** |
|
| 305 | + * @param string $query |
|
| 306 | + */ |
|
| 304 | 307 | public function doInsertComplex($query) { |
| 305 | 308 | return $this->doSql($query); |
| 306 | 309 | } |
| 307 | 310 | |
| 311 | + /** |
|
| 312 | + * @param integer $replace |
|
| 313 | + */ |
|
| 308 | 314 | protected function doSet($table, $fieldsAndValues, $replace = DB_INSERT_PLAIN) { |
| 309 | 315 | $tableSafe = $this->db_escape($table); |
| 310 | 316 | $safeFieldsAndValues = implode(',', $this->safeFieldsEqualValues($fieldsAndValues)); |
@@ -337,6 +343,9 @@ discard block |
||
| 337 | 343 | return $this->doSet($table, $fieldsAndValues, $replace); |
| 338 | 344 | } |
| 339 | 345 | |
| 346 | + /** |
|
| 347 | + * @param string $table |
|
| 348 | + */ |
|
| 340 | 349 | public function doReplaceSet($table, $fieldsAndValues) { |
| 341 | 350 | return $this->doSet($table, $fieldsAndValues, DB_INSERT_REPLACE); |
| 342 | 351 | } |
@@ -371,7 +380,7 @@ discard block |
||
| 371 | 380 | * Values should be passed as-is |
| 372 | 381 | * |
| 373 | 382 | * @param string $table |
| 374 | - * @param array $fields |
|
| 383 | + * @param string[] $fields |
|
| 375 | 384 | * @param string[] $values |
| 376 | 385 | * |
| 377 | 386 | * @return array|bool|mysqli_result|null |
@@ -410,7 +419,7 @@ discard block |
||
| 410 | 419 | * Self-contained - means no params used |
| 411 | 420 | * Such queries usually used to make large amount of in-base calculations |
| 412 | 421 | * |
| 413 | - * @param $query |
|
| 422 | + * @param string $query |
|
| 414 | 423 | * |
| 415 | 424 | * @return array|bool|mysqli_result|null |
| 416 | 425 | */ |
@@ -418,6 +427,9 @@ discard block |
||
| 418 | 427 | return $this->doSql($query); |
| 419 | 428 | } |
| 420 | 429 | |
| 430 | + /** |
|
| 431 | + * @param boolean $isOneRecord |
|
| 432 | + */ |
|
| 421 | 433 | protected function doUpdateWhere($table, $fieldsSet, $fieldsAdjust = array(), $where = array(), $isOneRecord = DB_RECORDS_ALL) { |
| 422 | 434 | $tableSafe = $this->db_escape($table); |
| 423 | 435 | |
@@ -441,10 +453,16 @@ discard block |
||
| 441 | 453 | return $this->doSql($query); |
| 442 | 454 | } |
| 443 | 455 | |
| 456 | + /** |
|
| 457 | + * @param string $table |
|
| 458 | + */ |
|
| 444 | 459 | public function doUpdateRowSet($table, $fieldsAndValues, $where) { |
| 445 | 460 | return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORD_ONE); |
| 446 | 461 | } |
| 447 | 462 | |
| 463 | + /** |
|
| 464 | + * @param string $table |
|
| 465 | + */ |
|
| 448 | 466 | public function doUpdateTableSet($table, $fieldsAndValues, $where = array()) { |
| 449 | 467 | return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORDS_ALL); |
| 450 | 468 | } |
@@ -711,6 +729,10 @@ discard block |
||
| 711 | 729 | } |
| 712 | 730 | |
| 713 | 731 | // TODO Заменить это на новый логгер |
| 732 | + |
|
| 733 | + /** |
|
| 734 | + * @param string $query |
|
| 735 | + */ |
|
| 714 | 736 | protected function security_watch_user_queries($query) { |
| 715 | 737 | global $user; |
| 716 | 738 | |
@@ -734,6 +756,9 @@ discard block |
||
| 734 | 756 | } |
| 735 | 757 | |
| 736 | 758 | |
| 759 | + /** |
|
| 760 | + * @param string $query |
|
| 761 | + */ |
|
| 737 | 762 | public function security_query_check_bad_words($query) { |
| 738 | 763 | if ($this->skipQueryCheck) { |
| 739 | 764 | return; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | public function load_db_settings($configFile = '') { |
| 92 | 92 | $dbsettings = array(); |
| 93 | 93 | |
| 94 | - empty($configFile) ? $configFile = SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX : false; |
|
| 94 | + empty($configFile) ? $configFile = SN_ROOT_PHYSICAL."config".DOT_PHP_EX : false; |
|
| 95 | 95 | |
| 96 | 96 | require $configFile; |
| 97 | 97 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | if (empty($this->dbsettings)) { |
| 114 | - $this->load_db_settings(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX); |
|
| 114 | + $this->load_db_settings(SN_ROOT_PHYSICAL."config".DOT_PHP_EX); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | // TODO - фатальные (?) ошибки на каждом шагу. Хотя - скорее Эксепшны |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $sql = $query; |
| 164 | 164 | if (strpos($sql, '{{') !== false) { |
| 165 | 165 | foreach ($this->table_list as $tableName) { |
| 166 | - $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql); |
|
| 166 | + $sql = str_replace("{{{$tableName}}}", $this->db_prefix.$tableName, $sql); |
|
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | |
@@ -236,12 +236,12 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | $queryResult = null; |
| 238 | 238 | try { |
| 239 | - $queryResult = $this->db_sql_query($stringQuery . DbSqlHelper::quoteComment($queryTrace)); |
|
| 239 | + $queryResult = $this->db_sql_query($stringQuery.DbSqlHelper::quoteComment($queryTrace)); |
|
| 240 | 240 | if (!$queryResult) { |
| 241 | 241 | throw new Exception(); |
| 242 | 242 | } |
| 243 | 243 | } catch (Exception $e) { |
| 244 | - classSupernova::$debug->error($this->db_error() . "<br />{$query}<br />", 'SQL Error'); |
|
| 244 | + classSupernova::$debug->error($this->db_error()."<br />{$query}<br />", 'SQL Error'); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | return $queryResult; |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | case TYPE_EMPTY: |
| 580 | 580 | // No-type defaults to string |
| 581 | 581 | default: |
| 582 | - $value = "'" . $this->db_escape((string)$value) . "'"; |
|
| 582 | + $value = "'".$this->db_escape((string) $value)."'"; |
|
| 583 | 583 | break; |
| 584 | 584 | } |
| 585 | 585 | |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | if (is_int($fieldName)) { |
| 608 | 608 | $result[$fieldName] = $fieldValue; |
| 609 | 609 | } else { |
| 610 | - $result[$fieldName] = "`{$fieldName}` = " . $this->castAsDbValue($fieldValue); |
|
| 610 | + $result[$fieldName] = "`{$fieldName}` = ".$this->castAsDbValue($fieldValue); |
|
| 611 | 611 | } |
| 612 | 612 | } |
| 613 | 613 | |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | if (is_int($fieldName)) { |
| 637 | 637 | $result[$fieldName] = $fieldValue; |
| 638 | 638 | } else { |
| 639 | - $result[$fieldName] = "`{$fieldName}` = `{$fieldName}` + (" . $this->castAsDbValue($fieldValue) . ")"; |
|
| 639 | + $result[$fieldName] = "`{$fieldName}` = `{$fieldName}` + (".$this->castAsDbValue($fieldValue).")"; |
|
| 640 | 640 | } |
| 641 | 641 | } |
| 642 | 642 | |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | foreach ($fields as $key => $value) { |
| 670 | - $result[$key] = "`" . $this->db_escape($value) . "`"; |
|
| 670 | + $result[$key] = "`".$this->db_escape($value)."`"; |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | return $result; |
@@ -723,10 +723,10 @@ discard block |
||
| 723 | 723 | $this->isWatching = true; |
| 724 | 724 | $msg = "\$query = \"{$query}\"\n\r"; |
| 725 | 725 | if (!empty($_POST)) { |
| 726 | - $msg .= "\n\r" . dump($_POST, '$_POST'); |
|
| 726 | + $msg .= "\n\r".dump($_POST, '$_POST'); |
|
| 727 | 727 | } |
| 728 | 728 | if (!empty($_GET)) { |
| 729 | - $msg .= "\n\r" . dump($_GET, '$_GET'); |
|
| 729 | + $msg .= "\n\r".dump($_GET, '$_GET'); |
|
| 730 | 730 | } |
| 731 | 731 | classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true)); |
| 732 | 732 | $this->isWatching = false; |
@@ -752,37 +752,37 @@ discard block |
||
| 752 | 752 | case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit: |
| 753 | 753 | case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit: |
| 754 | 754 | case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0: |
| 755 | - $report = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n"; |
|
| 755 | + $report = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n"; |
|
| 756 | 756 | $report .= ">Database Inforamation\n"; |
| 757 | - $report .= "\tID - " . $user['id'] . "\n"; |
|
| 758 | - $report .= "\tUser - " . $user['username'] . "\n"; |
|
| 759 | - $report .= "\tAuth level - " . $user['authlevel'] . "\n"; |
|
| 760 | - $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n"; |
|
| 761 | - $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n"; |
|
| 762 | - $report .= "\tUser IP - " . $user['user_lastip'] . "\n"; |
|
| 763 | - $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n"; |
|
| 764 | - $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
| 765 | - $report .= "\tCurrent Page - " . $user['current_page'] . "\n"; |
|
| 766 | - $report .= "\tRegister Time - " . $user['register_time'] . "\n"; |
|
| 757 | + $report .= "\tID - ".$user['id']."\n"; |
|
| 758 | + $report .= "\tUser - ".$user['username']."\n"; |
|
| 759 | + $report .= "\tAuth level - ".$user['authlevel']."\n"; |
|
| 760 | + $report .= "\tAdmin Notes - ".$user['adminNotes']."\n"; |
|
| 761 | + $report .= "\tCurrent Planet - ".$user['current_planet']."\n"; |
|
| 762 | + $report .= "\tUser IP - ".$user['user_lastip']."\n"; |
|
| 763 | + $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n"; |
|
| 764 | + $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
| 765 | + $report .= "\tCurrent Page - ".$user['current_page']."\n"; |
|
| 766 | + $report .= "\tRegister Time - ".$user['register_time']."\n"; |
|
| 767 | 767 | $report .= "\n"; |
| 768 | 768 | |
| 769 | 769 | $report .= ">Query Information\n"; |
| 770 | - $report .= "\tQuery - " . $query . "\n"; |
|
| 770 | + $report .= "\tQuery - ".$query."\n"; |
|
| 771 | 771 | $report .= "\n"; |
| 772 | 772 | |
| 773 | 773 | $report .= ">\$_SERVER Information\n"; |
| 774 | - $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n"; |
|
| 775 | - $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n"; |
|
| 776 | - $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
| 777 | - $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n"; |
|
| 778 | - $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n"; |
|
| 779 | - $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n"; |
|
| 780 | - $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n"; |
|
| 781 | - $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n"; |
|
| 774 | + $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n"; |
|
| 775 | + $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n"; |
|
| 776 | + $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
| 777 | + $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n"; |
|
| 778 | + $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n"; |
|
| 779 | + $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n"; |
|
| 780 | + $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n"; |
|
| 781 | + $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n"; |
|
| 782 | 782 | |
| 783 | 783 | $report .= "\n--------------------------------------------------------------------------------------------------\n"; |
| 784 | 784 | |
| 785 | - $fp = fopen(SN_ROOT_PHYSICAL . 'badqrys.txt', 'a'); |
|
| 785 | + $fp = fopen(SN_ROOT_PHYSICAL.'badqrys.txt', 'a'); |
|
| 786 | 786 | fwrite($fp, $report); |
| 787 | 787 | fclose($fp); |
| 788 | 788 | |
@@ -4,11 +4,11 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type) { |
| 6 | 6 | return classSupernova::$db->doSelect( |
| 7 | - "SELECT p.*, u.username" . ($table_parent_columns ? ', p1.name AS parent_name' : '') . |
|
| 7 | + "SELECT p.*, u.username".($table_parent_columns ? ', p1.name AS parent_name' : ''). |
|
| 8 | 8 | " FROM {{planets}} AS p |
| 9 | 9 | LEFT JOIN {{users}} AS u ON u.id = p.id_owner" . |
| 10 | - ($table_parent_columns ? ' LEFT JOIN {{planets}} AS p1 ON p1.id = p.parent_planet' : '') . |
|
| 11 | - " WHERE " . ($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}")); |
|
| 10 | + ($table_parent_columns ? ' LEFT JOIN {{planets}} AS p1 ON p1.id = p.parent_planet' : ''). |
|
| 11 | + " WHERE ".($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}")); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | function db_planet_list_search($searchtext) { |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | ORDER BY |
| 107 | 107 | sp.`{$Rank}_rank`, subject.{$source['id']} |
| 108 | 108 | LIMIT |
| 109 | - " . $start . ",100;"; |
|
| 109 | + ".$start.",100;"; |
|
| 110 | 110 | } else { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
| 111 | 111 | $query_str = |
| 112 | 112 | "SELECT |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | ORDER BY |
| 120 | 120 | subject.{$Rank} DESC, subject.{$source['id']} |
| 121 | 121 | LIMIT |
| 122 | - " . $start . ",100;"; |
|
| 122 | + ".$start.",100;"; |
|
| 123 | 123 | } |
| 124 | 124 | } else { |
| 125 | 125 | // TODO |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | ORDER BY |
| 137 | 137 | sp.`{$Rank}_rank`, subject.id |
| 138 | 138 | LIMIT |
| 139 | - " . $start . ",100;"; |
|
| 139 | + ".$start.",100;"; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | return classSupernova::$db->doSelect($query_str); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | |
| 146 | 146 | function db_stat_list_update_ally_stats() { |
| 147 | - return ; |
|
| 147 | + return; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | function db_stat_list_delete_ally_player() { |
@@ -394,9 +394,9 @@ discard block |
||
| 394 | 394 | */ |
| 395 | 395 | function db_payment_list_get($flt_payer, $flt_status, $flt_test, $flt_module) { |
| 396 | 396 | $extra_conditions = |
| 397 | - ($flt_payer > 0 ? "AND payment_user_id = {$flt_payer} " : '') . |
|
| 398 | - ($flt_status >= 0 ? "AND payment_status = {$flt_status} " : '') . |
|
| 399 | - ($flt_test >= 0 ? "AND payment_test = {$flt_test} " : '') . |
|
| 397 | + ($flt_payer > 0 ? "AND payment_user_id = {$flt_payer} " : ''). |
|
| 398 | + ($flt_status >= 0 ? "AND payment_status = {$flt_status} " : ''). |
|
| 399 | + ($flt_test >= 0 ? "AND payment_test = {$flt_test} " : ''). |
|
| 400 | 400 | ($flt_module ? "AND payment_module_name = '{$flt_module}' " : ''); |
| 401 | 401 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{payment}}` WHERE 1 {$extra_conditions} ORDER BY payment_id DESC;"); |
| 402 | 402 | |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | // Log Online ************************************************************************************************************* |
| 426 | 426 | function db_log_online_insert() { |
| 427 | 427 | classSupernova::$db->doInsertSet(TABLE_LOG_USERS_ONLINE, array( |
| 428 | - 'online_count' => (int)classSupernova::$config->var_online_user_count, |
|
| 428 | + 'online_count' => (int) classSupernova::$config->var_online_user_count, |
|
| 429 | 429 | ), DB_INSERT_IGNORE); |
| 430 | 430 | } |
| 431 | 431 | |
@@ -450,9 +450,9 @@ discard block |
||
| 450 | 450 | function db_log_delete_update_and_stat_calc() { |
| 451 | 451 | classSupernova::$db->doDeleteSimple( |
| 452 | 452 | 'DELETE FROM `{{logs}}` WHERE `log_code` IN (' |
| 453 | - . LOG_INFO_DB_CHANGE . ', ' |
|
| 454 | - . LOG_INFO_MAINTENANCE . ', ' |
|
| 455 | - . LOG_INFO_STAT_PROCESS . |
|
| 453 | + . LOG_INFO_DB_CHANGE.', ' |
|
| 454 | + . LOG_INFO_MAINTENANCE.', ' |
|
| 455 | + . LOG_INFO_STAT_PROCESS. |
|
| 456 | 456 | ')' |
| 457 | 457 | ); |
| 458 | 458 | } |
@@ -521,10 +521,10 @@ discard block |
||
| 521 | 521 | function db_log_dark_matter_insert($user_id, $change_type, $dark_matter, $comment_unsafe, $rowUserNameUnsafe, $page_url_unsafe) { |
| 522 | 522 | return classSupernova::$db->doInsertSet(TABLE_LOG_DARK_MATTER, array( |
| 523 | 523 | 'log_dark_matter_username' => $rowUserNameUnsafe, |
| 524 | - 'log_dark_matter_reason' => (int)$change_type, |
|
| 525 | - 'log_dark_matter_amount' => (float)$dark_matter, |
|
| 526 | - 'log_dark_matter_comment' => (string)$comment_unsafe, |
|
| 527 | - 'log_dark_matter_page' => (string)$page_url_unsafe, |
|
| 524 | + 'log_dark_matter_reason' => (int) $change_type, |
|
| 525 | + 'log_dark_matter_amount' => (float) $dark_matter, |
|
| 526 | + 'log_dark_matter_comment' => (string) $comment_unsafe, |
|
| 527 | + 'log_dark_matter_page' => (string) $page_url_unsafe, |
|
| 528 | 528 | 'log_dark_matter_sender' => $user_id, |
| 529 | 529 | )); |
| 530 | 530 | } |
@@ -693,9 +693,9 @@ discard block |
||
| 693 | 693 | function db_ube_report_get_best_battles() { |
| 694 | 694 | $query = classSupernova::$db->doSelect("SELECT * |
| 695 | 695 | FROM `{{ube_report}}` |
| 696 | - WHERE `ube_report_time_process` < DATE(DATE_SUB(NOW(), INTERVAL " . MODULE_INFO_BEST_BATTLES_LOCK_DAYS . " DAY)) |
|
| 696 | + WHERE `ube_report_time_process` < DATE(DATE_SUB(NOW(), INTERVAL " . MODULE_INFO_BEST_BATTLES_LOCK_DAYS." DAY)) |
|
| 697 | 697 | ORDER BY `ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC |
| 698 | - LIMIT " . MODULE_INFO_BEST_BATTLES_REPORT_VIEW . ";"); |
|
| 698 | + LIMIT " . MODULE_INFO_BEST_BATTLES_REPORT_VIEW.";"); |
|
| 699 | 699 | |
| 700 | 700 | return $query; |
| 701 | 701 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | use Vector\Vector; |
| 25 | 25 | |
| 26 | -if(!defined('INIT')) { |
|
| 26 | +if (!defined('INIT')) { |
|
| 27 | 27 | // include_once('init.php'); |
| 28 | 28 | die('Unauthorized access'); |
| 29 | 29 | } |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | classSupernova::$config->debug = 0; |
| 42 | 42 | |
| 43 | 43 | |
| 44 | -if(classSupernova::$config->db_version == DB_VERSION) { |
|
| 45 | -} elseif(classSupernova::$config->db_version > DB_VERSION) { |
|
| 44 | +if (classSupernova::$config->db_version == DB_VERSION) { |
|
| 45 | +} elseif (classSupernova::$config->db_version > DB_VERSION) { |
|
| 46 | 46 | classSupernova::$config->db_saveItem('var_db_update_end', SN_TIME_NOW); |
| 47 | 47 | die( |
| 48 | 48 | 'Internal error! Auotupdater detects DB version greater then can be handled!<br /> |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | ); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | -if(classSupernova::$config->db_version < 26) { |
|
| 54 | +if (classSupernova::$config->db_version < 26) { |
|
| 55 | 55 | $sys_log_disabled = true; |
| 56 | 56 | } |
| 57 | 57 | |
@@ -70,20 +70,20 @@ discard block |
||
| 70 | 70 | $update_tables = array(); |
| 71 | 71 | $update_indexes = array(); |
| 72 | 72 | $query = upd_do_query('SHOW TABLES;', true); |
| 73 | -while($row = classSupernova::$db->db_fetch_row($query)) { |
|
| 73 | +while ($row = classSupernova::$db->db_fetch_row($query)) { |
|
| 74 | 74 | upd_load_table_info($row[0]); |
| 75 | 75 | } |
| 76 | 76 | upd_log_message('Table info loaded. Now looking DB for upgrades...'); |
| 77 | 77 | |
| 78 | 78 | upd_do_query('SET FOREIGN_KEY_CHECKS=0;', true); |
| 79 | 79 | |
| 80 | -if($new_version < 37) { |
|
| 80 | +if ($new_version < 37) { |
|
| 81 | 81 | require_once('update_old.php'); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | ini_set('memory_limit', '1024M'); |
| 85 | 85 | |
| 86 | -switch($new_version) { |
|
| 86 | +switch ($new_version) { |
|
| 87 | 87 | case 37: |
| 88 | 88 | upd_log_version_update(); |
| 89 | 89 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | upd_check_key('payment_currency_exchange_mm_', 2500, !classSupernova::$config->payment_currency_exchange_mm_); |
| 100 | 100 | |
| 101 | - if(!$update_tables['log_metamatter']) { |
|
| 101 | + if (!$update_tables['log_metamatter']) { |
|
| 102 | 102 | upd_create_table('log_metamatter', |
| 103 | 103 | "( |
| 104 | 104 | `id` SERIAL, |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | "ADD `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'", |
| 124 | 124 | ), !$update_tables['payment']['payment_test']); |
| 125 | 125 | |
| 126 | - if($update_tables['payment']['payment_test']['Default'] == 1) { |
|
| 126 | + if ($update_tables['payment']['payment_test']['Default'] == 1) { |
|
| 127 | 127 | upd_alter_table('payment', array( |
| 128 | 128 | "MODIFY COLUMN `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'", |
| 129 | 129 | )); |
@@ -139,15 +139,15 @@ discard block |
||
| 139 | 139 | "MODIFY COLUMN `metamatter` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Metamatter amount'", |
| 140 | 140 | ), $update_tables['users']['metamatter']['Type'] == 'int(20)'); |
| 141 | 141 | |
| 142 | - $query = upd_do_query("SELECT * FROM {{que}} WHERE `que_type` = " . QUE_RESEARCH . " AND que_unit_id IN (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") FOR UPDATE"); |
|
| 143 | - while($row = db_fetch($query)) { |
|
| 142 | + $query = upd_do_query("SELECT * FROM {{que}} WHERE `que_type` = ".QUE_RESEARCH." AND que_unit_id IN (".TECH_EXPEDITION.",".TECH_COLONIZATION.") FOR UPDATE"); |
|
| 143 | + while ($row = db_fetch($query)) { |
|
| 144 | 144 | $planet_id = ($row['que_planet_id_origin'] ? $row['que_planet_id_origin'] : $row['que_planet_id']); |
| 145 | 145 | upd_do_query("SELECT id FROM {{planets}} WHERE id = {$planet_id} FOR UPDATE"); |
| 146 | 146 | $price = sys_unit_str2arr($row['que_unit_price']); |
| 147 | - upd_do_query("UPDATE {{planets}} SET " . |
|
| 148 | - "`metal` = `metal` + " . ($price[RES_METAL] ? $price[RES_METAL] : 0) . "," . |
|
| 149 | - "`crystal` = `crystal` + " . ($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0) . "," . |
|
| 150 | - "`deuterium` = `deuterium` + " . ($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0) . |
|
| 147 | + upd_do_query("UPDATE {{planets}} SET ". |
|
| 148 | + "`metal` = `metal` + ".($price[RES_METAL] ? $price[RES_METAL] : 0).",". |
|
| 149 | + "`crystal` = `crystal` + ".($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0).",". |
|
| 150 | + "`deuterium` = `deuterium` + ".($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0). |
|
| 151 | 151 | " WHERE id = {$planet_id}" |
| 152 | 152 | ); |
| 153 | 153 | upd_do_query("DELETE FROM {{que}} WHERE que_id = {$row['que_id']}"); |
@@ -156,10 +156,10 @@ discard block |
||
| 156 | 156 | $query = upd_do_query("SELECT unit_id, unit_snid, unit_level, id_planet FROM {{unit}} AS un |
| 157 | 157 | LEFT JOIN {{users}} AS u ON u.id = un.unit_player_id |
| 158 | 158 | LEFT JOIN {{planets}} AS p ON p.id = u.id_planet |
| 159 | - WHERE unit_snid IN (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") |
|
| 159 | + WHERE unit_snid IN (" . TECH_EXPEDITION.",".TECH_COLONIZATION.") |
|
| 160 | 160 | FOR UPDATE"); |
| 161 | - while($row = db_fetch($query)) { |
|
| 162 | - if(!$row['id_planet']) { |
|
| 161 | + while ($row = db_fetch($query)) { |
|
| 162 | + if (!$row['id_planet']) { |
|
| 163 | 163 | continue; |
| 164 | 164 | } |
| 165 | 165 | |
@@ -167,14 +167,14 @@ discard block |
||
| 167 | 167 | $unit_level = $row['unit_level']; |
| 168 | 168 | $price = get_unit_param($unit_id, P_COST); |
| 169 | 169 | $factor = $price['factor']; |
| 170 | - foreach($price as $resource_id => &$resource_amount) { |
|
| 170 | + foreach ($price as $resource_id => &$resource_amount) { |
|
| 171 | 171 | $resource_amount = $resource_amount * (pow($factor, $unit_level) - 1) / ($factor - 1); |
| 172 | 172 | } |
| 173 | 173 | // upd_do_query |
| 174 | - upd_do_query($q = "UPDATE {{planets}} SET " . |
|
| 175 | - "`metal` = `metal` + " . ($price[RES_METAL] ? $price[RES_METAL] : 0) . "," . |
|
| 176 | - "`crystal` = `crystal` + " . ($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0) . "," . |
|
| 177 | - "`deuterium` = `deuterium` + " . ($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0) . |
|
| 174 | + upd_do_query($q = "UPDATE {{planets}} SET ". |
|
| 175 | + "`metal` = `metal` + ".($price[RES_METAL] ? $price[RES_METAL] : 0).",". |
|
| 176 | + "`crystal` = `crystal` + ".($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0).",". |
|
| 177 | + "`deuterium` = `deuterium` + ".($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0). |
|
| 178 | 178 | " WHERE id = {$row['id_planet']}" |
| 179 | 179 | ); |
| 180 | 180 | upd_do_query("DELETE FROM {{unit}} WHERE unit_id = {$row['unit_id']}"); |
@@ -186,14 +186,14 @@ discard block |
||
| 186 | 186 | // Вернуть ресы за уже исследованную Экспедиционную технологию |
| 187 | 187 | upd_check_key('player_max_colonies', -1, classSupernova::$config->player_max_colonies >= 0); |
| 188 | 188 | |
| 189 | - if(!isset($update_tables['users']['player_rpg_explore_xp'])) { |
|
| 189 | + if (!isset($update_tables['users']['player_rpg_explore_xp'])) { |
|
| 190 | 190 | upd_alter_table('users', array( |
| 191 | 191 | "ADD COLUMN `player_rpg_explore_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
| 192 | 192 | "ADD COLUMN `player_rpg_explore_xp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
| 193 | 193 | ), !isset($update_tables['users']['player_rpg_explore_xp'])); |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - if(!$update_tables['log_users_online']) { |
|
| 196 | + if (!$update_tables['log_users_online']) { |
|
| 197 | 197 | upd_create_table('log_users_online', "( |
| 198 | 198 | `online_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Measure time', |
| 199 | 199 | `online_count` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Users online', |
@@ -208,11 +208,11 @@ discard block |
||
| 208 | 208 | "ADD `user_time_measured` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'When was time diff measured last time' AFTER `onlinetime`", |
| 209 | 209 | ), !$update_tables['users']['user_time_measured']); |
| 210 | 210 | |
| 211 | - if($update_tables['rw']) { |
|
| 211 | + if ($update_tables['rw']) { |
|
| 212 | 212 | upd_do_query("DROP TABLE IF EXISTS {{rw}};"); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - if(!$update_tables['player_award']) { |
|
| 215 | + if (!$update_tables['player_award']) { |
|
| 216 | 216 | upd_create_table('player_award', "( |
| 217 | 217 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 218 | 218 | `award_type_id` int(11) DEFAULT NULL COMMENT 'Award type i.e. order, medal, pennant, rank etc', |
@@ -254,14 +254,14 @@ discard block |
||
| 254 | 254 | upd_log_version_update(); |
| 255 | 255 | |
| 256 | 256 | |
| 257 | - if(!isset($update_tables['planets']['que_processed'])) { |
|
| 257 | + if (!isset($update_tables['planets']['que_processed'])) { |
|
| 258 | 258 | upd_alter_table('planets', array( |
| 259 | 259 | "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `last_update`", |
| 260 | 260 | ), true); |
| 261 | 261 | upd_do_query("UPDATE {{planets}} SET que_processed = last_update;"); |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - if(!isset($update_tables['users']['que_processed'])) { |
|
| 264 | + if (!isset($update_tables['users']['que_processed'])) { |
|
| 265 | 265 | upd_alter_table('users', array( |
| 266 | 266 | "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `onlinetime`", |
| 267 | 267 | ), true); |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | |
| 272 | - if(isset($update_tables['planets']['que'])) { |
|
| 272 | + if (isset($update_tables['planets']['que'])) { |
|
| 273 | 273 | $sn_data_aux = array( |
| 274 | 274 | SHIP_SMALL_FIGHTER_WRATH => array( |
| 275 | 275 | 'name' => 'ship_fighter_wrath', |
@@ -354,20 +354,20 @@ discard block |
||
| 354 | 354 | $unit_data = array(); |
| 355 | 355 | $planets = array(); |
| 356 | 356 | |
| 357 | - foreach($planet_unit_list as $unit_id) { |
|
| 358 | - if(!($unit_name = get_unit_param($unit_id, P_NAME))) { |
|
| 357 | + foreach ($planet_unit_list as $unit_id) { |
|
| 358 | + if (!($unit_name = get_unit_param($unit_id, P_NAME))) { |
|
| 359 | 359 | $unit_name = $sn_data_aux[$unit_id][P_NAME]; |
| 360 | 360 | } |
| 361 | - if(isset($update_tables['planets'][$unit_name])) { |
|
| 361 | + if (isset($update_tables['planets'][$unit_name])) { |
|
| 362 | 362 | $drop[] = "DROP COLUMN `{$unit_name}`"; |
| 363 | 363 | |
| 364 | - if(isset($aux_group[$unit_id])) { |
|
| 364 | + if (isset($aux_group[$unit_id])) { |
|
| 365 | 365 | $units_info[$unit_id] = $sn_data_aux[$unit_id]; |
| 366 | 366 | $units_info[$unit_id]['que'] = QUE_HANGAR; |
| 367 | 367 | } else { |
| 368 | 368 | $units_info[$unit_id] = get_unit_param($unit_id); |
| 369 | - foreach($ques_info as $que_id => $que_data1) { |
|
| 370 | - if(in_array($unit_id, $que_data1['unit_list'])) { |
|
| 369 | + foreach ($ques_info as $que_id => $que_data1) { |
|
| 370 | + if (in_array($unit_id, $que_data1['unit_list'])) { |
|
| 371 | 371 | $units_info[$unit_id]['que'] = $que_id; |
| 372 | 372 | break; |
| 373 | 373 | } |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | $query = upd_do_query("SELECT * FROM {{planets}} FOR UPDATE"); |
| 380 | - while($row = db_fetch($query)) { |
|
| 380 | + while ($row = db_fetch($query)) { |
|
| 381 | 381 | $user_id = $row['id_owner']; |
| 382 | 382 | $planet_id = $row['id']; |
| 383 | 383 | |
@@ -385,25 +385,25 @@ discard block |
||
| 385 | 385 | |
| 386 | 386 | // Конвертируем юниты |
| 387 | 387 | $units_levels = array(); |
| 388 | - foreach($planet_unit_list as $unit_id) { |
|
| 388 | + foreach ($planet_unit_list as $unit_id) { |
|
| 389 | 389 | $unit_name = &$units_info[$unit_id][P_NAME]; |
| 390 | - if(!isset($row[$unit_name]) || !$row[$unit_name]) { |
|
| 390 | + if (!isset($row[$unit_name]) || !$row[$unit_name]) { |
|
| 391 | 391 | continue; |
| 392 | 392 | } |
| 393 | 393 | $units_levels[$unit_id] = $row[$unit_name]; |
| 394 | - $unit_data[] = "({$user_id}," . LOC_PLANET . ",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})"; |
|
| 395 | - if(count($unit_data) > 30) { |
|
| 394 | + $unit_data[] = "({$user_id},".LOC_PLANET.",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})"; |
|
| 395 | + if (count($unit_data) > 30) { |
|
| 396 | 396 | $unit_data_max = strlen(implode(',', $unit_data)) > $unit_data_max ? strlen(implode(',', $unit_data)) : $unit_data_max; |
| 397 | - upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';'); |
|
| 397 | + upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES '.implode(',', $unit_data).';'); |
|
| 398 | 398 | $unit_data = array(); |
| 399 | 399 | } |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | // Конвертируем очередь построек |
| 403 | - if($row['que']) { |
|
| 403 | + if ($row['que']) { |
|
| 404 | 404 | $que = explode(';', $row['que']); |
| 405 | - foreach($que as $que_item) { |
|
| 406 | - if(!$que_item) { |
|
| 405 | + foreach ($que as $que_item) { |
|
| 406 | + if (!$que_item) { |
|
| 407 | 407 | continue; |
| 408 | 408 | } |
| 409 | 409 | |
@@ -418,8 +418,8 @@ discard block |
||
| 418 | 418 | $unit_factor = $unit_cost[P_FACTOR] ? $unit_cost[P_FACTOR] : 1; |
| 419 | 419 | $price_increase = pow($unit_factor, $unit_level); |
| 420 | 420 | // $unit_time = 0; |
| 421 | - foreach($unit_cost as $resource_id => &$resource_amount) { |
|
| 422 | - if(!in_array($resource_id, $group_resource_loot)) { |
|
| 421 | + foreach ($unit_cost as $resource_id => &$resource_amount) { |
|
| 422 | + if (!in_array($resource_id, $group_resource_loot)) { |
|
| 423 | 423 | unset($unit_cost[$resource_id]); |
| 424 | 424 | continue; |
| 425 | 425 | } |
@@ -433,39 +433,39 @@ discard block |
||
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | // Конвертируем очередь верфи |
| 436 | - if($row['b_hangar_id']) { |
|
| 436 | + if ($row['b_hangar_id']) { |
|
| 437 | 437 | $return_resources = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0,); |
| 438 | 438 | $hangar_units = sys_unit_str2arr($row['b_hangar_id']); |
| 439 | - foreach($hangar_units as $unit_id => $unit_count) { |
|
| 440 | - if($unit_count <= 0) { |
|
| 439 | + foreach ($hangar_units as $unit_id => $unit_count) { |
|
| 440 | + if ($unit_count <= 0) { |
|
| 441 | 441 | continue; |
| 442 | 442 | } |
| 443 | - foreach($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) { |
|
| 444 | - if(!in_array($resource_id, $group_resource_loot)) { |
|
| 443 | + foreach ($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) { |
|
| 444 | + if (!in_array($resource_id, $group_resource_loot)) { |
|
| 445 | 445 | continue; |
| 446 | 446 | } |
| 447 | 447 | $return_resources[$resource_id] += $unit_count * $resource_amount; |
| 448 | 448 | } |
| 449 | 449 | } |
| 450 | - if(array_sum($return_resources) > 0) { |
|
| 450 | + if (array_sum($return_resources) > 0) { |
|
| 451 | 451 | upd_do_query("UPDATE {{planets}} SET `metal` = `metal` + {$return_resources[RES_METAL]}, `crystal` = `crystal` + {$return_resources[RES_CRYSTAL]}, `deuterium` = `deuterium` + {$return_resources[RES_DEUTERIUM]} WHERE `id` = {$planet_id} LIMIT 1"); |
| 452 | 452 | } |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | |
| 456 | - if(count($que_data) > 10) { |
|
| 456 | + if (count($que_data) > 10) { |
|
| 457 | 457 | $que_data_max = strlen(implode(',', $que_data)) > $que_data_max ? strlen(implode(',', $que_data)) : $que_data_max; |
| 458 | - upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES ' . implode(',', $que_data) . ';'); |
|
| 458 | + upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES '.implode(',', $que_data).';'); |
|
| 459 | 459 | $que_data = array(); |
| 460 | 460 | } |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | - if(!empty($unit_data)) { |
|
| 464 | - upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';'); |
|
| 463 | + if (!empty($unit_data)) { |
|
| 464 | + upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES '.implode(',', $unit_data).';'); |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | - if(!empty($que_data)) { |
|
| 468 | - upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES ' . implode(',', $que_data) . ';'); |
|
| 467 | + if (!empty($que_data)) { |
|
| 468 | + upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES '.implode(',', $que_data).';'); |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | upd_alter_table('planets', $drop, true); |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | JOIN `{{users}}` AS u ON a.`id` = u.`user_as_ally` AND `user_as_ally` IS NOT NULL AND `username` = '' |
| 476 | 476 | SET u.`username` = CONCAT('[', a.`ally_tag`, ']');"); |
| 477 | 477 | |
| 478 | - if($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') { |
|
| 478 | + if ($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') { |
|
| 479 | 479 | upd_do_query("SET FOREIGN_KEY_CHECKS=0;"); |
| 480 | 480 | upd_alter_table('statpoints', "DROP FOREIGN KEY `FK_stats_id_ally`", $update_foreigns['statpoints']['FK_stats_id_ally']); |
| 481 | 481 | upd_alter_table('statpoints', "DROP KEY `I_stats_id_ally`", $update_indexes['statpoints']['I_stats_id_ally']); |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | "ADD CONSTRAINT `FK_users_browser_id` FOREIGN KEY (`user_last_browser_id`) REFERENCES `{{security_browser}}` (`browser_id`) ON DELETE SET NULL ON UPDATE CASCADE", |
| 572 | 572 | ), !isset($update_tables['users']['user_last_proxy'])); |
| 573 | 573 | |
| 574 | - if(!isset($update_tables['notes']['planet_type'])) { |
|
| 574 | + if (!isset($update_tables['notes']['planet_type'])) { |
|
| 575 | 575 | upd_alter_table('notes', array( |
| 576 | 576 | "ADD COLUMN `galaxy` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `title`", |
| 577 | 577 | "ADD COLUMN `system` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `galaxy`", |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | upd_alter_table('users', "ADD COLUMN `user_bot` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['users']['user_bot'])); |
| 590 | 590 | upd_alter_table('unit', "ADD KEY `I_unit_type_snid` (unit_type, unit_snid) USING BTREE", !$update_indexes['unit']['I_unit_type_snid']); |
| 591 | 591 | |
| 592 | - if($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') { |
|
| 592 | + if ($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') { |
|
| 593 | 593 | upd_alter_table('users', array( |
| 594 | 594 | "MODIFY COLUMN `settings_tooltiptime` smallint(5) unsigned NOT NULL DEFAULT '500'", |
| 595 | 595 | ), $update_tables['users']['settings_tooltiptime']['Type'] != 'smallint'); |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | upd_do_query("UPDATE `{{users}}` SET settings_tooltiptime = 500;"); |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | - if(!isset($update_tables['log_users_online']['online_aggregated'])) { |
|
| 600 | + if (!isset($update_tables['log_users_online']['online_aggregated'])) { |
|
| 601 | 601 | upd_alter_table('log_users_online', "ADD COLUMN `online_aggregated` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['log_users_online']['online_aggregated'])); |
| 602 | 602 | upd_alter_table('log_users_online', array( |
| 603 | 603 | "DROP PRIMARY KEY", |
@@ -605,13 +605,13 @@ discard block |
||
| 605 | 605 | ), $update_indexes['log_users_online']['PRIMARY'] != 'online_timestamp,online_aggregated,'); |
| 606 | 606 | } |
| 607 | 607 | |
| 608 | - if(!isset($update_tables['users']['gender'])) { |
|
| 609 | - upd_alter_table('users', "ADD COLUMN `gender` TINYINT(1) UNSIGNED NOT NULL DEFAULT " . GENDER_UNKNOWN, !isset($update_tables['users']['gender'])); |
|
| 610 | - upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', " . GENDER_FEMALE . ", IF(UPPER(`sex`) = 'M', " . GENDER_MALE . ", " . GENDER_UNKNOWN . "));"); |
|
| 608 | + if (!isset($update_tables['users']['gender'])) { |
|
| 609 | + upd_alter_table('users', "ADD COLUMN `gender` TINYINT(1) UNSIGNED NOT NULL DEFAULT ".GENDER_UNKNOWN, !isset($update_tables['users']['gender'])); |
|
| 610 | + upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', ".GENDER_FEMALE.", IF(UPPER(`sex`) = 'M', ".GENDER_MALE.", ".GENDER_UNKNOWN."));"); |
|
| 611 | 611 | } |
| 612 | 612 | upd_alter_table('users', "DROP COLUMN `sex`", isset($update_tables['users']['sex'])); |
| 613 | 613 | |
| 614 | - if(!$update_tables['users']['dark_matter_total']) { |
|
| 614 | + if (!$update_tables['users']['dark_matter_total']) { |
|
| 615 | 615 | upd_alter_table('users', "ADD `dark_matter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Dark Matter amount ever gained' AFTER `dark_matter`", !$update_tables['users']['dark_matter_total']); |
| 616 | 616 | upd_do_query( |
| 617 | 617 | "UPDATE `{{users}}` AS u |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | upd_check_key('player_metamatter_immortal', 100000, !isset(classSupernova::$config->player_metamatter_immortal)); |
| 627 | - if(!$update_tables['users']['metamatter_total']) { |
|
| 627 | + if (!$update_tables['users']['metamatter_total']) { |
|
| 628 | 628 | upd_alter_table('users', "ADD `metamatter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Metamatter amount ever bought'", !$update_tables['users']['metamatter_total']); |
| 629 | 629 | |
| 630 | 630 | upd_do_query( |
@@ -636,11 +636,11 @@ discard block |
||
| 636 | 636 | (SELECT IF(sum(amount) IS NULL, 0, sum(amount)) FROM {{log_metamatter}} AS mm WHERE mm.user_id = u.id AND mm.amount > 0) |
| 637 | 637 | );"); |
| 638 | 638 | } |
| 639 | - if(!isset($update_tables['users']['immortal'])) { |
|
| 639 | + if (!isset($update_tables['users']['immortal'])) { |
|
| 640 | 640 | upd_alter_table('users', "ADD COLUMN `immortal` TIMESTAMP NULL", !isset($update_tables['users']['immortal'])); |
| 641 | 641 | upd_do_query("UPDATE {{users}} SET `immortal` = NOW() WHERE `metamatter_total` > 0;"); |
| 642 | 642 | } |
| 643 | - if(isset($update_tables['player_award'])) { |
|
| 643 | + if (isset($update_tables['player_award'])) { |
|
| 644 | 644 | upd_do_query( |
| 645 | 645 | "UPDATE {{users}} AS u JOIN {{player_award}} AS pa ON u.id = pa.player_id |
| 646 | 646 | SET metamatter_total = 1, immortal = NOW() |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | CONSTRAINT `FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
| 668 | 668 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"); |
| 669 | 669 | |
| 670 | - if(empty($update_tables['blitz_statpoints'])) { |
|
| 670 | + if (empty($update_tables['blitz_statpoints'])) { |
|
| 671 | 671 | upd_create_table('blitz_statpoints', " ( |
| 672 | 672 | `stat_date` int(11) NOT NULL DEFAULT '0', |
| 673 | 673 | `id_owner` bigint(20) unsigned DEFAULT NULL, |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | CONSTRAINT `FK_survey_votes_survey_parent_id` FOREIGN KEY (`survey_parent_id`) REFERENCES `{{survey}}` (`survey_id`) ON DELETE CASCADE ON UPDATE CASCADE |
| 736 | 736 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"); |
| 737 | 737 | |
| 738 | - if(empty($update_tables['security_url'])) { |
|
| 738 | + if (empty($update_tables['security_url'])) { |
|
| 739 | 739 | upd_create_table('security_url', " ( |
| 740 | 740 | `url_id` int unsigned NOT NULL AUTO_INCREMENT, |
| 741 | 741 | `url_string` VARCHAR(250) NOT NULL DEFAULT '', |
@@ -748,17 +748,17 @@ discard block |
||
| 748 | 748 | |
| 749 | 749 | $strings = array(); |
| 750 | 750 | $query = classSupernova::$db->doSql($query); |
| 751 | - while($row = db_fetch($query)) { |
|
| 752 | - $strings[] = '("' . db_escape($row['url']) . '")'; |
|
| 753 | - if(count($strings) > 100) { |
|
| 754 | - classSupernova::$db->doSql($query_string . implode(',', $strings)); |
|
| 751 | + while ($row = db_fetch($query)) { |
|
| 752 | + $strings[] = '("'.db_escape($row['url']).'")'; |
|
| 753 | + if (count($strings) > 100) { |
|
| 754 | + classSupernova::$db->doSql($query_string.implode(',', $strings)); |
|
| 755 | 755 | $strings = array(); |
| 756 | 756 | } |
| 757 | 757 | } |
| 758 | - !empty($strings) ? classSupernova::$db->doSql($query_string . implode(',', $strings)) : false; |
|
| 758 | + !empty($strings) ? classSupernova::$db->doSql($query_string.implode(',', $strings)) : false; |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | - if(isset($update_tables['counter']['page'])) // TODO REMOVE |
|
| 761 | + if (isset($update_tables['counter']['page'])) // TODO REMOVE |
|
| 762 | 762 | { |
| 763 | 763 | update_security_url("SELECT DISTINCT `page` AS url FROM {{counter}}"); |
| 764 | 764 | update_security_url("SELECT DISTINCT `url` AS url FROM {{counter}}"); |
@@ -783,7 +783,7 @@ discard block |
||
| 783 | 783 | "ADD CONSTRAINT `FK_counter_page_url_id` FOREIGN KEY (`page_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE", |
| 784 | 784 | "ADD CONSTRAINT `FK_counter_plain_url_id` FOREIGN KEY (`plain_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE", |
| 785 | 785 | ), !isset($update_tables['counter']['device_id'])); |
| 786 | - if(isset($update_tables['counter']['ip'])) { |
|
| 786 | + if (isset($update_tables['counter']['ip'])) { |
|
| 787 | 787 | // upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `user_proxy` = `proxy`, `visit_time` = FROM_UNIXTIME(`time`)'); |
| 788 | 788 | upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `visit_time` = FROM_UNIXTIME(`time`)'); |
| 789 | 789 | upd_do_query('UPDATE `{{counter}}` AS c JOIN {{security_url}} AS u ON u.url_string = c.page SET c.page_url_id = u.url_id'); |
@@ -834,7 +834,7 @@ discard block |
||
| 834 | 834 | |
| 835 | 835 | upd_check_key('stats_history_days', 14, !classSupernova::$config->stats_history_days); |
| 836 | 836 | |
| 837 | - if(classSupernova::$config->payment_currency_default != 'USD') { |
|
| 837 | + if (classSupernova::$config->payment_currency_default != 'USD') { |
|
| 838 | 838 | upd_check_key('payment_currency_default', 'USD', true); |
| 839 | 839 | upd_check_key('payment_currency_exchange_dm_', 20000, true); |
| 840 | 840 | upd_check_key('payment_currency_exchange_mm_', 20000, true); |
@@ -891,7 +891,7 @@ discard block |
||
| 891 | 891 | |
| 892 | 892 | $virtual_exploded = explode('/', SN_ROOT_VIRTUAL_PARENT); |
| 893 | 893 | // TODO - переделать всё на db_loadItem... НАВЕРНОЕ |
| 894 | - upd_check_key('server_email', 'root@' . $virtual_exploded[2], !classSupernova::$config->db_loadItem('server_email')); |
|
| 894 | + upd_check_key('server_email', 'root@'.$virtual_exploded[2], !classSupernova::$config->db_loadItem('server_email')); |
|
| 895 | 895 | |
| 896 | 896 | upd_alter_table('survey_votes', array( |
| 897 | 897 | "DROP FOREIGN KEY `FK_survey_votes_user`", |
@@ -917,12 +917,12 @@ discard block |
||
| 917 | 917 | function propagade_player_options($old_option_name, $new_option_id) { |
| 918 | 918 | global $update_tables; |
| 919 | 919 | |
| 920 | - if(!empty($update_tables['users'][$old_option_name])) { |
|
| 920 | + if (!empty($update_tables['users'][$old_option_name])) { |
|
| 921 | 921 | upd_do_query( |
| 922 | 922 | "REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`) |
| 923 | 923 | SELECT `id`, {$new_option_id}, `{$old_option_name}` |
| 924 | 924 | FROM {{users}} |
| 925 | - WHERE `user_as_ally` is null and `user_bot` = " . USER_BOT_PLAYER); |
|
| 925 | + WHERE `user_as_ally` is null and `user_bot` = ".USER_BOT_PLAYER); |
|
| 926 | 926 | // TODO - UNCOMMENT !!! |
| 927 | 927 | upd_alter_table('users', array("DROP COLUMN `{$old_option_name}`",)); |
| 928 | 928 | } |
@@ -951,7 +951,7 @@ discard block |
||
| 951 | 951 | |
| 952 | 952 | |
| 953 | 953 | // 2015-08-03 15:05:26 40a6.0 |
| 954 | - if(empty($update_tables['planets']['position_original'])) { |
|
| 954 | + if (empty($update_tables['planets']['position_original'])) { |
|
| 955 | 955 | upd_alter_table('planets', array( |
| 956 | 956 | "ADD COLUMN `position_original` smallint NOT NULL DEFAULT 0", |
| 957 | 957 | "ADD COLUMN `field_max_original` smallint NOT NULL DEFAULT 0", |
@@ -966,7 +966,7 @@ discard block |
||
| 966 | 966 | upd_do_query('UPDATE {{planets}} SET `position_original` = `planet`, `field_max_original` = `field_max`, `temp_min_original` = `temp_min`, `temp_max_original` = `temp_max`;'); |
| 967 | 967 | |
| 968 | 968 | // Миграция тяжмета в оливин |
| 969 | - upd_do_query('UPDATE {{planets}} SET `density_index` = ' . PLANET_DENSITY_METAL_PERIDOT . ' WHERE `density_index` = 7'); // deprecated define('PLANET_DENSITY_METAL_HEAVY', 7); |
|
| 969 | + upd_do_query('UPDATE {{planets}} SET `density_index` = '.PLANET_DENSITY_METAL_PERIDOT.' WHERE `density_index` = 7'); // deprecated define('PLANET_DENSITY_METAL_HEAVY', 7); |
|
| 970 | 970 | |
| 971 | 971 | // Добавляем планету-странника |
| 972 | 972 | upd_check_key('game_maxPlanet', 16, Vector::$knownPlanets == 15); |
@@ -979,12 +979,12 @@ discard block |
||
| 979 | 979 | |
| 980 | 980 | // 2015-08-27 19:14:05 40a10.0 |
| 981 | 981 | // Старая версия таблицы |
| 982 | - if(!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) { |
|
| 982 | + if (!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) { |
|
| 983 | 983 | upd_drop_table('account'); |
| 984 | 984 | upd_drop_table('account_translate'); |
| 985 | 985 | } |
| 986 | 986 | |
| 987 | - if(empty($update_tables['account'])) { |
|
| 987 | + if (empty($update_tables['account'])) { |
|
| 988 | 988 | upd_create_table('account', " ( |
| 989 | 989 | `account_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 990 | 990 | `account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT '', |
@@ -1003,7 +1003,7 @@ discard block |
||
| 1003 | 1003 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"); |
| 1004 | 1004 | |
| 1005 | 1005 | upd_create_table('account_translate', " ( |
| 1006 | - `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Account provider', |
|
| 1006 | + `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL." COMMENT 'Account provider', |
|
| 1007 | 1007 | `provider_account_id` bigint(20) unsigned NOT NULL COMMENT 'Account ID on provider', |
| 1008 | 1008 | `user_id` bigint(20) unsigned NOT NULL COMMENT 'User ID', |
| 1009 | 1009 | `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, |
@@ -1018,12 +1018,12 @@ discard block |
||
| 1018 | 1018 | (`account_id`, `account_name`, `account_password`, `account_salt`, `account_email`, `account_register_time`, `account_language`, `account_metamatter`, `account_metamatter_total`, `account_immortal`) |
| 1019 | 1019 | SELECT |
| 1020 | 1020 | `id`, `username`, `password`, `salt`, `email_2`, FROM_UNIXTIME(register_time), `lang`, `metamatter`, `metamatter_total`, `immortal` |
| 1021 | - FROM {{users}} WHERE `user_as_ally` IS NULL AND `user_bot` = " . USER_BOT_PLAYER . ";" |
|
| 1021 | + FROM {{users}} WHERE `user_as_ally` IS NULL AND `user_bot` = " . USER_BOT_PLAYER.";" |
|
| 1022 | 1022 | ); |
| 1023 | 1023 | |
| 1024 | 1024 | upd_do_query( |
| 1025 | 1025 | "REPLACE INTO {{account_translate}} (`provider_id`, `provider_account_id`, `user_id`, `timestamp`) |
| 1026 | - SELECT " . ACCOUNT_PROVIDER_LOCAL . ", a.account_id, u.id, a.`account_register_time` |
|
| 1026 | + SELECT " . ACCOUNT_PROVIDER_LOCAL.", a.account_id, u.id, a.`account_register_time` |
|
| 1027 | 1027 | FROM {{users}} AS u |
| 1028 | 1028 | JOIN {{account}} AS a ON |
| 1029 | 1029 | a.account_name = u.username |
@@ -1038,7 +1038,7 @@ discard block |
||
| 1038 | 1038 | |
| 1039 | 1039 | |
| 1040 | 1040 | // 2015-09-05 17:07:15 40a10.17 |
| 1041 | - upd_alter_table('ube_report', "ADD COLUMN `ube_report_capture_result` tinyint unsigned NOT NULL DEFAULT " . UBE_CAPTURE_DISABLED, empty($update_tables['ube_report']['ube_report_capture_result'])); |
|
| 1041 | + upd_alter_table('ube_report', "ADD COLUMN `ube_report_capture_result` tinyint unsigned NOT NULL DEFAULT ".UBE_CAPTURE_DISABLED, empty($update_tables['ube_report']['ube_report_capture_result'])); |
|
| 1042 | 1042 | |
| 1043 | 1043 | |
| 1044 | 1044 | // 2015-09-07 21:11:48 40a10.19 |
@@ -1046,18 +1046,18 @@ discard block |
||
| 1046 | 1046 | |
| 1047 | 1047 | |
| 1048 | 1048 | // 2015-09-24 11:39:37 40a10.25 |
| 1049 | - if(empty($update_tables['log_metamatter']['provider_id'])) { |
|
| 1049 | + if (empty($update_tables['log_metamatter']['provider_id'])) { |
|
| 1050 | 1050 | upd_alter_table('log_metamatter', array( |
| 1051 | - "ADD COLUMN `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Account provider'", |
|
| 1051 | + "ADD COLUMN `provider_id` tinyint unsigned NOT NULL DEFAULT ".ACCOUNT_PROVIDER_LOCAL." COMMENT 'Account provider'", |
|
| 1052 | 1052 | "ADD COLUMN `account_id` bigint(20) unsigned NOT NULL DEFAULT 0", |
| 1053 | 1053 | "ADD COLUMN `account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT ''", |
| 1054 | - "ADD COLUMN `server_name` varchar(128) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT '" . SN_ROOT_VIRTUAL . "'", |
|
| 1054 | + "ADD COLUMN `server_name` varchar(128) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT '".SN_ROOT_VIRTUAL."'", |
|
| 1055 | 1055 | ), empty($update_tables['log_metamatter']['provider_id'])); |
| 1056 | 1056 | |
| 1057 | 1057 | upd_do_query("UPDATE {{log_metamatter}} SET `account_id` = `user_id`, `account_name` = `username`"); |
| 1058 | 1058 | |
| 1059 | 1059 | upd_alter_table('payment', array( |
| 1060 | - "ADD COLUMN `payment_provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Payment account provider'", |
|
| 1060 | + "ADD COLUMN `payment_provider_id` tinyint unsigned NOT NULL DEFAULT ".ACCOUNT_PROVIDER_LOCAL." COMMENT 'Payment account provider'", |
|
| 1061 | 1061 | "ADD COLUMN `payment_account_id` bigint(20) unsigned NOT NULL", |
| 1062 | 1062 | "ADD COLUMN `payment_account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT ''", |
| 1063 | 1063 | ), !$update_tables['payment']['payment_account_id']); |
@@ -1098,7 +1098,7 @@ discard block |
||
| 1098 | 1098 | upd_check_key('event_halloween_2015_code', '', !isset(classSupernova::$config->event_halloween_2015_code)); |
| 1099 | 1099 | upd_check_key('event_halloween_2015_timestamp', SN_TIME_SQL, !isset(classSupernova::$config->event_halloween_2015_timestamp)); |
| 1100 | 1100 | upd_check_key('event_halloween_2015_units_used', serialize(array()), !isset(classSupernova::$config->event_halloween_2015_units_used)); |
| 1101 | - if(empty($update_tables['log_halloween_2015'])) { |
|
| 1101 | + if (empty($update_tables['log_halloween_2015'])) { |
|
| 1102 | 1102 | upd_create_table('log_halloween_2015', " ( |
| 1103 | 1103 | `log_hw2015_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 1104 | 1104 | `player_id` bigint(20) unsigned NOT NULL COMMENT 'User ID', |
@@ -1113,7 +1113,7 @@ discard block |
||
| 1113 | 1113 | |
| 1114 | 1114 | |
| 1115 | 1115 | // 2015-11-28 06:30:27 40a19.21 |
| 1116 | - if(!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) { |
|
| 1116 | + if (!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) { |
|
| 1117 | 1117 | upd_alter_table('ube_report', array( |
| 1118 | 1118 | "ADD COLUMN `ube_report_debris_total_in_metal` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Total debris in metal'", |
| 1119 | 1119 | "ADD KEY `I_ube_report_time_debris_id` (`ube_report_time_process` DESC, `ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC)", // For Best Battles module |
@@ -1128,7 +1128,7 @@ discard block |
||
| 1128 | 1128 | |
| 1129 | 1129 | |
| 1130 | 1130 | // 2015-12-06 15:10:58 40b1.0 |
| 1131 | - if(!empty($update_indexes['planets']['I_metal_mine'])) { |
|
| 1131 | + if (!empty($update_indexes['planets']['I_metal_mine'])) { |
|
| 1132 | 1132 | upd_alter_table('planets', "DROP KEY `I_metal`", $update_indexes['planets']['I_metal']); |
| 1133 | 1133 | upd_alter_table('planets', "DROP KEY `I_ship_sattelite_sloth`", $update_indexes['planets']['I_ship_sattelite_sloth']); |
| 1134 | 1134 | upd_alter_table('planets', "DROP KEY `I_ship_bomber_envy`", $update_indexes['planets']['I_ship_bomber_envy']); |
@@ -1191,7 +1191,7 @@ discard block |
||
| 1191 | 1191 | case 40: |
| 1192 | 1192 | upd_log_version_update(); |
| 1193 | 1193 | |
| 1194 | - if(empty($update_tables['festival'])) { |
|
| 1194 | + if (empty($update_tables['festival'])) { |
|
| 1195 | 1195 | upd_create_table('festival', " ( |
| 1196 | 1196 | `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
| 1197 | 1197 | `start` datetime NOT NULL COMMENT 'Festival start datetime', |
@@ -1232,7 +1232,7 @@ discard block |
||
| 1232 | 1232 | ); |
| 1233 | 1233 | } |
| 1234 | 1234 | |
| 1235 | - if(empty($update_tables['festival_unit'])) { |
|
| 1235 | + if (empty($update_tables['festival_unit'])) { |
|
| 1236 | 1236 | upd_create_table('festival_unit', " ( |
| 1237 | 1237 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 1238 | 1238 | `highspot_id` int(10) unsigned DEFAULT NULL, |
@@ -1249,7 +1249,7 @@ discard block |
||
| 1249 | 1249 | } |
| 1250 | 1250 | |
| 1251 | 1251 | // 2015-12-21 06:06:09 41a0.12 |
| 1252 | - if(empty($update_tables['festival_unit_log'])) { |
|
| 1252 | + if (empty($update_tables['festival_unit_log'])) { |
|
| 1253 | 1253 | upd_create_table('festival_unit_log', " ( |
| 1254 | 1254 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
| 1255 | 1255 | `highspot_id` int(10) unsigned DEFAULT NULL, |
@@ -1279,19 +1279,19 @@ discard block |
||
| 1279 | 1279 | $update_tables['security_browser']['browser_user_agent']['Collation'] == 'latin1_bin' |
| 1280 | 1280 | ); |
| 1281 | 1281 | |
| 1282 | - if($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') { |
|
| 1282 | + if ($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') { |
|
| 1283 | 1283 | upd_alter_table('security_browser', "DROP KEY `I_browser_user_agent`", true); |
| 1284 | 1284 | upd_alter_table('security_browser', "ADD KEY `I_browser_user_agent` (`browser_user_agent`) USING HASH", true); |
| 1285 | 1285 | } |
| 1286 | 1286 | |
| 1287 | - if(!empty($update_tables['fleets']['fleet_array'])) { |
|
| 1287 | + if (!empty($update_tables['fleets']['fleet_array'])) { |
|
| 1288 | 1288 | $query = upd_do_query("SELECT * FROM {{fleets}}"); |
| 1289 | - while($row = db_fetch($query)) { |
|
| 1289 | + while ($row = db_fetch($query)) { |
|
| 1290 | 1290 | $unit_list = sys_unit_str2arr($row['fleet_array']); |
| 1291 | - foreach($unit_list as $unit_id => $unit_count) { |
|
| 1291 | + foreach ($unit_list as $unit_id => $unit_count) { |
|
| 1292 | 1292 | upd_do_query( |
| 1293 | 1293 | "REPLACE INTO {{unit}} (`unit_player_id`,`unit_location_type`,`unit_location_id`,`unit_type`,`unit_snid`,`unit_level`) VALUES |
| 1294 | - ({$row['fleet_owner']}, " . LOC_FLEET . ", {$row['fleet_id']}, 200, {$unit_id}, {$unit_count});", |
|
| 1294 | + ({$row['fleet_owner']}, ".LOC_FLEET.", {$row['fleet_id']}, 200, {$unit_id}, {$unit_count});", |
|
| 1295 | 1295 | // ({$row['fleet_owner']}, " . LOC_FLEET . ", {$row['fleet_id']}, " . get_unit_param($unit_id, P_UNIT_TYPE) . ", {$unit_id}, {$unit_count});", |
| 1296 | 1296 | true |
| 1297 | 1297 | ); |
@@ -1325,11 +1325,11 @@ discard block |
||
| 1325 | 1325 | |
| 1326 | 1326 | classSupernova::$cache->unset_by_prefix('lng_'); |
| 1327 | 1327 | |
| 1328 | -if($new_version) { |
|
| 1328 | +if ($new_version) { |
|
| 1329 | 1329 | classSupernova::$config->db_saveItem('db_version', $new_version); |
| 1330 | 1330 | upd_log_message("<font color=green>DB version is now {$new_version}</font>"); |
| 1331 | 1331 | } else { |
| 1332 | - upd_log_message("DB version didn't changed from " . classSupernova::$config->db_version); |
|
| 1332 | + upd_log_message("DB version didn't changed from ".classSupernova::$config->db_version); |
|
| 1333 | 1333 | } |
| 1334 | 1334 | |
| 1335 | 1335 | classSupernova::$config->db_loadAll(); |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @return string |
| 91 | 91 | */ |
| 92 | 92 | protected function stringValue($value) { |
| 93 | - return "'" . $this->escape((string)$value) . "'"; |
|
| 93 | + return "'".$this->escape((string) $value)."'"; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @return string |
| 102 | 102 | */ |
| 103 | 103 | protected function quote($fieldName) { |
| 104 | - return "`" . $this->escape((string)$fieldName) . "`"; |
|
| 104 | + return "`".$this->escape((string) $fieldName)."`"; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * @return string |
| 113 | 113 | */ |
| 114 | 114 | protected function quoteTable($tableName) { |
| 115 | - return "`{{" . $this->escape((string)$tableName) . "}}`"; |
|
| 115 | + return "`{{".$this->escape((string) $tableName)."}}`"; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | public function table($table) { |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | foreach ($fieldValues as $fieldName => $fieldValue) { |
| 232 | 232 | // Integer $fieldName is DANGER! They skipped there! |
| 233 | 233 | if (!is_int($fieldName)) { |
| 234 | - $result[$fieldName] = $this->quote($fieldName) . " = " . $this->castAsDbValue($fieldValue); |
|
| 234 | + $result[$fieldName] = $this->quote($fieldName)." = ".$this->castAsDbValue($fieldValue); |
|
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | protected function buildCommand() { |
| 242 | 242 | switch ($this->command) { |
| 243 | 243 | case static::DELETE: |
| 244 | - $this->build[] = static::DELETE . " FROM " . $this->quoteTable($this->table) . ' '; |
|
| 244 | + $this->build[] = static::DELETE." FROM ".$this->quoteTable($this->table).' '; |
|
| 245 | 245 | break; |
| 246 | 246 | } |
| 247 | 247 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | if (!empty($error_msg)) { |
| 60 | 60 | // TODO - Убрать позже |
| 61 | - print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - ' . $error_msg . '</h1>'); |
|
| 61 | + print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - '.$error_msg.'</h1>'); |
|
| 62 | 62 | $backtrace = debug_backtrace(); |
| 63 | 63 | array_shift($backtrace); |
| 64 | 64 | pdump($backtrace); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | public function start($level = '') { |
| 72 | 72 | $this->check(null); |
| 73 | 73 | |
| 74 | - $level ? $this->db->doSql('SET TRANSACTION ISOLATION LEVEL ' . $level) : false; |
|
| 74 | + $level ? $this->db->doSql('SET TRANSACTION ISOLATION LEVEL '.$level) : false; |
|
| 75 | 75 | |
| 76 | 76 | $this->transaction_id++; |
| 77 | 77 | $this->db->doSql('START TRANSACTION'); |
@@ -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'] = classSupernova::$gc->snCache->getLocks(); |
| 157 | 157 | $error_backtrace['cSN_data'] = classSupernova::$gc->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'] = classSupernova::$gc->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->doSql($query, true) or die($fatal_error . classSupernova::$db->db_error()); |
|
| 222 | + ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";"; |
|
| 223 | + classSupernova::$db->doSql($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->doSql($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 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | if (classSupernova::$gc->snCache->isUnitLocatorNotSet($location_type, $location_id)) { |
| 27 | - $got_data = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . DBStaticUnit::db_unit_time_restrictions()); |
|
| 27 | + $got_data = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND ".DBStaticUnit::db_unit_time_restrictions()); |
|
| 28 | 28 | if (!empty($got_data) && is_array($got_data)) { |
| 29 | 29 | foreach ($got_data as $unit_id => $unit_data) { |
| 30 | 30 | classSupernova::$gc->snCache->setUnitLocatorByLocationAndIDs($location_type, $location_id, $unit_data); |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | public static function db_unit_count_by_user_and_type_and_snid($user_id, $unit_type = 0, $unit_snid = 0) { |
| 61 | 61 | $query = classSupernova::$db->doSelect( |
| 62 | - "SELECT unit_snid, sum(unit_level) as `qty` FROM {{unit}} WHERE `unit_player_id` = {$user_id} " . |
|
| 63 | - ($unit_type ? "AND `unit_type` = {$unit_type} " : '') . |
|
| 64 | - ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : '') . |
|
| 62 | + "SELECT unit_snid, sum(unit_level) as `qty` FROM {{unit}} WHERE `unit_player_id` = {$user_id} ". |
|
| 63 | + ($unit_type ? "AND `unit_type` = {$unit_type} " : ''). |
|
| 64 | + ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : ''). |
|
| 65 | 65 | 'GROUP BY `unit_snid`' |
| 66 | 66 | ); |
| 67 | 67 | $result = array(); |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | WHERE |
| 82 | 82 | f.fleet_owner = {$user_id} AND |
| 83 | 83 | (f.fleet_start_planet_id = {$location_id} OR f.fleet_end_planet_id = {$location_id}) |
| 84 | - AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = " . LOC_FLEET . " AND " . self::db_unit_time_restrictions() . |
|
| 85 | - " LIMIT 1" . |
|
| 84 | + AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = ".LOC_FLEET." AND ".self::db_unit_time_restrictions(). |
|
| 85 | + " LIMIT 1". |
|
| 86 | 86 | ($for_update ? ' FOR UPDATE' : '')); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | public static function db_unit_list_laboratories($user_id) { |
| 91 | 91 | return classSupernova::$db->doSelect("SELECT DISTINCT unit_location_id AS `id` |
| 92 | 92 | FROM {{unit}} |
| 93 | - WHERE unit_player_id = {$user_id} AND unit_location_type = " . LOC_PLANET . " AND unit_level > 0 AND unit_snid IN (" . STRUC_LABORATORY . ", " . STRUC_LABORATORY_NANO . ");"); |
|
| 93 | + WHERE unit_player_id = {$user_id} AND unit_location_type = ".LOC_PLANET." AND unit_level > 0 AND unit_snid IN (".STRUC_LABORATORY.", ".STRUC_LABORATORY_NANO.");"); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | return classSupernova::$db->doSelect( |
| 137 | 137 | "SELECT unit_player_id, unit_type, unit_snid, unit_level, count(*) AS unit_amount |
| 138 | 138 | FROM `{{unit}}` |
| 139 | - WHERE unit_level > 0 AND " . self::db_unit_time_restrictions() . |
|
| 139 | + WHERE unit_level > 0 AND " . self::db_unit_time_restrictions(). |
|
| 140 | 140 | " GROUP BY unit_player_id, unit_type, unit_snid, unit_level" |
| 141 | 141 | ); |
| 142 | 142 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | ), |
| 165 | 165 | array( |
| 166 | 166 | 'unit_time_finish IS NOT NULL', |
| 167 | - "unit_time_finish < FROM_UNIXTIME(" . SN_TIME_NOW . ")", |
|
| 167 | + "unit_time_finish < FROM_UNIXTIME(".SN_TIME_NOW.")", |
|
| 168 | 168 | ) |
| 169 | 169 | ); |
| 170 | 170 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | $temp = DBStaticUnit::db_get_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id'); |
| 205 | 205 | if (!empty($temp['unit_id'])) { |
| 206 | - $result = (bool)classSupernova::$gc->cacheOperator->db_upd_record_by_id( |
|
| 206 | + $result = (bool) classSupernova::$gc->cacheOperator->db_upd_record_by_id( |
|
| 207 | 207 | LOC_UNIT, |
| 208 | 208 | $temp['unit_id'], |
| 209 | 209 | array(), |
@@ -214,15 +214,15 @@ discard block |
||
| 214 | 214 | } else { |
| 215 | 215 | $locationIdRendered = $unit_location == LOC_USER ? $user['id'] : $planet_id; |
| 216 | 216 | $unitType = get_unit_param($unit_id, P_UNIT_TYPE); |
| 217 | - $result = (bool)classSupernova::$gc->cacheOperator->db_ins_record( |
|
| 217 | + $result = (bool) classSupernova::$gc->cacheOperator->db_ins_record( |
|
| 218 | 218 | LOC_UNIT, |
| 219 | 219 | array( |
| 220 | 220 | 'unit_player_id' => $user['id'], |
| 221 | - 'unit_location_type' => (int)$unit_location, |
|
| 221 | + 'unit_location_type' => (int) $unit_location, |
|
| 222 | 222 | 'unit_location_id' => $locationIdRendered, |
| 223 | - 'unit_type' => (int)$unitType, |
|
| 224 | - 'unit_snid' => (int)$unit_id, |
|
| 225 | - 'unit_level' => (float)$unit_value, |
|
| 223 | + 'unit_type' => (int) $unitType, |
|
| 224 | + 'unit_snid' => (int) $unit_id, |
|
| 225 | + 'unit_level' => (float) $unit_value, |
|
| 226 | 226 | ) |
| 227 | 227 | ); |
| 228 | 228 | } |
@@ -122,10 +122,10 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | $update_cache = false; |
| 124 | 124 | |
| 125 | - if(!empty($this->to_write)) { |
|
| 126 | - foreach($this->to_write as $key => $cork) { |
|
| 125 | + if (!empty($this->to_write)) { |
|
| 126 | + foreach ($this->to_write as $key => $cork) { |
|
| 127 | 127 | $value = is_array($this->data[$key]) ? serialize($this->data[$key]) : $this->data[$key]; // Сериализация для массивов при сохранении в БД |
| 128 | - $this->to_write[$key] = "({$this->user_id}, '" . db_escape($key) . "', '" . db_escape($value) . "')"; |
|
| 128 | + $this->to_write[$key] = "({$this->user_id}, '".db_escape($key)."', '".db_escape($value)."')"; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | classSupernova::$gc->db->doReplaceValuesDeprecated( |
@@ -143,9 +143,9 @@ discard block |
||
| 143 | 143 | $update_cache = true; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - if(!empty($this->to_delete)) { |
|
| 147 | - foreach($this->to_delete as $key => &$value) { |
|
| 148 | - $value = is_string($key) ? "'". db_escape($key) . "'" : $key; |
|
| 146 | + if (!empty($this->to_delete)) { |
|
| 147 | + foreach ($this->to_delete as $key => &$value) { |
|
| 148 | + $value = is_string($key) ? "'".db_escape($key)."'" : $key; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | classSupernova::$db->doDeleteDanger( |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | 'player_id' => $this->user_id, |
| 155 | 155 | ), |
| 156 | 156 | array( |
| 157 | - "`option_id` IN (" . implode(',', $this->to_delete) . ")", |
|
| 157 | + "`option_id` IN (".implode(',', $this->to_delete).")", |
|
| 158 | 158 | ) |
| 159 | 159 | ); |
| 160 | 160 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | $update_cache = true; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if($update_cache) { |
|
| 165 | + if ($update_cache) { |
|
| 166 | 166 | $field_name = $this->cached_name(); |
| 167 | 167 | classSupernova::$cache->$field_name = $this->data; |
| 168 | 168 | } |
@@ -181,11 +181,11 @@ discard block |
||
| 181 | 181 | $this->load(); |
| 182 | 182 | } |
| 183 | 183 | protected function cached_name() { |
| 184 | - return 'options_' . $this->user_id; |
|
| 184 | + return 'options_'.$this->user_id; |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | protected function load() { |
| 188 | - if($this->loaded) { |
|
| 188 | + if ($this->loaded) { |
|
| 189 | 189 | return; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | $this->to_write = array(); |
| 194 | 194 | $this->to_delete = array(); |
| 195 | 195 | |
| 196 | - if(!$this->user_id) { |
|
| 196 | + if (!$this->user_id) { |
|
| 197 | 197 | $this->loaded = true; |
| 198 | 198 | return; |
| 199 | 199 | } |
@@ -201,13 +201,13 @@ discard block |
||
| 201 | 201 | $field_name = $this->cached_name(); |
| 202 | 202 | $a_data = classSupernova::$cache->$field_name; |
| 203 | 203 | |
| 204 | - if(!empty($a_data)) { |
|
| 204 | + if (!empty($a_data)) { |
|
| 205 | 205 | $this->data = array_replace_recursive($this->data, $a_data); |
| 206 | 206 | return; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
| 210 | - while($row = db_fetch($query)) { |
|
| 210 | + while ($row = db_fetch($query)) { |
|
| 211 | 211 | // $this->data[$row['option_id']] = $row['value']; |
| 212 | 212 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
| 213 | 213 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | protected function cached_name() { |
| 287 | - return 'options_' . $this->user_id; |
|
| 287 | + return 'options_'.$this->user_id; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | // TODO - serialize/unserialize options |
@@ -292,14 +292,14 @@ discard block |
||
| 292 | 292 | // Если в массиве индекса только один элемент - значит это просто индекс |
| 293 | 293 | is_array($option_id) && count($option_id) == 1 ? $option_id = reset($option_id) : false; |
| 294 | 294 | |
| 295 | - if(!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) { |
|
| 295 | + if (!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) { |
|
| 296 | 296 | $this->load(); |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - if(is_array($option_id)) { |
|
| 299 | + if (is_array($option_id)) { |
|
| 300 | 300 | $result = $this->data; |
| 301 | - foreach($option_id as $sub_key) { |
|
| 302 | - if(!isset($result) || !isset($result[$sub_key])) { |
|
| 301 | + foreach ($option_id as $sub_key) { |
|
| 302 | + if (!isset($result) || !isset($result[$sub_key])) { |
|
| 303 | 303 | $result = null; |
| 304 | 304 | break; |
| 305 | 305 | } |
@@ -317,12 +317,12 @@ discard block |
||
| 317 | 317 | * @param null|mixed $value |
| 318 | 318 | */ |
| 319 | 319 | public function __set($option, $value = null) { |
| 320 | - if(empty($option) || !$this->user_id) { |
|
| 320 | + if (empty($option) || !$this->user_id) { |
|
| 321 | 321 | return; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | // Если в массиве индекса только один элемент - значит это просто индекс |
| 325 | - if(is_array($option) && count($option) == 1) { |
|
| 325 | + if (is_array($option) && count($option) == 1) { |
|
| 326 | 326 | // Разворачиваем его в индекс |
| 327 | 327 | $option = array(reset($option) => $value); |
| 328 | 328 | unset($value); |
@@ -331,13 +331,13 @@ discard block |
||
| 331 | 331 | |
| 332 | 332 | $to_write = array(); |
| 333 | 333 | // Адресация многомерного массива через массив индексов в $option |
| 334 | - if(is_array($option) && isset($value)) { |
|
| 334 | + if (is_array($option) && isset($value)) { |
|
| 335 | 335 | $a_data = &$this->data; |
| 336 | - foreach($option as $option_id) { |
|
| 336 | + foreach ($option as $option_id) { |
|
| 337 | 337 | !is_array($a_data[$option_id]) ? $a_data[$option_id] = array() : false; |
| 338 | 338 | $a_data = &$a_data[$option_id]; |
| 339 | 339 | } |
| 340 | - if($a_data != $value) { |
|
| 340 | + if ($a_data != $value) { |
|
| 341 | 341 | $a_data = $value; |
| 342 | 342 | $to_write[reset($option)] = null; |
| 343 | 343 | } |
@@ -345,11 +345,11 @@ discard block |
||
| 345 | 345 | // Пакетная запись из массива ключ -> значение |
| 346 | 346 | !is_array($option) ? $option = array($option => $value) : false; |
| 347 | 347 | |
| 348 | - foreach($option as $option_id => $option_value) { |
|
| 349 | - if($this->data[$option_id] !== $option_value) { |
|
| 348 | + foreach ($option as $option_id => $option_value) { |
|
| 349 | + if ($this->data[$option_id] !== $option_value) { |
|
| 350 | 350 | // TODO - вынести отдельно в обработчик |
| 351 | - if($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) { |
|
| 352 | - sn_setcookie(SN_COOKIE . '_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
|
| 351 | + if ($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) { |
|
| 352 | + sn_setcookie(SN_COOKIE.'_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | $this->data[$option_id] = $option_value; |
@@ -358,13 +358,13 @@ discard block |
||
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - if(!empty($to_write)) { |
|
| 361 | + if (!empty($to_write)) { |
|
| 362 | 362 | $field_name = $this->cached_name(); |
| 363 | 363 | classSupernova::$cache->$field_name = $this->data; |
| 364 | 364 | |
| 365 | - foreach($to_write as $option_id => &$option_value) { |
|
| 365 | + foreach ($to_write as $option_id => &$option_value) { |
|
| 366 | 366 | $option_value = is_array($this->data[$option_id]) ? serialize($this->data[$option_id]) : $this->data[$option_id]; // Сериализация для массивов при сохранении в БД |
| 367 | - $to_write[$option_id] = "({$this->user_id}, '" . db_escape($option_id) . "', '" . db_escape($option_value) . "')"; |
|
| 367 | + $to_write[$option_id] = "({$this->user_id}, '".db_escape($option_id)."', '".db_escape($option_value)."')"; |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | classSupernova::$gc->db->doReplaceValuesDeprecated( |
@@ -380,26 +380,26 @@ discard block |
||
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | protected function load() { |
| 383 | - if($this->loaded) { |
|
| 383 | + if ($this->loaded) { |
|
| 384 | 384 | return; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | $this->data = $this->defaults; |
| 388 | 388 | |
| 389 | - if(!$this->user_id) { |
|
| 389 | + if (!$this->user_id) { |
|
| 390 | 390 | return; |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | $field_name = $this->cached_name(); |
| 394 | 394 | $a_data = classSupernova::$cache->$field_name; |
| 395 | 395 | |
| 396 | - if(!empty($a_data)) { |
|
| 396 | + if (!empty($a_data)) { |
|
| 397 | 397 | $this->data = array_replace($this->data, $a_data); |
| 398 | 398 | return; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
| 402 | - while($row = db_fetch($query)) { |
|
| 402 | + while ($row = db_fetch($query)) { |
|
| 403 | 403 | // $this->data[$row['option_id']] = $row['value']; |
| 404 | 404 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
| 405 | 405 | } |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | return $this->__get($offset); |
| 416 | 416 | } |
| 417 | 417 | public function offsetSet($offset, $value) { |
| 418 | - if(!is_null($offset)) { |
|
| 418 | + if (!is_null($offset)) { |
|
| 419 | 419 | // $this->data[$offset] = $value; |
| 420 | 420 | $this->__set($offset, $value); |
| 421 | 421 | } else { |