@@ -4,6 +4,6 @@ |
||
4 | 4 | |
5 | 5 | // header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); |
6 | 6 | // @header("{$serverProtocol} 200 OK"); |
7 | -echo "File {$redirectFrom} not found on server. Contact administration if you think that this is error"; |
|
7 | +echo "file {$redirectFrom} not found on server. Contact administration if you think that this is error"; |
|
8 | 8 | die(); |
9 | 9 | ?> */ |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $this->db_saveItem(array_combine(array_keys($this->defaults), array_fill(0, count($this->defaults), null))); |
92 | 92 | } |
93 | 93 | |
94 | - public function db_saveItem($item_list, $value = NULL) { |
|
94 | + public function db_saveItem($item_list, $value = null) { |
|
95 | 95 | if(empty($item_list)) { |
96 | 96 | return; |
97 | 97 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $qry = array(); |
103 | 103 | foreach($item_list as $item_name => $item_value) { |
104 | 104 | if($item_name) { |
105 | - $item_value = db_escape($item_value === NULL ? $this->$item_name : $item_value); |
|
105 | + $item_value = db_escape($item_value === null ? $this->$item_name : $item_value); |
|
106 | 106 | $item_name = db_escape($item_name); |
107 | 107 | $qry[] = "('{$item_name}', '{$item_value}')"; |
108 | 108 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $this->sql_index_field = "{$table_name}_name"; |
41 | 41 | $this->sql_value_field = "{$table_name}_value"; |
42 | 42 | |
43 | - if(!$this->_DB_LOADED) { |
|
43 | + if (!$this->_DB_LOADED) { |
|
44 | 44 | $this->db_loadAll(); |
45 | 45 | } |
46 | 46 | } |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function db_loadItem($index) { |
62 | 62 | $result = null; |
63 | - if($index) { |
|
63 | + if ($index) { |
|
64 | 64 | $index_safe = db_escape($index); |
65 | 65 | $queryResult = doquery("SELECT `{$this->sql_value_field}` FROM `{{{$this->table_name}}}` WHERE `{$this->sql_index_field}` = '{$index_safe}' FOR UPDATE", true); |
66 | - if(is_array($queryResult) && !empty($queryResult)) { |
|
66 | + if (is_array($queryResult) && !empty($queryResult)) { |
|
67 | 67 | $this->$index = $result = $queryResult[$this->sql_value_field]; |
68 | 68 | } |
69 | 69 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $this->loadDefaults(); |
76 | 76 | |
77 | 77 | $query = doquery("SELECT * FROM {{{$this->table_name}}} FOR UPDATE;"); |
78 | - while($row = db_fetch($query)) { |
|
78 | + while ($row = db_fetch($query)) { |
|
79 | 79 | $this[$row[$this->sql_index_field]] = $row[$this->sql_value_field]; |
80 | 80 | } |
81 | 81 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | public function loadDefaults() { |
86 | - foreach($this->defaults as $defName => $defValue) { |
|
86 | + foreach ($this->defaults as $defName => $defValue) { |
|
87 | 87 | $this->$defName = $defValue; |
88 | 88 | } |
89 | 89 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | public function db_saveItem($item_list, $value = NULL) { |
96 | - if(empty($item_list)) { |
|
96 | + if (empty($item_list)) { |
|
97 | 97 | return; |
98 | 98 | } |
99 | 99 | |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | |
102 | 102 | // Сначала записываем данные в базу - что бы поймать все блокировки |
103 | 103 | $qry = array(); |
104 | - foreach($item_list as $item_name => $item_value) { |
|
105 | - if($item_name) { |
|
104 | + foreach ($item_list as $item_name => $item_value) { |
|
105 | + if ($item_name) { |
|
106 | 106 | $item_value = db_escape($item_value === NULL ? $this->$item_name : $item_value); |
107 | 107 | $item_name = db_escape($item_name); |
108 | 108 | $qry[] = "('{$item_name}', '{$item_value}')"; |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | doquery("REPLACE INTO `{{" . $this->table_name . "}}` (`{$this->sql_index_field}`, `{$this->sql_value_field}`) VALUES " . implode(',', $qry) . ";"); |
112 | 112 | |
113 | 113 | // И только после взятия блокировок - меняем значения в кэше |
114 | - foreach($item_list as $item_name => $item_value) { |
|
115 | - if($item_name && $item_value !== null) { |
|
114 | + foreach ($item_list as $item_name => $item_value) { |
|
115 | + if ($item_name && $item_value !== null) { |
|
116 | 116 | $this->__set($item_name, $item_value); |
117 | 117 | } |
118 | 118 | } |
@@ -140,14 +140,14 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | public function __get($name) { |
143 | - if($this->force) { |
|
143 | + if ($this->force) { |
|
144 | 144 | $this->force = false; |
145 | 145 | $value = $this->db_loadItem($name); |
146 | 146 | } else { |
147 | 147 | $value = parent::__get($name); |
148 | 148 | } |
149 | 149 | |
150 | - if(isset($this->notEmptyFields[$name]) && empty($value) && isset($this->defaults[$name])) { |
|
150 | + if (isset($this->notEmptyFields[$name]) && empty($value) && isset($this->defaults[$name])) { |
|
151 | 151 | $value = $this->defaults[$name]; |
152 | 152 | } |
153 | 153 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | public function __set($name, $value) { |
158 | - if($this->force) { |
|
158 | + if ($this->force) { |
|
159 | 159 | $this->force = false; |
160 | 160 | $this->db_saveItem($name, $value); |
161 | 161 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | * @return mixed |
14 | 14 | * @deprecated |
15 | 15 | */ |
16 | -function RestoreFleetToPlanet(&$fleet_row, $start = true, $only_resources = false, $safe_fleet = false){return sn_function_call('RestoreFleetToPlanet', array(&$fleet_row, $start, $only_resources, $safe_fleet, &$result));} |
|
16 | +function RestoreFleetToPlanet(&$fleet_row, $start = true, $only_resources = false, $safe_fleet = false) {return sn_function_call('RestoreFleetToPlanet', array(&$fleet_row, $start, $only_resources, $safe_fleet, &$result)); } |
|
17 | 17 | /** |
18 | 18 | * @param array $fleet_row |
19 | 19 | * @param bool $start |
@@ -29,7 +29,7 @@ |
||
29 | 29 | */ |
30 | 30 | protected $_repository; |
31 | 31 | |
32 | - /** |
|
32 | + /** |
|
33 | 33 | * @var ContainerPlus $_oldRepo |
34 | 34 | */ |
35 | 35 | protected $_oldRepo; |
@@ -86,7 +86,7 @@ |
||
86 | 86 | |
87 | 87 | public function get($entityClass, $id) { |
88 | 88 | $entityIndex = get_class($entityClass) . '\\' . $id; |
89 | - if(!isset($this->_repository[$entityIndex])) { |
|
89 | + if (!isset($this->_repository[$entityIndex])) { |
|
90 | 90 | |
91 | 91 | } |
92 | 92 |
@@ -11,7 +11,7 @@ |
||
11 | 11 | class SnBootstrap { |
12 | 12 | |
13 | 13 | public static function install_benchmark() { |
14 | - register_shutdown_function(function () { |
|
14 | + register_shutdown_function(function() { |
|
15 | 15 | if (defined('IN_AJAX')) { |
16 | 16 | return; |
17 | 17 | } |
@@ -58,7 +58,7 @@ |
||
58 | 58 | $config->pass()->game_disable = GAME_DISABLE_STAT; |
59 | 59 | |
60 | 60 | $statMinimalInterval = intval($config->pass()->stats_minimal_interval); |
61 | - $config->pass()->var_stat_update_end= date(FMT_DATE_TIME_SQL, SN_TIME_NOW + ($statMinimalInterval ? $statMinimalInterval : STATS_RUN_INTERVAL_MINIMUM)); |
|
61 | + $config->pass()->var_stat_update_end = date(FMT_DATE_TIME_SQL, SN_TIME_NOW + ($statMinimalInterval ? $statMinimalInterval : STATS_RUN_INTERVAL_MINIMUM)); |
|
62 | 62 | $config->pass()->var_stat_update_msg = 'Update started'; |
63 | 63 | sn_db_transaction_commit(); |
64 | 64 |
@@ -22,11 +22,11 @@ |
||
22 | 22 | |
23 | 23 | define('IN_AJAX', true); |
24 | 24 | |
25 | -if(($result = StatUpdateLauncher::scheduler_process()) && !defined('IN_ADMIN')) { |
|
25 | +if (($result = StatUpdateLauncher::scheduler_process()) && !defined('IN_ADMIN')) { |
|
26 | 26 | $result = htmlspecialchars($result, ENT_QUOTES, 'UTF-8'); |
27 | 27 | print(json_encode($result)); |
28 | 28 | } |
29 | 29 | |
30 | -if(!defined('IN_ADMIN')) { |
|
30 | +if (!defined('IN_ADMIN')) { |
|
31 | 31 | die(); |
32 | 32 | } |
@@ -75,11 +75,11 @@ |
||
75 | 75 | * @return float[] - [int resourceId] -> [float ratesNormalizedToResourceCost] |
76 | 76 | */ |
77 | 77 | public function getResourceExchangeIn($resourceId) { |
78 | - if(empty($this->resourceExchangeRates[$resourceId])) { |
|
78 | + if (empty($this->resourceExchangeRates[$resourceId])) { |
|
79 | 79 | $defaultRates = $this->getResourcesExchange(); |
80 | 80 | |
81 | 81 | $this->resourceExchangeRates[$resourceId] = []; |
82 | - foreach($defaultRates as $defaultResourceId => $defaultRate) { |
|
82 | + foreach ($defaultRates as $defaultResourceId => $defaultRate) { |
|
83 | 83 | $this->resourceExchangeRates[$resourceId][$defaultResourceId] = $defaultRate / $defaultRates[$resourceId]; |
84 | 84 | } |
85 | 85 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list){return sn_function_call('admin_planet_edit_mode', array(&$template, &$admin_planet_edit_mode_list));} |
|
3 | +function admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list) {return sn_function_call('admin_planet_edit_mode', array(&$template, &$admin_planet_edit_mode_list)); } |
|
4 | 4 | function sn_admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list) |
5 | 5 | { |
6 | 6 | global $lang; |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | return $mode; |
20 | 20 | } |
21 | 21 | |
22 | -function admin_planet_edit_template(&$template, $edit_planet_row, $mode){return sn_function_call('admin_planet_edit_template', array(&$template, $edit_planet_row, $mode));} |
|
22 | +function admin_planet_edit_template(&$template, $edit_planet_row, $mode) {return sn_function_call('admin_planet_edit_template', array(&$template, $edit_planet_row, $mode)); } |
|
23 | 23 | /** |
24 | 24 | * @param template $template |
25 | 25 | * @param $edit_planet_row |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | global $lang; |
31 | 31 | |
32 | 32 | $unit_list = sn_get_groups($mode); |
33 | - if(empty($unit_list)) |
|
33 | + if (empty($unit_list)) |
|
34 | 34 | { |
35 | 35 | return; |
36 | 36 | } |
37 | 37 | $name_list = $lang['tech']; |
38 | 38 | |
39 | - foreach($unit_list as $unit_id) |
|
39 | + foreach ($unit_list as $unit_id) |
|
40 | 40 | { |
41 | 41 | $template->assign_block_vars('unit', array( |
42 | 42 | 'ID' => $unit_id, |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | -function admin_planet_edit_query_string($unit_id, $unit_amount, $mode){return sn_function_call('admin_planet_edit_query_string', array($unit_id, $unit_amount, $mode));} |
|
50 | +function admin_planet_edit_query_string($unit_id, $unit_amount, $mode) {return sn_function_call('admin_planet_edit_query_string', array($unit_id, $unit_amount, $mode)); } |
|
51 | 51 | function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode) |
52 | 52 | { |
53 | - if($unit_amount && in_array($unit_id, sn_get_groups($mode))) |
|
53 | + if ($unit_amount && in_array($unit_id, sn_get_groups($mode))) |
|
54 | 54 | { |
55 | 55 | $unit_amount = round($unit_amount); |
56 | 56 | $unit_name = get_unit_param($unit_id, P_NAME); |
@@ -1,8 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list){return sn_function_call('admin_planet_edit_mode', array(&$template, &$admin_planet_edit_mode_list));} |
4 | -function sn_admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list) |
|
5 | -{ |
|
4 | +function sn_admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list) { |
|
6 | 5 | global $lang; |
7 | 6 | |
8 | 7 | $admin_planet_edit_mode_list = array_merge(isset($admin_planet_edit_mode_list) ? $admin_planet_edit_mode_list : array(), array( |
@@ -25,8 +24,7 @@ discard block |
||
25 | 24 | * @param $edit_planet_row |
26 | 25 | * @param $mode |
27 | 26 | */ |
28 | -function sn_admin_planet_edit_template(&$template, $edit_planet_row, $mode) |
|
29 | -{ |
|
27 | +function sn_admin_planet_edit_template(&$template, $edit_planet_row, $mode) { |
|
30 | 28 | global $lang; |
31 | 29 | |
32 | 30 | $unit_list = sn_get_groups($mode); |
@@ -48,15 +46,13 @@ discard block |
||
48 | 46 | } |
49 | 47 | |
50 | 48 | function admin_planet_edit_query_string($unit_id, $unit_amount, $mode){return sn_function_call('admin_planet_edit_query_string', array($unit_id, $unit_amount, $mode));} |
51 | -function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode) |
|
52 | -{ |
|
49 | +function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode) { |
|
53 | 50 | if($unit_amount && in_array($unit_id, sn_get_groups($mode))) |
54 | 51 | { |
55 | 52 | $unit_amount = round($unit_amount); |
56 | 53 | $unit_name = get_unit_param($unit_id, P_NAME); |
57 | 54 | $result = "{$unit_name} = GREATEST(0, {$unit_name} + ({$unit_amount}))"; |
58 | - } |
|
59 | - else |
|
55 | + } else |
|
60 | 56 | { |
61 | 57 | $result = ''; |
62 | 58 | } |