@@ -293,7 +293,7 @@ |
||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
| 296 | - * @param $ranklist |
|
| 296 | + * @param string $ranklist |
|
| 297 | 297 | * @param $user |
| 298 | 298 | */ |
| 299 | 299 | public static function db_ally_update_ranklist($ranklist, $user) { |
@@ -75,7 +75,7 @@ |
||
| 75 | 75 | |
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | - * @param $fleet_group_id_list |
|
| 78 | + * @param string $fleet_group_id_list |
|
| 79 | 79 | */ |
| 80 | 80 | public static function db_acs_delete_by_list($fleet_group_id_list) { |
| 81 | 81 | doquery("DELETE FROM {{aks}} WHERE `id` IN ({$fleet_group_id_list})"); |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | /** |
| 156 | 156 | * @param string $query |
| 157 | 157 | * |
| 158 | - * @return mixed|string |
|
| 158 | + * @return string |
|
| 159 | 159 | */ |
| 160 | 160 | public function replaceTablePlaceholders($query) { |
| 161 | 161 | $sql = $query; |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
| 172 | - * @param $query |
|
| 172 | + * @param string $query |
|
| 173 | 173 | */ |
| 174 | 174 | protected function logQuery($query) { |
| 175 | 175 | if (!classSupernova::$config->debug) { |
@@ -311,10 +311,16 @@ discard block |
||
| 311 | 311 | return $this->doExecute($query); |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | + /** |
|
| 315 | + * @param string $table |
|
| 316 | + */ |
|
| 314 | 317 | public function doInsertSet($table, $fieldsAndValues) { |
| 315 | 318 | return $this->doSet($table, $fieldsAndValues, false); |
| 316 | 319 | } |
| 317 | 320 | |
| 321 | + /** |
|
| 322 | + * @param string $table |
|
| 323 | + */ |
|
| 318 | 324 | public function doReplaceSet($table, $fieldsAndValues) { |
| 319 | 325 | return $this->doSet($table, $fieldsAndValues, true); |
| 320 | 326 | } |
@@ -427,7 +433,7 @@ discard block |
||
| 427 | 433 | * |
| 428 | 434 | * Usually used for mallformed $where conditions |
| 429 | 435 | * |
| 430 | - * @param $table |
|
| 436 | + * @param string $table |
|
| 431 | 437 | * @param $where |
| 432 | 438 | * |
| 433 | 439 | * @return array|bool|mysqli_result|null |
@@ -565,6 +571,10 @@ discard block |
||
| 565 | 571 | } |
| 566 | 572 | |
| 567 | 573 | // TODO Заменить это на новый логгер |
| 574 | + |
|
| 575 | + /** |
|
| 576 | + * @param string $query |
|
| 577 | + */ |
|
| 568 | 578 | protected function security_watch_user_queries($query) { |
| 569 | 579 | global $user; |
| 570 | 580 | |
@@ -588,6 +598,9 @@ discard block |
||
| 588 | 598 | } |
| 589 | 599 | |
| 590 | 600 | |
| 601 | + /** |
|
| 602 | + * @param string $query |
|
| 603 | + */ |
|
| 591 | 604 | public function security_query_check_bad_words($query) { |
| 592 | 605 | if ($this->skipQueryCheck) { |
| 593 | 606 | return; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | public function load_db_settings($configFile = '') { |
| 90 | 90 | $dbsettings = array(); |
| 91 | 91 | |
| 92 | - empty($configFile) ? $configFile = SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX : false; |
|
| 92 | + empty($configFile) ? $configFile = SN_ROOT_PHYSICAL."config".DOT_PHP_EX : false; |
|
| 93 | 93 | |
| 94 | 94 | require $configFile; |
| 95 | 95 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | if (empty($this->dbsettings)) { |
| 112 | - $this->load_db_settings(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX); |
|
| 112 | + $this->load_db_settings(SN_ROOT_PHYSICAL."config".DOT_PHP_EX); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // TODO - фатальные (?) ошибки на каждом шагу. Хотя - скорее Эксепшны |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $sql = $query; |
| 162 | 162 | if (strpos($sql, '{{') !== false) { |
| 163 | 163 | foreach ($this->table_list as $tableName) { |
| 164 | - $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql); |
|
| 164 | + $sql = str_replace("{{{$tableName}}}", $this->db_prefix.$tableName, $sql); |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
@@ -234,12 +234,12 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | $queryResult = null; |
| 236 | 236 | try { |
| 237 | - $queryResult = $this->db_sql_query($stringQuery . DbSqlHelper::quoteComment($queryTrace)); |
|
| 237 | + $queryResult = $this->db_sql_query($stringQuery.DbSqlHelper::quoteComment($queryTrace)); |
|
| 238 | 238 | if (!$queryResult) { |
| 239 | 239 | throw new Exception(); |
| 240 | 240 | } |
| 241 | 241 | } catch (Exception $e) { |
| 242 | - classSupernova::$debug->error($this->db_error() . "<br />{$query}<br />", 'SQL Error'); |
|
| 242 | + classSupernova::$debug->error($this->db_error()."<br />{$query}<br />", 'SQL Error'); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | return $queryResult; |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | case TYPE_EMPTY: |
| 463 | 463 | // No-type defaults to string |
| 464 | 464 | default: |
| 465 | - $value = "'" . $this->db_escape((string)$value) . "'"; |
|
| 465 | + $value = "'".$this->db_escape((string) $value)."'"; |
|
| 466 | 466 | break; |
| 467 | 467 | } |
| 468 | 468 | |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | if (is_int($fieldName)) { |
| 491 | 491 | $result[$fieldName] = $fieldValue; |
| 492 | 492 | } else { |
| 493 | - $result[$fieldName] = "`{$fieldName}` = " . $this->castAsDbValue($fieldValue); |
|
| 493 | + $result[$fieldName] = "`{$fieldName}` = ".$this->castAsDbValue($fieldValue); |
|
| 494 | 494 | } |
| 495 | 495 | } |
| 496 | 496 | |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | foreach ($fields as $key => $value) { |
| 524 | - $result[$key] = "`" . $this->db_escape($value) . "`"; |
|
| 524 | + $result[$key] = "`".$this->db_escape($value)."`"; |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | return $result; |
@@ -577,10 +577,10 @@ discard block |
||
| 577 | 577 | $this->isWatching = true; |
| 578 | 578 | $msg = "\$query = \"{$query}\"\n\r"; |
| 579 | 579 | if (!empty($_POST)) { |
| 580 | - $msg .= "\n\r" . dump($_POST, '$_POST'); |
|
| 580 | + $msg .= "\n\r".dump($_POST, '$_POST'); |
|
| 581 | 581 | } |
| 582 | 582 | if (!empty($_GET)) { |
| 583 | - $msg .= "\n\r" . dump($_GET, '$_GET'); |
|
| 583 | + $msg .= "\n\r".dump($_GET, '$_GET'); |
|
| 584 | 584 | } |
| 585 | 585 | classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true)); |
| 586 | 586 | $this->isWatching = false; |
@@ -606,37 +606,37 @@ discard block |
||
| 606 | 606 | case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit: |
| 607 | 607 | case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit: |
| 608 | 608 | case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0: |
| 609 | - $report = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n"; |
|
| 609 | + $report = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n"; |
|
| 610 | 610 | $report .= ">Database Inforamation\n"; |
| 611 | - $report .= "\tID - " . $user['id'] . "\n"; |
|
| 612 | - $report .= "\tUser - " . $user['username'] . "\n"; |
|
| 613 | - $report .= "\tAuth level - " . $user['authlevel'] . "\n"; |
|
| 614 | - $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n"; |
|
| 615 | - $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n"; |
|
| 616 | - $report .= "\tUser IP - " . $user['user_lastip'] . "\n"; |
|
| 617 | - $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n"; |
|
| 618 | - $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
| 619 | - $report .= "\tCurrent Page - " . $user['current_page'] . "\n"; |
|
| 620 | - $report .= "\tRegister Time - " . $user['register_time'] . "\n"; |
|
| 611 | + $report .= "\tID - ".$user['id']."\n"; |
|
| 612 | + $report .= "\tUser - ".$user['username']."\n"; |
|
| 613 | + $report .= "\tAuth level - ".$user['authlevel']."\n"; |
|
| 614 | + $report .= "\tAdmin Notes - ".$user['adminNotes']."\n"; |
|
| 615 | + $report .= "\tCurrent Planet - ".$user['current_planet']."\n"; |
|
| 616 | + $report .= "\tUser IP - ".$user['user_lastip']."\n"; |
|
| 617 | + $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n"; |
|
| 618 | + $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
| 619 | + $report .= "\tCurrent Page - ".$user['current_page']."\n"; |
|
| 620 | + $report .= "\tRegister Time - ".$user['register_time']."\n"; |
|
| 621 | 621 | $report .= "\n"; |
| 622 | 622 | |
| 623 | 623 | $report .= ">Query Information\n"; |
| 624 | - $report .= "\tQuery - " . $query . "\n"; |
|
| 624 | + $report .= "\tQuery - ".$query."\n"; |
|
| 625 | 625 | $report .= "\n"; |
| 626 | 626 | |
| 627 | 627 | $report .= ">\$_SERVER Information\n"; |
| 628 | - $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n"; |
|
| 629 | - $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n"; |
|
| 630 | - $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
| 631 | - $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n"; |
|
| 632 | - $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n"; |
|
| 633 | - $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n"; |
|
| 634 | - $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n"; |
|
| 635 | - $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n"; |
|
| 628 | + $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n"; |
|
| 629 | + $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n"; |
|
| 630 | + $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
| 631 | + $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n"; |
|
| 632 | + $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n"; |
|
| 633 | + $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n"; |
|
| 634 | + $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n"; |
|
| 635 | + $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n"; |
|
| 636 | 636 | |
| 637 | 637 | $report .= "\n--------------------------------------------------------------------------------------------------\n"; |
| 638 | 638 | |
| 639 | - $fp = fopen(SN_ROOT_PHYSICAL . 'badqrys.txt', 'a'); |
|
| 639 | + $fp = fopen(SN_ROOT_PHYSICAL.'badqrys.txt', 'a'); |
|
| 640 | 640 | fwrite($fp, $report); |
| 641 | 641 | fclose($fp); |
| 642 | 642 | |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | * @param $alliance |
| 58 | 58 | * @param $where_add |
| 59 | 59 | * @param $start_row |
| 60 | - * @param $page_limit |
|
| 60 | + * @param integer $page_limit |
|
| 61 | 61 | * |
| 62 | 62 | * @return array|bool|mysqli_result|null |
| 63 | 63 | */ |
@@ -2,6 +2,10 @@ |
||
| 2 | 2 | |
| 3 | 3 | class DBStaticFleetMissile { |
| 4 | 4 | |
| 5 | + /** |
|
| 6 | + * @param double $arrival |
|
| 7 | + * @param integer $target_structure |
|
| 8 | + */ |
|
| 5 | 9 | public static function db_missile_insert($target_coord, $user, $planetrow, $arrival, $fleet_ship_count, $target_structure) { |
| 6 | 10 | classSupernova::$db->doInsert( |
| 7 | 11 | "INSERT INTO `{{iraks}}` SET |
@@ -26,8 +26,8 @@ |
||
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * @param template $template |
| 29 | - * @param $query_where |
|
| 30 | - * @param $query_limit |
|
| 29 | + * @param string $query_where |
|
| 30 | + * @param integer $query_limit |
|
| 31 | 31 | * |
| 32 | 32 | * @return array|bool|mysqli_result|null |
| 33 | 33 | */ |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | use Vector\Vector; |
| 12 | 12 | |
| 13 | -include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
| 13 | +include('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
| 14 | 14 | lng_include('notes'); |
| 15 | 15 | |
| 16 | 16 | global $user; |
@@ -18,15 +18,15 @@ discard block |
||
| 18 | 18 | $template = gettemplate('notes', true); |
| 19 | 19 | |
| 20 | 20 | $result = array(); |
| 21 | -if(($result_message = sys_get_param_str('MESSAGE')) && isset(classLocale::$lang[$result_message])) { |
|
| 21 | +if (($result_message = sys_get_param_str('MESSAGE')) && isset(classLocale::$lang[$result_message])) { |
|
| 22 | 22 | $result[] = array('STATUS' => sys_get_param_int('STATUS'), 'MESSAGE' => classLocale::$lang[$result_message]); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | $note_id_edit = sys_get_param_id('note_id_edit'); |
| 26 | -if(sys_get_param('note_delete')) { |
|
| 26 | +if (sys_get_param('note_delete')) { |
|
| 27 | 27 | try { |
| 28 | 28 | DBStaticNote::processDelete($user, $note_id_edit); |
| 29 | - } catch(Exception $e) { |
|
| 29 | + } catch (Exception $e) { |
|
| 30 | 30 | $note_id_edit = 0; |
| 31 | 31 | sn_db_transaction_rollback(); |
| 32 | 32 | $result[] = array( |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | 'MESSAGE' => classLocale::$lang[$e->getMessage()], |
| 35 | 35 | ); |
| 36 | 36 | } |
| 37 | -} elseif(($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) { |
|
| 37 | +} elseif (($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) { |
|
| 38 | 38 | $note_title == db_escape(classLocale::$lang['note_new_title']) ? $note_title = '' : false; |
| 39 | 39 | ($note_text = sys_get_param_str('note_text')) == db_escape(classLocale::$lang['note_new_text']) ? $note_text = '' : false; |
| 40 | 40 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $note_system = max(0, min(sys_get_param_id('note_system'), Vector::$knownSystems)); |
| 44 | 44 | $note_planet = max(0, min(sys_get_param_id('note_planet'), Vector::$knownPlanets + 1)); |
| 45 | 45 | |
| 46 | - if(!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) { |
|
| 46 | + if (!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) { |
|
| 47 | 47 | throw new exception('note_err_note_empty', ERR_WARNING); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -52,15 +52,15 @@ discard block |
||
| 52 | 52 | $note_sticky = intval(sys_get_param_id('note_sticky')) ? 1 : 0; |
| 53 | 53 | |
| 54 | 54 | sn_db_transaction_start(); |
| 55 | - if($note_id_edit) { |
|
| 55 | + if ($note_id_edit) { |
|
| 56 | 56 | $check_note_id = DBStaticNote::db_note_get_id_and_owner($note_id_edit); |
| 57 | - if(!$check_note_id) { |
|
| 57 | + if (!$check_note_id) { |
|
| 58 | 58 | throw new Exception('note_err_note_not_found', ERR_ERROR); |
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if($note_id_edit) { |
|
| 63 | - if($check_note_id['owner'] != $user['id']) { |
|
| 62 | + if ($note_id_edit) { |
|
| 63 | + if ($check_note_id['owner'] != $user['id']) { |
|
| 64 | 64 | throw new Exception('note_err_owner_wrong', ERR_ERROR); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | sn_db_transaction_commit(); |
| 73 | - sys_redirect('notes.php?STATUS=' . ERR_NONE . '&MESSAGE=' . ($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added')); |
|
| 73 | + sys_redirect('notes.php?STATUS='.ERR_NONE.'&MESSAGE='.($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added')); |
|
| 74 | 74 | // throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE); |
| 75 | - } catch(Exception $e) { |
|
| 75 | + } catch (Exception $e) { |
|
| 76 | 76 | $note_id_edit = 0; |
| 77 | 77 | sn_db_transaction_rollback(); |
| 78 | 78 | $result[] = array( |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | -if(!$note_id_edit) { |
|
| 85 | +if (!$note_id_edit) { |
|
| 86 | 86 | note_assign($template, array( |
| 87 | 87 | 'id' => 0, |
| 88 | 88 | 'time' => SN_TIME_NOW, |
@@ -95,13 +95,13 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | $note_exist = false; |
| 97 | 97 | $notes_query = DBStaticNote::db_note_list_by_owner($user['id']); |
| 98 | -while($note_row = db_fetch($notes_query)) { |
|
| 98 | +while ($note_row = db_fetch($notes_query)) { |
|
| 99 | 99 | note_assign($template, $note_row); |
| 100 | 100 | $note_exist = $note_exist || $note_row['id'] == $note_id_edit; |
| 101 | 101 | } |
| 102 | 102 | $note_id_edit = $note_exist ? $note_id_edit : 0; |
| 103 | 103 | |
| 104 | -foreach($note_priority_classes as $note_priority_id => $note_priority_class) { |
|
| 104 | +foreach ($note_priority_classes as $note_priority_id => $note_priority_class) { |
|
| 105 | 105 | $template->assign_block_vars('note_priority', array( |
| 106 | 106 | 'ID' => $note_priority_id, |
| 107 | 107 | 'CLASS' => $note_priority_classes[$note_priority_id], |
@@ -109,14 +109,14 @@ discard block |
||
| 109 | 109 | )); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | -foreach(classLocale::$lang['sys_planet_type'] as $planet_type_id => $planet_type_string) { |
|
| 112 | +foreach (classLocale::$lang['sys_planet_type'] as $planet_type_id => $planet_type_string) { |
|
| 113 | 113 | $template->assign_block_vars('planet_type', array( |
| 114 | 114 | 'ID' => $planet_type_id, |
| 115 | 115 | 'TEXT' => $planet_type_string, |
| 116 | 116 | )); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | -foreach($result as $result_data) { |
|
| 119 | +foreach ($result as $result_data) { |
|
| 120 | 120 | $template->assign_block_vars('result', $result_data); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | use Vector\Vector; |
| 8 | 8 | |
| 9 | 9 | function sys_user_vacation($user) { |
| 10 | - if(sys_get_param_str('vacation') == 'leave') { |
|
| 10 | + if (sys_get_param_str('vacation') == 'leave') { |
|
| 11 | 11 | if ($user['vacation'] < SN_TIME_NOW) { |
| 12 | 12 | $user['vacation'] = 0; |
| 13 | 13 | $user['vacation_next'] = SN_TIME_NOW + classSupernova::$config->player_vacation_timeout; |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | } |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - if($user['vacation']) { |
|
| 18 | + if ($user['vacation']) { |
|
| 19 | 19 | // sn_sys_logout(false, true); |
| 20 | 20 | // core_auth::logout(false, true); |
| 21 | 21 | |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | // TODO: Full rewrite |
| 46 | 46 | sn_db_transaction_start(); |
| 47 | 47 | $TheUser = DBStaticUser::db_user_by_id($UserID); |
| 48 | - if ( $TheUser['ally_id'] != 0 ) { |
|
| 49 | - $TheAlly = classSupernova::$db->doSelectFetch("SELECT * FROM `{{alliance}}` WHERE `id` = '" . $TheUser['ally_id'] . "';"); |
|
| 48 | + if ($TheUser['ally_id'] != 0) { |
|
| 49 | + $TheAlly = classSupernova::$db->doSelectFetch("SELECT * FROM `{{alliance}}` WHERE `id` = '".$TheUser['ally_id']."';"); |
|
| 50 | 50 | $TheAlly['ally_members'] -= 1; |
| 51 | - if ( $TheAlly['ally_members'] > 0 ) { |
|
| 52 | - classSupernova::$db->doUpdate( "UPDATE `{{alliance}}` SET `ally_members` = '" . $TheAlly['ally_members'] . "' WHERE `id` = '" . $TheAlly['id'] . "';"); |
|
| 51 | + if ($TheAlly['ally_members'] > 0) { |
|
| 52 | + classSupernova::$db->doUpdate("UPDATE `{{alliance}}` SET `ally_members` = '".$TheAlly['ally_members']."' WHERE `id` = '".$TheAlly['id']."';"); |
|
| 53 | 53 | } else { |
| 54 | 54 | classSupernova::$gc->db->doDeleteRowWhere(TABLE_ALLIANCE, array('id' => $TheAlly['id'],)); |
| 55 | 55 | classSupernova::$gc->db->doDeleteWhere(TABLE_STAT_POINTS, array('stat_type' => STAT_TYPE_ALLY, 'id_owner' => $TheAlly['id'],)); |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | classSupernova::$gc->db->doDeleteWhere(TABLE_MESSAGES, array('message_owner' => $UserID,)); |
| 63 | 63 | classSupernova::$gc->db->doDeleteWhere(TABLE_MESSAGES, array('message_sender' => $UserID,)); |
| 64 | - classSupernova::$gc->db->doDeleteWhere(TABLE_NOTES, array('owner' => $UserID ,)); |
|
| 64 | + classSupernova::$gc->db->doDeleteWhere(TABLE_NOTES, array('owner' => $UserID,)); |
|
| 65 | 65 | FleetList::db_fleet_list_delete_by_owner($UserID); |
| 66 | - classSupernova::$gc->db->doDeleteWhere(TABLE_BUDDY, array('BUDDY_SENDER_ID' => $UserID ,)); |
|
| 67 | - classSupernova::$gc->db->doDeleteWhere(TABLE_BUDDY, array('BUDDY_OWNER_ID' => $UserID ,)); |
|
| 66 | + classSupernova::$gc->db->doDeleteWhere(TABLE_BUDDY, array('BUDDY_SENDER_ID' => $UserID,)); |
|
| 67 | + classSupernova::$gc->db->doDeleteWhere(TABLE_BUDDY, array('BUDDY_OWNER_ID' => $UserID,)); |
|
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | classSupernova::$gc->cacheOperator->db_del_record_by_id(LOC_USER, $UserID); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | $ban_current = DBStaticUser::db_user_by_id($banned['id'], false, 'banaday'); |
| 86 | 86 | $ban_until = ($ban_current['banaday'] ? $ban_current['banaday'] : SN_TIME_NOW) + $term; |
| 87 | 87 | |
| 88 | - DBStaticUser::db_user_set_by_id($banned['id'], "`banaday` = {$ban_until} " . ($is_vacation ? ", `vacation` = '{$ban_until}' " : '')); |
|
| 88 | + DBStaticUser::db_user_set_by_id($banned['id'], "`banaday` = {$ban_until} ".($is_vacation ? ", `vacation` = '{$ban_until}' " : '')); |
|
| 89 | 89 | |
| 90 | 90 | $banned['username'] = db_escape($banned['username']); |
| 91 | 91 | $banner['username'] = db_escape($banner['username']); |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * @param string $reason |
| 104 | 104 | */ |
| 105 | 105 | function sys_admin_player_ban_unset($banner, $banned, $reason = '') { |
| 106 | - DBStaticUser::db_user_set_by_id($banned['id'], "`banaday` = 0, `vacation` = " . SN_TIME_NOW . ""); |
|
| 106 | + DBStaticUser::db_user_set_by_id($banned['id'], "`banaday` = 0, `vacation` = ".SN_TIME_NOW.""); |
|
| 107 | 107 | |
| 108 | 108 | $banned['username'] = db_escape($banned['username']); |
| 109 | 109 | $banner['username'] = db_escape($banner['username']); |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | 'total_points' => $options['total_points'] = empty($options['total_points']) ? 0 : $options['total_points'], |
| 134 | 134 | |
| 135 | - 'options' => (empty($options['options']) ? $player_options_string : $options['options']) . (empty($options['options_extra']) ? '' : $options['options_extra']), |
|
| 135 | + 'options' => (empty($options['options']) ? $player_options_string : $options['options']).(empty($options['options_extra']) ? '' : $options['options_extra']), |
|
| 136 | 136 | |
| 137 | 137 | 'galaxy' => $options['galaxy'] = intval($options['galaxy'] ? $options['galaxy'] : 0), |
| 138 | 138 | 'system' => $options['system'] = intval($options['system'] ? $options['system'] : 0), |
@@ -143,28 +143,28 @@ discard block |
||
| 143 | 143 | !empty($options['password_encoded_unsafe']) ? $field_set['password'] = $options['password_encoded_unsafe'] : false; |
| 144 | 144 | |
| 145 | 145 | $user_new = classSupernova::$gc->cacheOperator->db_ins_field_set(LOC_USER, $field_set); |
| 146 | - if(!($options['galaxy'] && $options['system'] && $options['planet'])) { |
|
| 146 | + if (!($options['galaxy'] && $options['system'] && $options['planet'])) { |
|
| 147 | 147 | $options['galaxy'] = classSupernova::$config->LastSettedGalaxyPos; |
| 148 | 148 | $options['system'] = classSupernova::$config->LastSettedSystemPos; |
| 149 | - $segment_size = floor(Vector::$knownPlanets/ 3); |
|
| 149 | + $segment_size = floor(Vector::$knownPlanets / 3); |
|
| 150 | 150 | $segment = floor(classSupernova::$config->LastSettedPlanetPos / $segment_size); |
| 151 | 151 | $segment++; |
| 152 | 152 | $options['planet'] = mt_rand(1 + $segment * $segment_size, ($segment + 1) * $segment_size); |
| 153 | 153 | |
| 154 | 154 | // $new_planet_id = 0; |
| 155 | - while(true) { |
|
| 156 | - if($options['planet'] > Vector::$knownPlanets) { |
|
| 155 | + while (true) { |
|
| 156 | + if ($options['planet'] > Vector::$knownPlanets) { |
|
| 157 | 157 | $options['planet'] = mt_rand(0, $segment_size - 1) + 1; |
| 158 | 158 | $options['system']++; |
| 159 | 159 | } |
| 160 | - if($options['system'] > Vector::$knownSystems) { |
|
| 160 | + if ($options['system'] > Vector::$knownSystems) { |
|
| 161 | 161 | $options['system'] = 1; |
| 162 | 162 | $options['galaxy']++; |
| 163 | 163 | } |
| 164 | - $options['galaxy'] > Vector::$knownGalaxies? $options['galaxy'] = 1 : false; |
|
| 164 | + $options['galaxy'] > Vector::$knownGalaxies ? $options['galaxy'] = 1 : false; |
|
| 165 | 165 | |
| 166 | 166 | $galaxy_row = DBStaticPlanet::db_planet_by_gspt($options['galaxy'], $options['system'], $options['planet'], PT_PLANET, true, 'id'); |
| 167 | - if(!$galaxy_row['id']) { |
|
| 167 | + if (!$galaxy_row['id']) { |
|
| 168 | 168 | classSupernova::$config->db_saveItem(array( |
| 169 | 169 | 'LastSettedGalaxyPos' => $options['galaxy'], |
| 170 | 170 | 'LastSettedSystemPos' => $options['system'], |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | db_player_name_history_replace($user_new['id'], $username_unsafe); |
| 188 | 188 | |
| 189 | - if(!empty($options['partner_id']) && ($referral_row = DBStaticUser::db_user_by_id($options['partner_id'], true))) { |
|
| 189 | + if (!empty($options['partner_id']) && ($referral_row = DBStaticUser::db_user_by_id($options['partner_id'], true))) { |
|
| 190 | 190 | db_referral_insert($options, $user_new); |
| 191 | 191 | } |
| 192 | 192 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $owners = array(); |
| 115 | 115 | } else { |
| 116 | 116 | $insert_values = array(); |
| 117 | - $insert_template = "('%u'," . str_replace('%', '%%', " '{$sender}', '{$timestamp}', '{$message_type}', '{$from}', '{$subject}', '{$text}')"); |
|
| 117 | + $insert_template = "('%u',".str_replace('%', '%%', " '{$sender}', '{$timestamp}', '{$message_type}', '{$from}', '{$subject}', '{$text}')"); |
|
| 118 | 118 | |
| 119 | 119 | foreach ($owners as $owner) { |
| 120 | 120 | if ($user['id'] != $owner) { |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | $sendList = array(); |
| 156 | 156 | $list = ''; |
| 157 | 157 | $query = DBStaticUser::db_user_list( |
| 158 | - "ally_id = '{$ally_id}'" . ($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''), |
|
| 158 | + "ally_id = '{$ally_id}'".($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''), |
|
| 159 | 159 | false, 'id, username'); |
| 160 | 160 | foreach ($query as $u) { |
| 161 | 161 | $sendList[] = $u['id']; |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | $subject_unsafe = substr($subject_unsafe, strlen(classLocale::$lang['msg_answer_prefix'])); |
| 254 | 254 | $re++; |
| 255 | 255 | } |
| 256 | - $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'] . $subject_unsafe : false; |
|
| 256 | + $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'].$subject_unsafe : false; |
|
| 257 | 257 | |
| 258 | 258 | $subject_unsafe = $subject_unsafe ? $subject_unsafe : classLocale::$lang['msg_subject_default']; |
| 259 | 259 | |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | return classSupernova::$db->doSelect( |
| 422 | 422 | "SELECT * FROM {{messages}} |
| 423 | 423 | WHERE |
| 424 | - `message_type` = '" . MSG_TYPE_PLAYER . "' AND |
|
| 424 | + `message_type` = '" . MSG_TYPE_PLAYER."' AND |
|
| 425 | 425 | ((`message_owner` = '{$user['id']}' AND `message_sender` = '{$recipient_id}') |
| 426 | 426 | OR |
| 427 | 427 | (`message_sender` = '{$user['id']}' AND `message_owner` = '{$recipient_id}')) ORDER BY `message_time` DESC LIMIT 20;"); |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | FROM |
| 466 | 466 | {{messages}} AS m |
| 467 | 467 | LEFT JOIN {{users}} AS u ON u.id = m.message_owner " . |
| 468 | - ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : '') . |
|
| 468 | + ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : ''). |
|
| 469 | 469 | "ORDER BY |
| 470 | 470 | `message_id` DESC |
| 471 | 471 | LIMIT |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | public static function db_message_insert_all($message_type, $from, $subject, $text) { |
| 476 | - return classSupernova::$db->doInsert('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' . |
|
| 476 | + return classSupernova::$db->doInsert('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) '. |
|
| 477 | 477 | "SELECT `id`, 0, unix_timestamp(now()), {$message_type}, '{$from}', '{$subject}', '{$text}' FROM {{users}}"); |
| 478 | 478 | } |
| 479 | 479 | |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | * @return array|bool|mysqli_result|null |
| 484 | 484 | */ |
| 485 | 485 | public static function db_message_count_by_type($int_type_selected) { |
| 486 | - $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM `{{messages}}`' . ($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : '')); |
|
| 486 | + $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM `{{messages}}`'.($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : '')); |
|
| 487 | 487 | |
| 488 | 488 | return $page_max; |
| 489 | 489 | } |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | */ |
| 508 | 508 | public static function db_message_list_delete_by_date($delete_date, $int_type_selected) { |
| 509 | 509 | $where[] = "message_time <= UNIX_TIMESTAMP('{$delete_date}')"; |
| 510 | - if($int_type_selected >= 0) { |
|
| 510 | + if ($int_type_selected >= 0) { |
|
| 511 | 511 | $where['message_type'] = $int_type_selected; |
| 512 | 512 | } |
| 513 | 513 | classSupernova::$db->doDeleteDeprecated(TABLE_MESSAGES, $where); |
@@ -517,8 +517,8 @@ discard block |
||
| 517 | 517 | * @param $insert_values |
| 518 | 518 | */ |
| 519 | 519 | public static function db_message_insert($insert_values) { |
| 520 | - classSupernova::$db->doInsert('INSERT INTO `{{messages}}` (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' . |
|
| 521 | - 'VALUES ' . implode(',', $insert_values)); |
|
| 520 | + classSupernova::$db->doInsert('INSERT INTO `{{messages}}` (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) '. |
|
| 521 | + 'VALUES '.implode(',', $insert_values)); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | } |