@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -define('INSIDE' , true); |
|
4 | -define('INSTALL' , false); |
|
3 | +define('INSIDE', true); |
|
4 | +define('INSTALL', false); |
|
5 | 5 | define('IN_ADMIN', true); |
6 | 6 | |
7 | 7 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | SnTemplate::messageBoxAdminAccessDenied(AUTH_LEVEL_ADMINISTRATOR); |
12 | 12 | |
13 | 13 | $planet_active = sys_get_param_int('planet_active'); |
14 | -if(!$planet_active) { |
|
14 | +if (!$planet_active) { |
|
15 | 15 | $planet_type = sys_get_param_int('planet_type', 1); |
16 | 16 | $planet_type = $planet_type == 3 ? 3 : 1; |
17 | 17 | } else { |
@@ -40,8 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | $page_title = |
42 | 42 | $lang['adm_planet_list_title'] . ': ' . |
43 | - ($planet_active ? $lang['adm_planet_active'] : |
|
44 | - ($planet_type ? ($planet_type == 3 ? $lang['sys_moons'] : $lang['sys_planets']) : '') |
|
43 | + ($planet_active ? $lang['adm_planet_active'] : ($planet_type ? ($planet_type == 3 ? $lang['sys_moons'] : $lang['sys_planets']) : '') |
|
45 | 44 | ); |
46 | 45 | $template->assign_vars(array( |
47 | 46 | 'PAGE_TITLE' => $page_title, |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | include_once('common.' . substr(strrchr(__FILE__, '.'), 1)); |
4 | 4 | |
5 | -if(SN::$gc->modules->countModulesInGroup('payment') && !SN_GOOGLE) { |
|
5 | +if (SN::$gc->modules->countModulesInGroup('payment') && !SN_GOOGLE) { |
|
6 | 6 | sys_redirect('metamatter.php'); |
7 | 7 | } |
8 | 8 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @return DbMysqliResultIterator|EmptyCountableIterator |
19 | 19 | */ |
20 | 20 | public static function dbFleetsOnHoldOnPlanetsByIds($planetIds, $time = SN_TIME_NOW) { |
21 | - if(empty($planetIds) || !is_array($planetIds)) { |
|
21 | + if (empty($planetIds) || !is_array($planetIds)) { |
|
22 | 22 | return new EmptyCountableIterator(); |
23 | 23 | } |
24 | 24 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $speeds = array(); |
42 | 42 | if (!empty($fleet)) { |
43 | 43 | foreach ($fleet as $ship_id => $amount) { |
44 | - if ($amount && in_array($ship_id, sn_get_groups(['fleet', 'missile',]))) { |
|
44 | + if ($amount && in_array($ship_id, sn_get_groups(['fleet', 'missile', ]))) { |
|
45 | 45 | $single_ship_data = !empty($shipData[$ship_id]) ? $shipData[$ship_id] : get_ship_data($ship_id, $user); |
46 | 46 | $speeds[] = $single_ship_data['speed']; |
47 | 47 | } |
@@ -122,15 +122,15 @@ |
||
122 | 122 | SN::db_transaction_commit(); |
123 | 123 | |
124 | 124 | $this->user_agent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
125 | - $this->browser_id = db_get_set_unique_id_value('security_browser', 'browser_id', ['browser_user_agent' => $this->user_agent,]); |
|
125 | + $this->browser_id = db_get_set_unique_id_value('security_browser', 'browser_id', ['browser_user_agent' => $this->user_agent, ]); |
|
126 | 126 | |
127 | 127 | $this->page_address = substr($_SERVER['PHP_SELF'], strlen(SN_ROOT_RELATIVE)); |
128 | - $this->page_address_id = db_get_set_unique_id_value('security_url', 'url_id', ['url_string' => $this->page_address,]); |
|
128 | + $this->page_address_id = db_get_set_unique_id_value('security_url', 'url_id', ['url_string' => $this->page_address, ]); |
|
129 | 129 | |
130 | 130 | // Not a simulator - because it can have loooooong string |
131 | 131 | if (strpos($_SERVER['REQUEST_URI'], '/simulator.php') !== 0 && !$skip_log_query) { |
132 | 132 | $this->queryString = !empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''; |
133 | - $this->queryStringId = db_get_set_unique_id_value('security_query_strings', 'id', ['query_string' => $this->queryString,]); |
|
133 | + $this->queryStringId = db_get_set_unique_id_value('security_query_strings', 'id', ['query_string' => $this->queryString, ]); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | $ip = sec_player_ip(); |
@@ -136,7 +136,7 @@ |
||
136 | 136 | // var_dump($fallBackPath); |
137 | 137 | // var_dump($template); |
138 | 138 | |
139 | - if(empty($fallBackPath)) { |
|
139 | + if (empty($fallBackPath)) { |
|
140 | 140 | if (!$this->parent || empty($fallbackName = $this->parent->getName()) || !$this->isTemplateExists()) { |
141 | 141 | // If no parent template - then using default template as fallback one |
142 | 142 | $fallbackName = SnTemplate::SN_TEMPLATE_NAME_DEFAULT; |
@@ -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 = SN::$db->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 = SN::$db->db_escape($item_value === NULL ? $this->$item_name : $item_value); |
107 | 107 | $item_name = SN::$db->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 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $this->db_saveItem(array_combine(array_keys($this->defaults), array_fill(0, count($this->defaults), null))); |
93 | 93 | } |
94 | 94 | |
95 | - public function db_saveItem($item_list, $value = NULL) { |
|
95 | + public function db_saveItem($item_list, $value = null) { |
|
96 | 96 | if(empty($item_list)) { |
97 | 97 | return; |
98 | 98 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $qry = array(); |
104 | 104 | foreach($item_list as $item_name => $item_value) { |
105 | 105 | if($item_name) { |
106 | - $item_value = SN::$db->db_escape($item_value === NULL ? $this->$item_name : $item_value); |
|
106 | + $item_value = SN::$db->db_escape($item_value === null ? $this->$item_name : $item_value); |
|
107 | 107 | $item_name = SN::$db->db_escape($item_name); |
108 | 108 | $qry[] = "('{$item_name}', '{$item_value}')"; |
109 | 109 | } |
@@ -142,9 +142,7 @@ |
||
142 | 142 | // Простое условие - $field_id = $field_value |
143 | 143 | if (is_string($field_id)) { |
144 | 144 | $field_value = |
145 | - $field_value === null ? 'NULL' : |
|
146 | - (is_string($field_value) ? "'" . SN::$db->db_escape($field_value) . "'" : |
|
147 | - (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
145 | + $field_value === null ? 'NULL' : (is_string($field_value) ? "'" . SN::$db->db_escape($field_value) . "'" : (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
148 | 146 | $the_conditions[] = "`{$field_id}` = {$field_value}"; |
149 | 147 | } else { |
150 | 148 | die('Неподдерживаемый тип условия'); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | |
225 | 225 | set_error_handler([$this, 'handlerQueryWarning']); |
226 | 226 | $sqlquery = $this->db_sql_query($sql); |
227 | - if(!$sqlquery) { |
|
227 | + if (!$sqlquery) { |
|
228 | 228 | $debug->error(SN::$db->db_error() . "<br />$sql<br />", 'SQL Error'); |
229 | 229 | } |
230 | 230 | restore_error_handler(); |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | $q1 = $this->db_sql_query("SHOW INDEX FROM {$prefixedTableName_safe};"); |
397 | 397 | while ($r1 = db_fetch($q1)) { |
398 | 398 | $indexName = $r1['Key_name']; |
399 | - if(empty($result[$indexName])) { |
|
399 | + if (empty($result[$indexName])) { |
|
400 | 400 | $result[$indexName] = new DbIndexDescription(); |
401 | 401 | } |
402 | 402 | $result[$indexName]->addField($r1); |
@@ -56,7 +56,7 @@ |
||
56 | 56 | $config->pass()->game_disable = GAME_DISABLE_STAT; |
57 | 57 | |
58 | 58 | $statMinimalInterval = intval($config->pass()->stats_minimal_interval); |
59 | - $config->pass()->var_stat_update_end= date(FMT_DATE_TIME_SQL, SN_TIME_NOW + ($statMinimalInterval ? $statMinimalInterval : STATS_RUN_INTERVAL_MINIMUM)); |
|
59 | + $config->pass()->var_stat_update_end = date(FMT_DATE_TIME_SQL, SN_TIME_NOW + ($statMinimalInterval ? $statMinimalInterval : STATS_RUN_INTERVAL_MINIMUM)); |
|
60 | 60 | $config->pass()->var_stat_update_msg = 'Update started'; |
61 | 61 | SN::db_transaction_commit(); |
62 | 62 |