@@ -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 | 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, |
@@ -18,26 +18,26 @@ discard block |
||
18 | 18 | |
19 | 19 | messageBoxAdminAccessDenied(AUTH_LEVEL_ADMINISTRATOR); |
20 | 20 | |
21 | -if($delete = sys_get_param_id('delete')) |
|
21 | +if ($delete = sys_get_param_id('delete')) |
|
22 | 22 | { |
23 | 23 | doquery("DELETE FROM `{{logs}}` WHERE `log_id` = {$delete} LIMIT 1;"); |
24 | 24 | } |
25 | -elseif(sys_get_param_str('delete_update_info')) |
|
25 | +elseif (sys_get_param_str('delete_update_info')) |
|
26 | 26 | { |
27 | 27 | doquery("DELETE FROM `{{logs}}` WHERE `log_code` in (103, 180, 191);"); |
28 | 28 | } |
29 | -elseif(sys_get_param_str('deleteall') == 'yes') |
|
29 | +elseif (sys_get_param_str('deleteall') == 'yes') |
|
30 | 30 | { |
31 | 31 | // doquery("TRUNCATE TABLE `{{logs}}`"); |
32 | 32 | } |
33 | 33 | |
34 | -if($detail = sys_get_param_id('detail')) |
|
34 | +if ($detail = sys_get_param_id('detail')) |
|
35 | 35 | { |
36 | 36 | $template = gettemplate('admin/adm_log_main_detail', true); |
37 | 37 | |
38 | 38 | $errorInfo = doquery("SELECT * FROM `{{logs}}` WHERE `log_id` = {$detail} LIMIT 1;", true); |
39 | 39 | $error_dump = unserialize($errorInfo['log_dump']); |
40 | - if(is_array($error_dump)) |
|
40 | + if (is_array($error_dump)) |
|
41 | 41 | { |
42 | 42 | foreach ($error_dump as $key => $value) |
43 | 43 | { |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | |
58 | 58 | $i = 0; |
59 | 59 | $query = doquery("SELECT * FROM `{{logs}}` ORDER BY log_id DESC LIMIT 100;"); |
60 | - while($u = db_fetch($query)) |
|
60 | + while ($u = db_fetch($query)) |
|
61 | 61 | { |
62 | 62 | $i++; |
63 | 63 | $v = array(); |
64 | - foreach($u as $key => $value) |
|
64 | + foreach ($u as $key => $value) |
|
65 | 65 | { |
66 | 66 | $v[strtoupper($key)] = $value; |
67 | 67 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | $configValue = $forceLoad ? $this->config->db_loadItem($configName) : $this->config[$configName]; |
36 | 36 | $configType == WATCHDOG_TIME_SQL ? $configValue = strtotime($configValue, SN_TIME_NOW) : false; |
37 | 37 | |
38 | - if(SN_TIME_NOW - $configValue > $timeDiff) { |
|
38 | + if (SN_TIME_NOW - $configValue > $timeDiff) { |
|
39 | 39 | $callable(); |
40 | 40 | } |
41 | 41 |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | global $lang, $debug; |
4 | 4 | |
5 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
5 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
6 | 6 | { |
7 | 7 | $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
8 | 8 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | if ($new_rank_name = sys_get_param_str('newRankName')) |
17 | 17 | { |
18 | - foreach($ally_rights as $fieldName) |
|
18 | + foreach ($ally_rights as $fieldName) |
|
19 | 19 | { |
20 | 20 | $newRank[$fieldName] = 0; |
21 | 21 | } |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | { |
29 | 29 | unset($ranks); |
30 | 30 | |
31 | - foreach($rankListInput as $rankID => $rank) |
|
31 | + foreach ($rankListInput as $rankID => $rank) |
|
32 | 32 | { |
33 | - foreach($ally_rights as $rightName) |
|
33 | + foreach ($ally_rights as $rightName) |
|
34 | 34 | { |
35 | 35 | $ranks[$rankID][$rightName] = $rank[$rightName] ? 1 : 0; |
36 | 36 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $d = sys_get_param_int('d'); |
42 | 42 | if ($d && isset($ranks[$d])) |
43 | 43 | { |
44 | - if(count($ranks) == 1) |
|
44 | + if (count($ranks) == 1) |
|
45 | 45 | { |
46 | 46 | messageBox($lang['ali_adm_lastRank'], $lang['ali_adm_rights_title']); |
47 | 47 | } |
@@ -53,16 +53,16 @@ discard block |
||
53 | 53 | |
54 | 54 | if (count($ranks)) |
55 | 55 | { |
56 | - foreach($ranks as $rankID => $rank) |
|
56 | + foreach ($ranks as $rankID => $rank) |
|
57 | 57 | { |
58 | 58 | $rank_data = array( |
59 | 59 | 'ID' => $rankID, |
60 | 60 | 'NAME' => $rank['name'], |
61 | 61 | ); |
62 | 62 | |
63 | - for($i = 1; $i < count($rank); $i++) |
|
63 | + for ($i = 1; $i < count($rank); $i++) |
|
64 | 64 | { |
65 | - $rank_data['R' . $i] = (($rank[$ally_rights[$i]] == 1) ? ' checked' : '') ; |
|
65 | + $rank_data['R' . $i] = (($rank[$ally_rights[$i]] == 1) ? ' checked' : ''); |
|
66 | 66 | $rank_data['N' . $i] = $ally_rights[$i]; |
67 | 67 | } |
68 | 68 |
@@ -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 |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @return array |
241 | 241 | */ |
242 | 242 | public static function parseParamStrings($array, $delimiter = '=') { |
243 | - !is_array($array) ? $array = array((string)$array) : false; |
|
243 | + !is_array($array) ? $array = array((string) $array) : false; |
|
244 | 244 | |
245 | 245 | $result = array(); |
246 | 246 | foreach ($array as $param) { |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | * @return float|null |
263 | 263 | */ |
264 | 264 | public static function maxValueByField(&$array, $fieldName) { |
265 | - return array_reduce($array, function ($carry, $item) use ($fieldName) { |
|
266 | - if(is_array($item) && isset($item[$fieldName]) && (!isset($carry) || $carry < $item[$fieldName])) { |
|
265 | + return array_reduce($array, function($carry, $item) use ($fieldName) { |
|
266 | + if (is_array($item) && isset($item[$fieldName]) && (!isset($carry) || $carry < $item[$fieldName])) { |
|
267 | 267 | $carry = $item[$fieldName]; |
268 | 268 | } |
269 | 269 | |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | |
281 | 281 | return |
282 | 282 | array_reduce($array, |
283 | - function ($carry, $item) use (&$fieldName, $maxValue) { |
|
284 | - if(is_array($item) && isset($item[$fieldName]) && $item[$fieldName] == $maxValue) { |
|
283 | + function($carry, $item) use (&$fieldName, $maxValue) { |
|
284 | + if (is_array($item) && isset($item[$fieldName]) && $item[$fieldName] == $maxValue) { |
|
285 | 285 | $carry[] = $item; |
286 | 286 | } |
287 | 287 | |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | } |
293 | 293 | |
294 | 294 | public static function intersectByKeys(array &$array1, array &$array2) { |
295 | - return array_uintersect_assoc($array1, $array2, function ($a, $b) {return 0;}); |
|
295 | + return array_uintersect_assoc($array1, $array2, function($a, $b) {return 0; }); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | } |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | |
53 | 53 | $prefix_length = strlen($this->db->db_prefix); |
54 | 54 | |
55 | - while($row = $this->db->db_fetch($query)) { |
|
56 | - foreach($row as $table_name) { |
|
55 | + while ($row = $this->db->db_fetch($query)) { |
|
56 | + foreach ($row as $table_name) { |
|
57 | 57 | $this->tablesAll[$table_name] = $table_name; |
58 | 58 | |
59 | - if(strpos($table_name, $this->db->db_prefix) === 0) { |
|
59 | + if (strpos($table_name, $this->db->db_prefix) === 0) { |
|
60 | 60 | $table_name_sn = substr($table_name, $prefix_length); |
61 | 61 | $this->tablesSn[$table_name_sn] = $table_name_sn; |
62 | 62 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return \string[] |
71 | 71 | */ |
72 | 72 | public function getAllTables() { |
73 | - if(!isset($this->tablesAll)) { |
|
73 | + if (!isset($this->tablesAll)) { |
|
74 | 74 | $this->loadTableNamesFromDb(); |
75 | 75 | } |
76 | 76 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @return string[] |
84 | 84 | */ |
85 | 85 | public function getSnTables() { |
86 | - if(!isset($this->tablesSn)) { |
|
86 | + if (!isset($this->tablesSn)) { |
|
87 | 87 | $this->loadTableNamesFromDb(); |
88 | 88 | } |
89 | 89 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @return TableSchema |
108 | 108 | */ |
109 | 109 | public function getTableSchema($tableName) { |
110 | - if(empty($this->tableSchemas[$tableName])) { |
|
110 | + if (empty($this->tableSchemas[$tableName])) { |
|
111 | 111 | $this->tableSchemas[$tableName] = new TableSchema($tableName, $this); |
112 | 112 | } |
113 | 113 |
@@ -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 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $this->sql_index_field = "{$table_name}_name"; |
34 | 34 | $this->sql_value_field = "{$table_name}_value"; |
35 | 35 | |
36 | - if(!$this->_DB_LOADED) { |
|
36 | + if (!$this->_DB_LOADED) { |
|
37 | 37 | $this->db_loadAll(); |
38 | 38 | } |
39 | 39 | } |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function db_loadItem($index) { |
55 | 55 | $result = null; |
56 | - if($index) { |
|
56 | + if ($index) { |
|
57 | 57 | $index_safe = db_escape($index); |
58 | 58 | $queryResult = doquery("SELECT `{$this->sql_value_field}` FROM `{{{$this->table_name}}}` WHERE `{$this->sql_index_field}` = '{$index_safe}' FOR UPDATE", true); |
59 | - if(is_array($queryResult) && !empty($queryResult)) { |
|
59 | + if (is_array($queryResult) && !empty($queryResult)) { |
|
60 | 60 | $this->$index = $result = $queryResult[$this->sql_value_field]; |
61 | 61 | } |
62 | 62 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $this->loadDefaults(); |
69 | 69 | |
70 | 70 | $query = doquery("SELECT * FROM {{{$this->table_name}}} FOR UPDATE;"); |
71 | - while($row = db_fetch($query)) { |
|
71 | + while ($row = db_fetch($query)) { |
|
72 | 72 | $this->$row[$this->sql_index_field] = $row[$this->sql_value_field]; |
73 | 73 | } |
74 | 74 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | public function loadDefaults() { |
79 | - foreach($this->defaults as $defName => $defValue) { |
|
79 | + foreach ($this->defaults as $defName => $defValue) { |
|
80 | 80 | $this->$defName = $defValue; |
81 | 81 | } |
82 | 82 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | public function db_saveItem($item_list, $value = NULL) { |
95 | - if(empty($item_list)) { |
|
95 | + if (empty($item_list)) { |
|
96 | 96 | return; |
97 | 97 | } |
98 | 98 | |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | |
101 | 101 | // Сначала записываем данные в базу - что бы поймать все блокировки |
102 | 102 | $qry = array(); |
103 | - foreach($item_list as $item_name => $item_value) { |
|
104 | - if($item_name) { |
|
103 | + foreach ($item_list as $item_name => $item_value) { |
|
104 | + if ($item_name) { |
|
105 | 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}')"; |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | doquery("REPLACE INTO `{{" . $this->table_name . "}}` (`{$this->sql_index_field}`, `{$this->sql_value_field}`) VALUES " . implode(',', $qry) . ";"); |
111 | 111 | |
112 | 112 | // И только после взятия блокировок - меняем значения в кэше |
113 | - foreach($item_list as $item_name => $item_value) { |
|
114 | - if($item_name && $item_value !== null) { |
|
113 | + foreach ($item_list as $item_name => $item_value) { |
|
114 | + if ($item_name && $item_value !== null) { |
|
115 | 115 | $this->__set($item_name, $item_value); |
116 | 116 | } |
117 | 117 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | public function __get($name) { |
129 | - if($this->force) { |
|
129 | + if ($this->force) { |
|
130 | 130 | $this->force = false; |
131 | 131 | $this->db_loadItem($name); |
132 | 132 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | public function __set($name, $value) { |
138 | - if($this->force) { |
|
138 | + if ($this->force) { |
|
139 | 139 | $this->force = false; |
140 | 140 | $this->db_saveItem($name, $value); |
141 | 141 | } |