@@ -26,7 +26,7 @@ |
||
26 | 26 | 'GROUP BY `unit_snid`' |
27 | 27 | ); |
28 | 28 | $result = array(); |
29 | - while($row = db_fetch($query)) { |
|
29 | + while ($row = db_fetch($query)) { |
|
30 | 30 | $result[$row['unit_snid']] = $row; |
31 | 31 | } |
32 | 32 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('IN_UPDATE')) { |
|
3 | +if (!defined('IN_UPDATE')) { |
|
4 | 4 | die('Trying to call update helpers externally!'); |
5 | 5 | } |
6 | 6 | |
@@ -8,13 +8,13 @@ discard block |
||
8 | 8 | global $update_tables; |
9 | 9 | |
10 | 10 | upd_add_more_time(); |
11 | - if(!$no_log) { |
|
11 | + if (!$no_log) { |
|
12 | 12 | upd_log_message("Performing query '{$query}'"); |
13 | 13 | } |
14 | 14 | |
15 | 15 | // classSupernova::$db->sn_db_connect(); |
16 | - if(!(strpos($query, '{{') === false)) { |
|
17 | - foreach($update_tables as $tableName => $cork) { |
|
16 | + if (!(strpos($query, '{{') === false)) { |
|
17 | + foreach ($update_tables as $tableName => $cork) { |
|
18 | 18 | $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix . $tableName, $query); |
19 | 19 | } |
20 | 20 | } |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | global $sys_log_disabled; |
28 | 28 | |
29 | 29 | classSupernova::$config->db_loadItem($key); |
30 | - if($condition || !isset(classSupernova::$config->$key)) { |
|
30 | + if ($condition || !isset(classSupernova::$config->$key)) { |
|
31 | 31 | upd_add_more_time(); |
32 | - if(!$sys_log_disabled) { |
|
32 | + if (!$sys_log_disabled) { |
|
33 | 33 | upd_log_message("Updating config key '{$key}' with value '{$default_value}'"); |
34 | 34 | } |
35 | 35 | classSupernova::$config->db_saveItem($key, $default_value); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | function upd_log_message($message) { |
58 | 58 | global $sys_log_disabled, $upd_log, $debug; |
59 | 59 | |
60 | - if($sys_log_disabled) { |
|
60 | + if ($sys_log_disabled) { |
|
61 | 61 | // print("{$message}<br />"); |
62 | 62 | } else { |
63 | 63 | $upd_log .= "{$message}\r\n"; |
@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | function upd_unset_table_info($table_name) { |
69 | 69 | global $update_tables, $update_indexes, $update_foreigns; |
70 | 70 | |
71 | - if(isset($update_tables[$table_name])) { |
|
71 | + if (isset($update_tables[$table_name])) { |
|
72 | 72 | unset($update_tables[$table_name]); |
73 | 73 | } |
74 | 74 | |
75 | - if(isset($update_indexes[$table_name])) { |
|
75 | + if (isset($update_indexes[$table_name])) { |
|
76 | 76 | unset($update_indexes[$table_name]); |
77 | 77 | } |
78 | 78 | |
79 | - if(isset($update_foreigns[$table_name])) { |
|
79 | + if (isset($update_foreigns[$table_name])) { |
|
80 | 80 | unset($update_foreigns[$table_name]); |
81 | 81 | } |
82 | 82 | } |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | upd_unset_table_info($tableName); |
91 | 91 | |
92 | 92 | $q1 = upd_do_query("SHOW FULL COLUMNS FROM {$prefix_table_name};", true); |
93 | - while($r1 = db_fetch($q1)) { |
|
93 | + while ($r1 = db_fetch($q1)) { |
|
94 | 94 | $update_tables[$tableName][$r1['Field']] = $r1; |
95 | 95 | } |
96 | 96 | |
97 | 97 | $q1 = upd_do_query("SHOW INDEX FROM {$prefix_table_name};", true); |
98 | - while($r1 = db_fetch($q1)) { |
|
98 | + while ($r1 = db_fetch($q1)) { |
|
99 | 99 | $update_indexes[$tableName][$r1['Key_name']] .= "{$r1['Column_name']},"; |
100 | 100 | $update_indexes_full[$tableName][$r1['Key_name']][$r1['Column_name']] = $r1; |
101 | 101 | } |
102 | 102 | |
103 | 103 | $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true); |
104 | - while($r1 = db_fetch($q1)) { |
|
104 | + while ($r1 = db_fetch($q1)) { |
|
105 | 105 | $table_referenced = str_replace(classSupernova::$config->db_prefix, '', $r1['REFERENCED_TABLE_NAME']); |
106 | 106 | |
107 | 107 | $update_foreigns[$tableName][$r1['CONSTRAINT_NAME']] .= "{$r1['COLUMN_NAME']},{$table_referenced},{$r1['REFERENCED_COLUMN_NAME']};"; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @return bool|mysqli_result|void |
117 | 117 | */ |
118 | 118 | function upd_alter_table($table, $alters, $condition = true) { |
119 | - if(!$condition) { |
|
119 | + if (!$condition) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | 122 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $alters_print = is_array($alters) ? dump($alters) : $alters; |
125 | 125 | upd_log_message("Altering table '{$table}' with alterations {$alters_print}"); |
126 | 126 | |
127 | - if(!is_array($alters)) { |
|
127 | + if (!is_array($alters)) { |
|
128 | 128 | $alters = array($alters); |
129 | 129 | } |
130 | 130 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | $result = upd_do_query($qry); |
135 | 135 | $error = db_error(); |
136 | - if($error) { |
|
136 | + if ($error) { |
|
137 | 137 | die("Altering error for table `{$table}`: {$error}<br />{$alters_print}"); |
138 | 138 | } |
139 | 139 | |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | function upd_create_table($table_name, $declaration) { |
153 | 153 | global $update_tables; |
154 | 154 | |
155 | - if(!$update_tables[$table_name]) { |
|
155 | + if (!$update_tables[$table_name]) { |
|
156 | 156 | upd_do_query('set foreign_key_checks = 0;', true); |
157 | 157 | $db_prefix = classSupernova::$config->db_prefix; |
158 | 158 | $result = upd_do_query("CREATE TABLE IF NOT EXISTS `{$db_prefix}{$table_name}` {$declaration}"); |
159 | 159 | $error = db_error(); |
160 | - if($error) { |
|
160 | + if ($error) { |
|
161 | 161 | die("Creating error for table `{$table_name}`: {$error}<br />" . dump($declaration)); |
162 | 162 | } |
163 | 163 | upd_do_query('set foreign_key_checks = 1;', true); |
@@ -183,14 +183,14 @@ discard block |
||
183 | 183 | |
184 | 184 | |
185 | 185 | function upd_db_unit_changeset_prepare($unit_id, $unit_value, $user, $planet_id = null) { |
186 | - if(!is_array($user)) { |
|
186 | + if (!is_array($user)) { |
|
187 | 187 | // TODO - remove later |
188 | 188 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER is not ARRAY</h1>'); |
189 | 189 | pdump(debug_backtrace()); |
190 | 190 | die('USER is not ARRAY'); |
191 | 191 | } |
192 | 192 | |
193 | - if(!isset($user['id']) || !$user['id']) { |
|
193 | + if (!isset($user['id']) || !$user['id']) { |
|
194 | 194 | // TODO - remove later |
195 | 195 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER[id] пустой</h1>'); |
196 | 196 | pdump($user); |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | $db_changeset = array(); |
207 | 207 | $temp = upd_db_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id'); |
208 | - if($temp['unit_id']) { |
|
208 | + if ($temp['unit_id']) { |
|
209 | 209 | // update |
210 | 210 | $db_changeset = array( |
211 | 211 | 'action' => SQL_OP_UPDATE, |
@@ -250,41 +250,41 @@ discard block |
||
250 | 250 | |
251 | 251 | |
252 | 252 | function upd_db_changeset_apply($db_changeset) { |
253 | - if(!is_array($db_changeset) || empty($db_changeset)) { |
|
253 | + if (!is_array($db_changeset) || empty($db_changeset)) { |
|
254 | 254 | return; |
255 | 255 | } |
256 | 256 | |
257 | - foreach($db_changeset as $table_name => $table_data) { |
|
258 | - foreach($table_data as $record_id => $conditions) { |
|
257 | + foreach ($db_changeset as $table_name => $table_data) { |
|
258 | + foreach ($table_data as $record_id => $conditions) { |
|
259 | 259 | $where = ''; |
260 | - if(!empty($conditions['where'])) { |
|
260 | + if (!empty($conditions['where'])) { |
|
261 | 261 | $where = 'WHERE ' . implode(' AND ', $conditions['where']); |
262 | 262 | } |
263 | 263 | |
264 | 264 | $fields = array(); |
265 | - if($conditions['fields']) { |
|
266 | - foreach($conditions['fields'] as $field_name => $field_data) { |
|
265 | + if ($conditions['fields']) { |
|
266 | + foreach ($conditions['fields'] as $field_name => $field_data) { |
|
267 | 267 | $condition = "`{$field_name}` = "; |
268 | 268 | $value = ''; |
269 | - if($field_data['delta']) { |
|
269 | + if ($field_data['delta']) { |
|
270 | 270 | $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; |
271 | - } elseif($field_data['set']) { |
|
271 | + } elseif ($field_data['set']) { |
|
272 | 272 | $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); |
273 | 273 | } |
274 | - if($value) { |
|
274 | + if ($value) { |
|
275 | 275 | $fields[] = $condition . $value; |
276 | 276 | } |
277 | 277 | } |
278 | 278 | } |
279 | 279 | $fields = implode(',', $fields); |
280 | 280 | |
281 | - switch($conditions['action']) { |
|
281 | + switch ($conditions['action']) { |
|
282 | 282 | case SQL_OP_DELETE: |
283 | 283 | upd_do_query("DELETE FROM {{{$table_name}}} {$where}"); |
284 | 284 | break; |
285 | 285 | |
286 | 286 | case SQL_OP_UPDATE: |
287 | - if($fields) { |
|
287 | + if ($fields) { |
|
288 | 288 | /*if($table_name == 'unit') |
289 | 289 | { |
290 | 290 | pdump("UPDATE {{{$table_name}}} SET {$fields} {$where}"); |
@@ -295,13 +295,13 @@ discard block |
||
295 | 295 | break; |
296 | 296 | |
297 | 297 | case SQL_OP_INSERT: |
298 | - if($fields) { |
|
298 | + if ($fields) { |
|
299 | 299 | upd_do_query("INSERT INTO {{{$table_name}}} SET {$fields}"); |
300 | 300 | } |
301 | 301 | break; |
302 | 302 | |
303 | 303 | case SQL_OP_REPLACE: |
304 | - if($fields) { |
|
304 | + if ($fields) { |
|
305 | 305 | upd_do_query("REPLACE INTO {{{$table_name}}} SET {$fields}"); |
306 | 306 | } |
307 | 307 | break; |
@@ -5,29 +5,29 @@ discard block |
||
5 | 5 | $avatar_filename = $fullsize_filename = SN_ROOT_PHYSICAL . 'images/avatar/' . $prefix . '_' . $subject_id; |
6 | 6 | $avatar_filename .= '.png'; |
7 | 7 | $fullsize_filename .= '_full.png'; |
8 | - if(sys_get_param_int('avatar_remove')) { |
|
9 | - if(file_exists($avatar_filename) && !unlink($avatar_filename)) { |
|
8 | + if (sys_get_param_int('avatar_remove')) { |
|
9 | + if (file_exists($avatar_filename) && !unlink($avatar_filename)) { |
|
10 | 10 | throw new Exception(classLocale::$lang['opt_msg_avatar_error_delete'], ERR_ERROR); |
11 | 11 | } |
12 | 12 | $avatar_field = 0; |
13 | 13 | throw new Exception(classLocale::$lang['opt_msg_avatar_removed'], ERR_NONE); |
14 | - } elseif($_FILES['avatar']['size']) { |
|
15 | - if(!in_array($_FILES['avatar']['type'], array('image/gif', 'image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png')) || $_FILES['avatar']['size'] > 204800) { |
|
14 | + } elseif ($_FILES['avatar']['size']) { |
|
15 | + if (!in_array($_FILES['avatar']['type'], array('image/gif', 'image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png')) || $_FILES['avatar']['size'] > 204800) { |
|
16 | 16 | throw new Exception(classLocale::$lang['opt_msg_avatar_error_unsupported'], ERR_WARNING); |
17 | 17 | } |
18 | 18 | |
19 | - if($_FILES['avatar']['error']) { |
|
19 | + if ($_FILES['avatar']['error']) { |
|
20 | 20 | throw new Exception(sprintf(classLocale::$lang['opt_msg_avatar_error_upload'], $_FILES['avatar']['error']), ERR_ERROR); |
21 | 21 | } |
22 | 22 | |
23 | - if(!($avatar_image = imagecreatefromstring(file_get_contents($_FILES['avatar']['tmp_name'])))) { |
|
23 | + if (!($avatar_image = imagecreatefromstring(file_get_contents($_FILES['avatar']['tmp_name'])))) { |
|
24 | 24 | throw new Exception(classLocale::$lang['opt_msg_avatar_error_unsupported'], ERR_WARNING); |
25 | 25 | } |
26 | 26 | |
27 | 27 | $avatar_size = getimagesize($_FILES['avatar']['tmp_name']); |
28 | 28 | $avatar_max_width = classSupernova::$config->avatar_max_width; |
29 | 29 | $avatar_max_height = classSupernova::$config->avatar_max_height; |
30 | - if($avatar_size[0] > $avatar_max_width || $avatar_size[1] > $avatar_max_height) { |
|
30 | + if ($avatar_size[0] > $avatar_max_width || $avatar_size[1] > $avatar_max_height) { |
|
31 | 31 | $aspect_ratio = min($avatar_max_width / $avatar_size[0], $avatar_max_height / $avatar_size[1]); |
32 | 32 | $avatar_image_new = imagecreatetruecolor($avatar_size[0] * $aspect_ratio, $avatar_size[0] * $aspect_ratio); |
33 | 33 | $result = imagecopyresized($avatar_image_new, $avatar_image, 0, 0, 0, 0, $avatar_size[0] * $aspect_ratio, $avatar_size[0] * $aspect_ratio, $avatar_size[0], $avatar_size[1]); |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | $avatar_image = $avatar_image_new; |
36 | 36 | } |
37 | 37 | |
38 | - if(file_exists($avatar_filename) && !unlink($avatar_filename)) { |
|
38 | + if (file_exists($avatar_filename) && !unlink($avatar_filename)) { |
|
39 | 39 | throw new Exception(classLocale::$lang['opt_msg_avatar_error_delete'], ERR_ERROR); |
40 | 40 | } |
41 | 41 | |
42 | - if(!imagepng($avatar_image, $avatar_filename, 9)) { |
|
42 | + if (!imagepng($avatar_image, $avatar_filename, 9)) { |
|
43 | 43 | throw new Exception(classLocale::$lang['opt_msg_avatar_error_writing'], ERR_ERROR); |
44 | 44 | } |
45 | 45 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | imagedestroy($avatar_image); |
48 | 48 | throw new Exception(classLocale::$lang['opt_msg_avatar_uploaded'], ERR_NONE); |
49 | 49 | } |
50 | - } catch(Exception $e) { |
|
50 | + } catch (Exception $e) { |
|
51 | 51 | return array( |
52 | 52 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
53 | 53 | 'MESSAGE' => $e->getMessage() |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | $classLocale = classLocale::$lang; |
4 | 4 | |
5 | -if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) { |
|
5 | +if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) { |
|
6 | 6 | $debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403); |
7 | 7 | } |
8 | 8 | |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | 'rpg_cost' => $rpg_cost, |
15 | 15 | )); |
16 | 16 | |
17 | -if(is_array($shipList)) { |
|
18 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) { |
|
17 | +if (is_array($shipList)) { |
|
18 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) { |
|
19 | 19 | $intError = MARKET_NO_DM; |
20 | 20 | } |
21 | 21 | |
@@ -32,30 +32,30 @@ discard block |
||
32 | 32 | $qry = array(); |
33 | 33 | $total = array(); |
34 | 34 | $db_changeset = array(); |
35 | - foreach($shipList as $shipID => &$shipCount) { |
|
35 | + foreach ($shipList as $shipID => &$shipCount) { |
|
36 | 36 | $shipCount = ceil(floatval($shipCount)); |
37 | - if(!$shipCount) { |
|
37 | + if (!$shipCount) { |
|
38 | 38 | continue; |
39 | 39 | } |
40 | 40 | |
41 | - if($shipCount < 0) { |
|
41 | + if ($shipCount < 0) { |
|
42 | 42 | $debug->warning('User supplied negative ship count on Black Market page', 'Hack Attempt', 307); |
43 | 43 | $intError = MARKET_NEGATIVE_SHIPS; |
44 | 44 | break; |
45 | 45 | } |
46 | 46 | |
47 | - if($mode == MARKET_SCRAPPER) { |
|
47 | + if ($mode == MARKET_SCRAPPER) { |
|
48 | 48 | $amount = mrc_get_level($user, $planetrow, $shipID, true, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
49 | - } elseif($mode == MARKET_STOCKMAN) { |
|
49 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
50 | 50 | $amount = $stock[$shipID]; |
51 | 51 | } |
52 | 52 | |
53 | - if($amount < $shipCount) { |
|
53 | + if ($amount < $shipCount) { |
|
54 | 54 | $intError = $error_no_stock; |
55 | 55 | break; |
56 | 56 | } |
57 | 57 | |
58 | - if(!in_array($shipID, sn_get_groups('fleet'))) { |
|
58 | + if (!in_array($shipID, sn_get_groups('fleet'))) { |
|
59 | 59 | $debug->warning('Hack Attempt', 'User supplied non-ship unit ID on Black Market page', 306); |
60 | 60 | $intError = MARKET_NOT_A_SHIP; |
61 | 61 | break; |
@@ -71,16 +71,16 @@ discard block |
||
71 | 71 | $resTemp[RES_CRYSTAL] = floor($build_data[BUILD_CREATE][RES_CRYSTAL] * $shipCount * $config_rpg_scrape_crystal * (-$multiplier)); |
72 | 72 | $resTemp[RES_DEUTERIUM] = floor($build_data[BUILD_CREATE][RES_DEUTERIUM] * $shipCount * $config_rpg_scrape_deuterium * (-$multiplier)); |
73 | 73 | |
74 | - foreach($resTemp as $resID => $resCount) { |
|
74 | + foreach ($resTemp as $resID => $resCount) { |
|
75 | 75 | $total[$resID] += $resCount; |
76 | 76 | } |
77 | 77 | |
78 | 78 | $message .= "<li>{$classLocale['tech'][$shipID]}: " . pretty_number($shipCount); |
79 | 79 | } |
80 | 80 | |
81 | - if($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
82 | - foreach($total as $resID => $resCount) { |
|
83 | - if(mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
81 | + if ($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
82 | + foreach ($total as $resID => $resCount) { |
|
83 | + if (mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
84 | 84 | $intError = MARKET_NO_RESOURCES; |
85 | 85 | $debug->warning('Trying to use bug in s/h market', 'S/H Ship Market', 301); |
86 | 86 | break; |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | |
91 | 91 | $intError = ($intError == MARKET_DEAL) && (array_sum($total) == 0) ? $error_zero_res : $intError; |
92 | 92 | |
93 | - if($intError == MARKET_DEAL) { |
|
93 | + if ($intError == MARKET_DEAL) { |
|
94 | 94 | $message .= '</ul>' . classLocale::$lang["eco_mrk_{$submode}_res"] . '<ul>'; |
95 | - foreach($total as $resID => $resCount) { |
|
96 | - if(!$resCount) { |
|
95 | + foreach ($total as $resID => $resCount) { |
|
96 | + if (!$resCount) { |
|
97 | 97 | continue; |
98 | 98 | } |
99 | 99 | |
@@ -127,38 +127,38 @@ discard block |
||
127 | 127 | 'MESSAGE' => classLocale::$lang['eco_mrk_errors'][$intError], |
128 | 128 | )); |
129 | 129 | |
130 | - foreach($shipList as $shipID => $shipCount) { |
|
130 | + foreach ($shipList as $shipID => $shipCount) { |
|
131 | 131 | $data['ships'][$shipID] = max(0, intval($shipCount)); |
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
135 | 135 | $message = ''; |
136 | 136 | |
137 | -if(!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) { |
|
138 | - classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item){return mt_rand(1, 1000);}, sn_get_groups('fleet')))); |
|
137 | +if (!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) { |
|
138 | + classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item) {return mt_rand(1, 1000); }, sn_get_groups('fleet')))); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | tpl_set_resource_info($template, $planetrow, array()); |
142 | 142 | |
143 | -if(!$array) { |
|
143 | +if (!$array) { |
|
144 | 144 | $array = array(); |
145 | 145 | } |
146 | 146 | |
147 | 147 | $group_fleet = sn_get_groups('fleet'); |
148 | -foreach($array as $key => $value) { |
|
149 | - if($mode == MARKET_SCRAPPER) { |
|
148 | +foreach ($array as $key => $value) { |
|
149 | + if ($mode == MARKET_SCRAPPER) { |
|
150 | 150 | $shipID = $value; |
151 | 151 | $amount = mrc_get_level($user, $planetrow, $shipID, false, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
152 | - } elseif($mode == MARKET_STOCKMAN) { |
|
152 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
153 | 153 | $shipID = $key; |
154 | 154 | $amount = $value; |
155 | 155 | } |
156 | 156 | |
157 | - if(!in_array($shipID, $group_fleet)) { |
|
157 | + if (!in_array($shipID, $group_fleet)) { |
|
158 | 158 | continue; |
159 | 159 | } |
160 | 160 | |
161 | - if($amount > 0) { |
|
161 | + if ($amount > 0) { |
|
162 | 162 | $build_data = eco_get_build_data($user, $planetrow, $shipID); |
163 | 163 | $template->assign_block_vars('ships', array( |
164 | 164 | 'ID' => $shipID, |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | // banner.php?id=<userid>&type=<banner|userbar>&format=<png> |
16 | 16 | $id = intval($id); |
17 | 17 | |
18 | - switch($type) { |
|
18 | + switch ($type) { |
|
19 | 19 | case 'banner': |
20 | 20 | $img_name = classSupernova::$config->int_banner_background; |
21 | 21 | break; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | 'info' => SN_ROOT_PHYSICAL . "design/fonts/" . classSupernova::$config->int_banner_fontInfo, |
49 | 49 | ); |
50 | 50 | |
51 | - if($id) { |
|
51 | + if ($id) { |
|
52 | 52 | // Querys |
53 | 53 | $user = db_user_by_id($id); |
54 | 54 | $planet_row = db_planet_by_id($user['id_planet']); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | $b_univ = classSupernova::$config->game_name; |
67 | - switch($type) { |
|
67 | + switch ($type) { |
|
68 | 68 | case 'banner': |
69 | 69 | // Banner size 416 x 58 |
70 | 70 | $fsize = 15; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | imagettftext($image, 11, 0, 8, 26, $txt_shadow, $fonts['info'], $b_user); |
78 | 78 | imagettftext($image, 11, 0, 6, 23, $txt_color, $fonts['info'], $b_user); |
79 | 79 | |
80 | - if($id) { |
|
80 | + if ($id) { |
|
81 | 81 | // Player level - right-alligned |
82 | 82 | $is = imagettfbbox(11, 0, $fonts['info'], $b_lvl); |
83 | 83 | imagettftext($image, 11, 0, $size[0] - 4 - $is[2], 25, $txt_shadow, $fonts['info'], $b_lvl); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | imagettftext($image, 9, 0, 4, $size[1] - 4, $txt_shadow, $fonts['userbar'], $b_user); |
136 | 136 | imagettftext($image, 9, 0, 2, $size[1] - 6, $txt_color, $fonts['userbar'], $b_user); |
137 | 137 | |
138 | - if($id) { |
|
138 | + if ($id) { |
|
139 | 139 | // Player level - right-alligned |
140 | 140 | $isp = imagettfbbox(9, 0, $fonts['userbar'], $b_lvl); |
141 | 141 | imagettftext($image, 9, 0, $is - $isp[2] - 10, $size[1] - 4, $txt_shadow, $fonts['userbar'], $b_lvl); |
@@ -11,38 +11,38 @@ discard block |
||
11 | 11 | |
12 | 12 | $in_admin = defined('IN_ADMIN') && IN_ADMIN === true; |
13 | 13 | |
14 | - if($in_admin) { |
|
14 | + if ($in_admin) { |
|
15 | 15 | $quest_id = sys_get_param_id('id'); |
16 | 16 | $quest_name = sys_get_param_str_unsafe('QUEST_NAME'); |
17 | - if(!empty($quest_name)) { |
|
17 | + if (!empty($quest_name)) { |
|
18 | 18 | $quest_description = sys_get_param_str_unsafe('QUEST_DESCRIPTION'); |
19 | 19 | try { |
20 | 20 | $quest_rewards_list = sys_get_param('QUEST_REWARDS_LIST'); |
21 | 21 | $quest_rewards = array(); |
22 | - foreach($quest_rewards_list as $quest_rewards_id => $quest_rewards_amount) { |
|
23 | - if(!in_array($quest_rewards_id, $quest_reward_allowed)) { |
|
22 | + foreach ($quest_rewards_list as $quest_rewards_id => $quest_rewards_amount) { |
|
23 | + if (!in_array($quest_rewards_id, $quest_reward_allowed)) { |
|
24 | 24 | throw new Exception(classLocale::$lang['qst_adm_err_reward_type']); |
25 | 25 | } |
26 | 26 | |
27 | - if($quest_rewards_amount < 0) { |
|
27 | + if ($quest_rewards_amount < 0) { |
|
28 | 28 | throw new Exception(classLocale::$lang['qst_adm_err_reward_amount']); |
29 | - } elseif($quest_rewards_amount > 0) { |
|
29 | + } elseif ($quest_rewards_amount > 0) { |
|
30 | 30 | $quest_rewards[] = "{$quest_rewards_id},{$quest_rewards_amount}"; |
31 | 31 | } |
32 | 32 | } |
33 | - if(empty($quest_rewards)) { |
|
33 | + if (empty($quest_rewards)) { |
|
34 | 34 | throw new Exception(classLocale::$lang['qst_adm_err_reward_empty']); |
35 | 35 | } |
36 | 36 | |
37 | 37 | $quest_rewards = implode(';', $quest_rewards); |
38 | 38 | |
39 | 39 | $quest_unit_id = sys_get_param_int('QUEST_UNIT_ID'); |
40 | - if(!in_array($quest_unit_id, $quest_units_allowed)) { |
|
40 | + if (!in_array($quest_unit_id, $quest_units_allowed)) { |
|
41 | 41 | throw new Exception(classLocale::$lang['qst_adm_err_unit_id']); |
42 | 42 | } |
43 | 43 | |
44 | 44 | $quest_unit_amount = sys_get_param_float('QUEST_UNIT_AMOUNT'); |
45 | - if($quest_unit_amount <= 0) { |
|
45 | + if ($quest_unit_amount <= 0) { |
|
46 | 46 | throw new Exception(classLocale::$lang['qst_adm_err_unit_amount']); |
47 | 47 | } |
48 | 48 | $quest_conditions = "{$quest_unit_id},{$quest_unit_amount}"; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | // TODO: Change quest type |
51 | 51 | $quest_type = 0; |
52 | 52 | |
53 | - if($mode == 'edit') { |
|
53 | + if ($mode == 'edit') { |
|
54 | 54 | $quest_name = db_escape($quest_name); |
55 | 55 | $quest_description = db_escape($quest_description); |
56 | 56 | db_quest_update($quest_name, $quest_type, $quest_description, $quest_conditions, $quest_rewards, $quest_id); |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | // TODO: Add mass mail for new quests |
68 | - } catch(Exception $e) { |
|
68 | + } catch (Exception $e) { |
|
69 | 69 | message($e->getMessage(), classLocale::$lang['sys_error']); |
70 | 70 | } |
71 | 71 | |
72 | 72 | $mode = ''; |
73 | 73 | }; |
74 | 74 | |
75 | - switch($mode) { |
|
75 | + switch ($mode) { |
|
76 | 76 | case 'del': |
77 | 77 | db_quest_delete($quest_id); |
78 | 78 | $mode = ''; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | } |
88 | 88 | $query = db_quest_count(); |
89 | 89 | classSupernova::$config->db_saveItem('quest_total', $query['count']); |
90 | - } elseif(!$user_id) { |
|
90 | + } elseif (!$user_id) { |
|
91 | 91 | $user_id = $user['id']; |
92 | 92 | } |
93 | 93 | |
@@ -100,22 +100,22 @@ discard block |
||
100 | 100 | 'IN_ADMIN' => $in_admin, |
101 | 101 | )); |
102 | 102 | |
103 | - if($quest) { |
|
103 | + if ($quest) { |
|
104 | 104 | $quest_templatized = qst_templatize(qst_quest_parse($quest, false)); |
105 | 105 | } else { |
106 | 106 | $quest_templatized['quest_rewards_list'] = array(); |
107 | 107 | } |
108 | 108 | |
109 | - foreach($quest_reward_allowed as $unit_id) { |
|
109 | + foreach ($quest_reward_allowed as $unit_id) { |
|
110 | 110 | $found = false; |
111 | - foreach($quest_templatized['quest_rewards_list'] as $quest_templatized_reward) { |
|
112 | - if($quest_templatized_reward['ID'] == $unit_id) { |
|
111 | + foreach ($quest_templatized['quest_rewards_list'] as $quest_templatized_reward) { |
|
112 | + if ($quest_templatized_reward['ID'] == $unit_id) { |
|
113 | 113 | $found = true; |
114 | 114 | break; |
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | - if(!$found) { |
|
118 | + if (!$found) { |
|
119 | 119 | $quest_templatized['quest_rewards_list'][$unit_id] = array( |
120 | 120 | 'ID' => $unit_id, |
121 | 121 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | |
127 | 127 | qst_assign_to_template($template, $quest_templatized); |
128 | 128 | |
129 | - foreach($quest_list as $quest_data) { |
|
129 | + foreach ($quest_list as $quest_data) { |
|
130 | 130 | qst_assign_to_template($template, qst_templatize($quest_data, true), 'quest'); |
131 | 131 | } |
132 | 132 | |
133 | - foreach($quest_units_allowed as $unit_id) { |
|
133 | + foreach ($quest_units_allowed as $unit_id) { |
|
134 | 134 | $template->assign_block_vars('allowed_unit', array( |
135 | 135 | 'ID' => $unit_id, |
136 | 136 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | function qst_get_quests($user_id = false, $status = false) { |
142 | 142 | $quest_list = array(); |
143 | 143 | |
144 | - if($user_id) { |
|
145 | - if($status !== false) { |
|
144 | + if ($user_id) { |
|
145 | + if ($status !== false) { |
|
146 | 146 | $query_add_where = "AND qs.quest_status_status "; |
147 | - if($status == null) { |
|
147 | + if ($status == null) { |
|
148 | 148 | $query_add_where .= "IS NULL"; |
149 | 149 | } else { |
150 | 150 | $query_add_where .= "= {$status}"; |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | $query = db_quest_list_get($query_add_select, $query_add_from, $query_add_where); |
158 | 158 | |
159 | - while($quest = db_fetch($query)) { |
|
159 | + while ($quest = db_fetch($query)) { |
|
160 | 160 | $quest_list[$quest['quest_id']] = qst_quest_parse($quest); |
161 | 161 | } |
162 | 162 | |
@@ -164,12 +164,12 @@ discard block |
||
164 | 164 | } |
165 | 165 | |
166 | 166 | function qst_assign_to_template(&$template, $quest_templatized, $block_name = false) { |
167 | - if($block_name) { |
|
167 | + if ($block_name) { |
|
168 | 168 | $template->assign_block_vars($block_name, $quest_templatized); |
169 | 169 | } else { |
170 | 170 | $template->assign_vars($quest_templatized); |
171 | - if(!empty($quest_templatized['quest_rewards_list'])) { |
|
172 | - foreach($quest_templatized['quest_rewards_list'] as $quest_reward) { |
|
171 | + if (!empty($quest_templatized['quest_rewards_list'])) { |
|
172 | + foreach ($quest_templatized['quest_rewards_list'] as $quest_reward) { |
|
173 | 173 | $template->assign_block_vars(($block_name ? $block_name . '.' : '') . 'quest_rewards_list', $quest_reward); |
174 | 174 | } |
175 | 175 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | |
187 | 187 | function qst_templatize($quest, $for_display = true) { |
188 | 188 | $tmp = array(); |
189 | - foreach($quest['quest_rewards_list'] as $quest_reward_id => $quest_reward_amount) { |
|
189 | + foreach ($quest['quest_rewards_list'] as $quest_reward_id => $quest_reward_amount) { |
|
190 | 190 | $tmp[] = array( |
191 | 191 | 'ID' => $quest_reward_id, |
192 | 192 | 'NAME' => $for_display ? str_replace(' ', ' ', classLocale::$lang['tech'][$quest_reward_id]) : classLocale::$lang['tech'][$quest_reward_id], |
@@ -211,8 +211,8 @@ discard block |
||
211 | 211 | |
212 | 212 | function qst_active_triggers($quest_list) { |
213 | 213 | $quest_triggers = array(); |
214 | - foreach($quest_list as $quest_id => $quest) { |
|
215 | - if($quest['quest_status_status'] != QUEST_STATUS_COMPLETE) { |
|
214 | + foreach ($quest_list as $quest_id => $quest) { |
|
215 | + if ($quest['quest_status_status'] != QUEST_STATUS_COMPLETE) { |
|
216 | 216 | list($quest_unit_id, $quest_unit_amount) = explode(',', $quest['quest_conditions']); |
217 | 217 | $quest_triggers[$quest_id] = $quest_unit_id; |
218 | 218 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | } |
223 | 223 | |
224 | 224 | function qst_reward(&$user, &$rewards, &$quest_list) { |
225 | - if(empty($rewards)) { |
|
225 | + if (empty($rewards)) { |
|
226 | 226 | return; |
227 | 227 | } |
228 | 228 | |
@@ -232,14 +232,14 @@ discard block |
||
232 | 232 | $total_rewards = array(); |
233 | 233 | $comment_dm = ''; |
234 | 234 | |
235 | - foreach($rewards as $quest_id => $user_data) { |
|
236 | - foreach($user_data as $user_id => $planet_data) { |
|
237 | - foreach($planet_data as $planet_id => $reward_list) { |
|
235 | + foreach ($rewards as $quest_id => $user_data) { |
|
236 | + foreach ($user_data as $user_id => $planet_data) { |
|
237 | + foreach ($planet_data as $planet_id => $reward_list) { |
|
238 | 238 | $comment = sprintf(classLocale::$lang['qst_msg_complete_body'], $quest_list[$quest_id]['quest_name']); |
239 | 239 | $comment_dm .= isset($reward_list[RES_DARK_MATTER]) ? $comment : ''; |
240 | 240 | |
241 | 241 | $comment_reward = array(); |
242 | - foreach($reward_list as $unit_id => $unit_amount) { |
|
242 | + foreach ($reward_list as $unit_id => $unit_amount) { |
|
243 | 243 | $comment_reward[] = $unit_amount . ' ' . classLocale::$lang['tech'][$unit_id]; |
244 | 244 | $total_rewards[$user_id][$planet_id][$unit_id] += $unit_amount; |
245 | 245 | } |
@@ -258,19 +258,19 @@ discard block |
||
258 | 258 | |
259 | 259 | $group_resources = sn_get_groups('resources_loot'); |
260 | 260 | $quest_rewards_allowed = sn_get_groups('quest_rewards'); |
261 | - if(!empty($total_rewards)) { |
|
262 | - foreach($total_rewards as $user_id => $planet_data) { |
|
261 | + if (!empty($total_rewards)) { |
|
262 | + foreach ($total_rewards as $user_id => $planet_data) { |
|
263 | 263 | $user_row = classSupernova::db_get_record_by_id(LOC_USER, $user_id); |
264 | - foreach($planet_data as $planet_id => $unit_data) { |
|
264 | + foreach ($planet_data as $planet_id => $unit_data) { |
|
265 | 265 | $local_changeset = array(); |
266 | - foreach($unit_data as $unit_id => $unit_amount) { |
|
267 | - if(!isset($quest_rewards_allowed[$unit_id])) { |
|
266 | + foreach ($unit_data as $unit_id => $unit_amount) { |
|
267 | + if (!isset($quest_rewards_allowed[$unit_id])) { |
|
268 | 268 | continue; |
269 | 269 | } |
270 | 270 | |
271 | - if($unit_id == RES_DARK_MATTER) { |
|
271 | + if ($unit_id == RES_DARK_MATTER) { |
|
272 | 272 | rpg_points_change($user['id'], RPG_QUEST, $unit_amount, $comment_dm); |
273 | - } elseif(isset($group_resources[$unit_id])) { |
|
273 | + } elseif (isset($group_resources[$unit_id])) { |
|
274 | 274 | $local_changeset[pname_resource_name($unit_id)] = array('delta' => $unit_amount); |
275 | 275 | } else // Проверим на юниты |
276 | 276 | { |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | // unit |
280 | 280 | } |
281 | 281 | |
282 | - if(!empty($local_changeset)) { |
|
282 | + if (!empty($local_changeset)) { |
|
283 | 283 | $planet_id = $planet_id == 0 && isset($user_row['id_planet']) ? $user_row['id_planet'] : $planet_id; |
284 | 284 | $db_changeset[$planet_id ? 'planets' : 'users'][] = array( |
285 | 285 | 'action' => SQL_OP_UPDATE, |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | $language_new = sys_get_param_str('langer', $user['lang']); |
14 | 14 | |
15 | - if($language_new != $user['lang']) { |
|
15 | + if ($language_new != $user['lang']) { |
|
16 | 16 | classLocale::$lang->lng_switch($language_new); |
17 | 17 | } |
18 | 18 | |
@@ -21,35 +21,35 @@ discard block |
||
21 | 21 | |
22 | 22 | $FMT_DATE = preg_replace(array('/d/', '/m/', '/Y/'), array('DD', 'MM', 'YYYY'), FMT_DATE); |
23 | 23 | |
24 | - if(sys_get_param_str('mode') == 'change') { |
|
25 | - if($user['authlevel'] > 0) { |
|
24 | + if (sys_get_param_str('mode') == 'change') { |
|
25 | + if ($user['authlevel'] > 0) { |
|
26 | 26 | $planet_protection = sys_get_param_int('adm_pl_prot') ? $user['authlevel'] : 0; |
27 | 27 | db_planet_set_by_owner($user['id'], "`id_level` = '{$planet_protection}'"); |
28 | 28 | db_user_set_by_id($user['id'], "`admin_protection` = '{$planet_protection}'"); |
29 | 29 | $user['admin_protection'] = $planet_protection; |
30 | 30 | } |
31 | 31 | |
32 | - if(sys_get_param_int('vacation') && !classSupernova::$config->user_vacation_disable) { |
|
32 | + if (sys_get_param_int('vacation') && !classSupernova::$config->user_vacation_disable) { |
|
33 | 33 | sn_db_transaction_start(); |
34 | - if($user['authlevel'] < 3) { |
|
35 | - if($user['vacation_next'] > SN_TIME_NOW) { |
|
34 | + if ($user['authlevel'] < 3) { |
|
35 | + if ($user['vacation_next'] > SN_TIME_NOW) { |
|
36 | 36 | message(classLocale::$lang['opt_vacation_err_timeout'], classLocale::$lang['Error'], 'index.php?page=options', 5); |
37 | 37 | die(); |
38 | 38 | } |
39 | 39 | |
40 | - if(FleetList::fleet_count_flying($user['id'])) { |
|
40 | + if (FleetList::fleet_count_flying($user['id'])) { |
|
41 | 41 | message(classLocale::$lang['opt_vacation_err_your_fleet'], classLocale::$lang['Error'], 'index.php?page=options', 5); |
42 | 42 | die(); |
43 | 43 | } |
44 | 44 | |
45 | 45 | $que = que_get($user['id'], false); |
46 | - if(!empty($que)) { |
|
46 | + if (!empty($que)) { |
|
47 | 47 | message(classLocale::$lang['opt_vacation_err_que'], classLocale::$lang['Error'], 'index.php?page=options', 5); |
48 | 48 | die(); |
49 | 49 | } |
50 | 50 | |
51 | 51 | $query = classSupernova::db_get_record_list(LOC_PLANET, "`id_owner` = {$user['id']}"); |
52 | - foreach($query as $planet) { |
|
52 | + foreach ($query as $planet) { |
|
53 | 53 | // $planet = sys_o_get_updated($user, $planet, SN_TIME_NOW); |
54 | 54 | // $planet = $planet['planet']; |
55 | 55 | |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | sn_db_transaction_commit(); |
69 | 69 | } |
70 | 70 | |
71 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
72 | - foreach($option_group as $option_name => $option_value) { |
|
73 | - if($user[$option_name] !== null) { |
|
71 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
72 | + foreach ($option_group as $option_name => $option_value) { |
|
73 | + if ($user[$option_name] !== null) { |
|
74 | 74 | $user[$option_name] = sys_get_param_str($option_name); |
75 | 75 | } else { |
76 | 76 | $user[$option_name] = $option_value; |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | |
82 | 82 | |
83 | 83 | $player_options = sys_get_param('options'); |
84 | - if(!empty($player_options)) { |
|
85 | - array_walk($player_options, function (&$value) { |
|
84 | + if (!empty($player_options)) { |
|
85 | + array_walk($player_options, function(&$value) { |
|
86 | 86 | // TODO - Когда будет больше параметров - сделать больше проверок |
87 | 87 | $value = intval($value); |
88 | 88 | }); |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | |
94 | 94 | $username = substr(sys_get_param_str_unsafe('username'), 0, 32); |
95 | 95 | $username_safe = db_escape($username); |
96 | - if($username && $user['username'] != $username && classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
96 | + if ($username && $user['username'] != $username && classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
97 | 97 | // проверка на корректность |
98 | 98 | sn_db_transaction_start(); |
99 | 99 | $name_check = db_player_name_history_get_name_by_name($username_safe); |
100 | - if(!$name_check || $name_check['player_id'] == $user['id']) { |
|
100 | + if (!$name_check || $name_check['player_id'] == $user['id']) { |
|
101 | 101 | $user = db_user_by_id($user['id'], true); |
102 | - switch(classSupernova::$config->game_user_changename) { |
|
102 | + switch (classSupernova::$config->game_user_changename) { |
|
103 | 103 | case SERVER_PLAYER_NAME_CHANGE_PAY: |
104 | - if(mrc_get_level($user, $planetrow, RES_DARK_MATTER) < classSupernova::$config->game_user_changename_cost) { |
|
104 | + if (mrc_get_level($user, $planetrow, RES_DARK_MATTER) < classSupernova::$config->game_user_changename_cost) { |
|
105 | 105 | $template_result['.']['result'][] = array( |
106 | 106 | 'STATUS' => ERR_ERROR, |
107 | 107 | 'MESSAGE' => classLocale::$lang['opt_msg_name_change_err_no_dm'], |
@@ -131,18 +131,18 @@ discard block |
||
131 | 131 | sn_db_transaction_commit(); |
132 | 132 | } |
133 | 133 | |
134 | - if($new_password = sys_get_param('newpass1')) { |
|
134 | + if ($new_password = sys_get_param('newpass1')) { |
|
135 | 135 | try { |
136 | - if($new_password != sys_get_param('newpass2')) { |
|
136 | + if ($new_password != sys_get_param('newpass2')) { |
|
137 | 137 | throw new Exception(classLocale::$lang['opt_err_pass_unmatched'], ERR_WARNING); |
138 | 138 | } |
139 | 139 | |
140 | - if(!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) { |
|
140 | + if (!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) { |
|
141 | 141 | throw new Exception(classLocale::$lang['opt_err_pass_wrong'], ERR_WARNING); |
142 | 142 | } |
143 | 143 | |
144 | 144 | throw new Exception(classLocale::$lang['opt_msg_pass_changed'], ERR_NONE); |
145 | - } catch(Exception $e) { |
|
145 | + } catch (Exception $e) { |
|
146 | 146 | $template_result['.']['result'][] = array( |
147 | 147 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
148 | 148 | 'MESSAGE' => $e->getMessage() |
@@ -164,12 +164,12 @@ discard block |
||
164 | 164 | $user['gender'] = $user['gender'] == GENDER_UNKNOWN ? $gender : $user['gender']; |
165 | 165 | |
166 | 166 | try { |
167 | - if($user['birthday']) { |
|
167 | + if ($user['birthday']) { |
|
168 | 168 | throw new exception(); |
169 | 169 | } |
170 | 170 | |
171 | 171 | $user_birthday = sys_get_param_str_unsafe('user_birthday'); |
172 | - if(!$user_birthday || $user_birthday == $FMT_DATE) { |
|
172 | + if (!$user_birthday || $user_birthday == $FMT_DATE) { |
|
173 | 173 | throw new exception(); |
174 | 174 | } |
175 | 175 | |
@@ -179,16 +179,16 @@ discard block |
||
179 | 179 | $pos['Y'] = strpos(FMT_DATE, 'Y'); |
180 | 180 | asort($pos); |
181 | 181 | $i = 0; |
182 | - foreach($pos as &$position) { |
|
182 | + foreach ($pos as &$position) { |
|
183 | 183 | $position = ++$i; |
184 | 184 | } |
185 | 185 | |
186 | 186 | $regexp = "/" . preg_replace(array('/\\\\/', '/\//', '/\./', '/\-/', '/d/', '/m/', '/Y/'), array('\\\\\\', '\/', '\.', '\-', '(\d?\d)', '(\d?\d)', '(\d{4})'), FMT_DATE) . "/"; |
187 | - if(!preg_match($regexp, $user_birthday, $match)) { |
|
187 | + if (!preg_match($regexp, $user_birthday, $match)) { |
|
188 | 188 | throw new exception(); |
189 | 189 | } |
190 | 190 | |
191 | - if(!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) { |
|
191 | + if (!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) { |
|
192 | 192 | throw new exception(); |
193 | 193 | } |
194 | 194 | |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | // EOF black magic! Now we have valid SQL date in $user['user_birthday'] - independent of date format |
197 | 197 | |
198 | 198 | $year = date('Y', SN_TIME_NOW); |
199 | - if(mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) { |
|
199 | + if (mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) { |
|
200 | 200 | $year--; |
201 | 201 | } |
202 | 202 | $user['user_birthday_celebrated'] = db_escape("{$year}-{$match[$pos['m']]}-{$match[$pos['d']]}"); |
203 | 203 | |
204 | 204 | $user_birthday = ", `user_birthday` = '{$user['user_birthday']}', `user_birthday_celebrated` = '{$user['user_birthday_celebrated']}'"; |
205 | - } catch(exception $e) { |
|
205 | + } catch (exception $e) { |
|
206 | 206 | $user_birthday = ''; |
207 | 207 | } |
208 | 208 | |
@@ -212,14 +212,14 @@ discard block |
||
212 | 212 | $template_result['.']['result'][] = $avatar_upload_result; |
213 | 213 | |
214 | 214 | $user_time_diff = playerTimeDiff::user_time_diff_get(); |
215 | - if(sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) { |
|
215 | + if (sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) { |
|
216 | 216 | playerTimeDiff::user_time_diff_set(array( |
217 | 217 | PLAYER_OPTION_TIME_DIFF => sys_get_param_int('PLAYER_OPTION_TIME_DIFF'), |
218 | 218 | PLAYER_OPTION_TIME_DIFF_UTC_OFFSET => 0, |
219 | 219 | PLAYER_OPTION_TIME_DIFF_FORCED => 1, |
220 | 220 | PLAYER_OPTION_TIME_DIFF_MEASURE_TIME => SN_TIME_SQL, |
221 | 221 | )); |
222 | - } elseif(sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) { |
|
222 | + } elseif (sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) { |
|
223 | 223 | playerTimeDiff::user_time_diff_set(array( |
224 | 224 | PLAYER_OPTION_TIME_DIFF => '', |
225 | 225 | PLAYER_OPTION_TIME_DIFF_UTC_OFFSET => 0, |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | 'STATUS' => ERR_NONE, |
240 | 240 | 'MESSAGE' => classLocale::$lang['opt_msg_saved'] |
241 | 241 | ); |
242 | - } elseif(sys_get_param_str('result') == 'ok') { |
|
242 | + } elseif (sys_get_param_str('result') == 'ok') { |
|
243 | 243 | $template_result['.']['result'][] = array( |
244 | 244 | 'STATUS' => ERR_NONE, |
245 | 245 | 'MESSAGE' => classLocale::$lang['opt_msg_saved'] |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | $template = gettemplate('options', $template); |
264 | 264 | |
265 | 265 | $dir = dir(SN_ROOT_PHYSICAL . 'skins'); |
266 | - while(($entry = $dir->read()) !== false) { |
|
267 | - if(is_dir("skins/{$entry}") && $entry[0] != '.') { |
|
266 | + while (($entry = $dir->read()) !== false) { |
|
267 | + if (is_dir("skins/{$entry}") && $entry[0] != '.') { |
|
268 | 268 | $template_result['.']['skin_list'][] = array( |
269 | 269 | 'VALUE' => $entry, |
270 | 270 | 'NAME' => $entry, |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | } |
275 | 275 | $dir->close(); |
276 | 276 | |
277 | - foreach(classLocale::$lang['opt_planet_sort_options'] as $key => &$value) { |
|
277 | + foreach (classLocale::$lang['opt_planet_sort_options'] as $key => &$value) { |
|
278 | 278 | $template_result['.']['planet_sort_options'][] = array( |
279 | 279 | 'VALUE' => $key, |
280 | 280 | 'NAME' => $value, |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | ); |
283 | 283 | } |
284 | 284 | |
285 | - foreach(classLocale::$lang['sys_gender_list'] as $key => $value) { |
|
285 | + foreach (classLocale::$lang['sys_gender_list'] as $key => $value) { |
|
286 | 286 | $template_result['.']['gender_list'][] = array( |
287 | 287 | 'VALUE' => $key, |
288 | 288 | 'NAME' => $value, |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | } |
292 | 292 | |
293 | 293 | $lang_list = lng_get_list(); |
294 | - foreach($lang_list as $lang_id => $lang_data) { |
|
294 | + foreach ($lang_list as $lang_id => $lang_data) { |
|
295 | 295 | $template_result['.']['languages'][] = array( |
296 | 296 | 'VALUE' => $lang_id, |
297 | 297 | 'NAME' => $lang_data['LANG_NAME_NATIVE'], |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | |
303 | - if(isset(classLocale::$lang['menu_customize_show_hide_button_state'])) { |
|
304 | - foreach(classLocale::$lang['menu_customize_show_hide_button_state'] as $key => $value) { |
|
303 | + if (isset(classLocale::$lang['menu_customize_show_hide_button_state'])) { |
|
304 | + foreach (classLocale::$lang['menu_customize_show_hide_button_state'] as $key => $value) { |
|
305 | 305 | $template->assign_block_vars('menu_customize_show_hide_button_state', array( |
306 | 306 | 'ID' => $key, |
307 | 307 | 'NAME' => $value, |
@@ -408,10 +408,10 @@ discard block |
||
408 | 408 | 'PAGE_HEADER' => classLocale::$lang['opt_header'], |
409 | 409 | )); |
410 | 410 | |
411 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
412 | - if($option_group_id == OPT_MESSAGE) { |
|
413 | - foreach($sn_message_class_list as $message_class_id => $message_class_data) { |
|
414 | - if($message_class_data['switchable'] || ($message_class_data['email'] && classSupernova::$config->game_email_pm)) { |
|
411 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
412 | + if ($option_group_id == OPT_MESSAGE) { |
|
413 | + foreach ($sn_message_class_list as $message_class_id => $message_class_data) { |
|
414 | + if ($message_class_data['switchable'] || ($message_class_data['email'] && classSupernova::$config->game_email_pm)) { |
|
415 | 415 | $option_name = $message_class_data['name']; |
416 | 416 | |
417 | 417 | $template->assign_block_vars("options_{$option_group_id}", array( |
@@ -423,8 +423,8 @@ discard block |
||
423 | 423 | } |
424 | 424 | } |
425 | 425 | } else { |
426 | - foreach($option_group as $option_name => $option_value) { |
|
427 | - if(array_key_exists($option_name, $user_option_types)) { |
|
426 | + foreach ($option_group as $option_name => $option_value) { |
|
427 | + if (array_key_exists($option_name, $user_option_types)) { |
|
428 | 428 | $option_type = $user_option_types[$option_name]; |
429 | 429 | } else { |
430 | 430 | $option_type = 'switch'; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $user_auth_level = isset($user['authlevel']) ? $user['authlevel'] : AUTH_LEVEL_ANONYMOUS; |
37 | 37 | |
38 | 38 | $mode = sys_get_param_int('mode'); |
39 | - switch($mode) { |
|
39 | + switch ($mode) { |
|
40 | 40 | case CHAT_MODE_ALLY: |
41 | 41 | $template_result['ALLY'] = intval($user['ally_id']); |
42 | 42 | $page_title = classLocale::$lang['chat_ally']; |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | $template_result['.']['smiles'] = array(); |
52 | - foreach($supernova->design['smiles'] as $auth_level => $replaces) { |
|
53 | - if($auth_level > $user_auth_level) { |
|
52 | + foreach ($supernova->design['smiles'] as $auth_level => $replaces) { |
|
53 | + if ($auth_level > $user_auth_level) { |
|
54 | 54 | continue; |
55 | 55 | } |
56 | 56 | |
57 | - foreach($replaces as $bbcode => $filename) { |
|
57 | + foreach ($replaces as $bbcode => $filename) { |
|
58 | 58 | $template_result['.']['smiles'][] = array( |
59 | 59 | 'BBCODE' => $bbcode, |
60 | 60 | 'FILENAME' => $filename, |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | define('IN_AJAX', true); |
78 | 78 | $skip_fleet_update = true; |
79 | 79 | |
80 | - if(classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) { |
|
80 | + if (classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) { |
|
81 | 81 | die(); |
82 | 82 | } |
83 | 83 | |
84 | - if(($message = sys_get_param_str('message')) && $user['username']) { |
|
84 | + if (($message = sys_get_param_str('message')) && $user['username']) { |
|
85 | 85 | $ally_id = sys_get_param('ally') && $user['ally_id'] ? $user['ally_id'] : 0; |
86 | 86 | $nick = db_escape(player_nick_compact(player_nick_render_current_to_array($user, array('color' => true, 'icons' => true, 'ally' => !$ally_id)))); |
87 | 87 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $skip_fleet_update = true; |
104 | 104 | |
105 | 105 | $history = sys_get_param_str('history'); |
106 | - if(!$history) { |
|
106 | + if (!$history) { |
|
107 | 107 | classSupernova::$config->array_set('users', $user['id'], 'chat_last_refresh', SN_TIME_MICRO); |
108 | 108 | } |
109 | 109 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $last_message = ''; |
112 | 112 | $alliance = 0; |
113 | 113 | $template_result['.']['chat'] = array(); |
114 | - if(!$history && classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) { |
|
114 | + if (!$history && classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) { |
|
115 | 115 | $result['disable'] = true; |
116 | 116 | $template_result['.']['chat'][] = array( |
117 | 117 | 'TIME' => date(FMT_DATE_TIME, htmlentities(SN_CLIENT_TIME_LOCAL, ENT_QUOTES, 'utf-8')), |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | |
125 | 125 | $where_add = ''; |
126 | 126 | $last_message = 0; |
127 | - if($history) { |
|
127 | + if ($history) { |
|
128 | 128 | $rows = db_chat_message_count_by_ally($alliance); |
129 | 129 | $page_count = ceil($rows['CNT'] / $page_limit); |
130 | 130 | |
131 | - for($i = 0; $i < $page_count; $i++) { |
|
131 | + for ($i = 0; $i < $page_count; $i++) { |
|
132 | 132 | $template_result['.']['page'][] = array( |
133 | 133 | 'NUMBER' => $i |
134 | 134 | ); |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | |
143 | 143 | $start_row = $page * $page_limit; |
144 | 144 | $query = db_chat_message_get_page($alliance, $where_add, $start_row, $page_limit); |
145 | - while($chat_row = db_fetch($query)) { |
|
145 | + while ($chat_row = db_fetch($query)) { |
|
146 | 146 | // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick |
147 | 147 | $chat_row['user'] = player_nick_render_to_html($chat_row['user']); |
148 | 148 | $nick_stripped = htmlentities(strip_tags($chat_row['user']), ENT_QUOTES, 'utf-8'); |
149 | 149 | $nick = str_replace(strip_tags($chat_row['user']), $nick_stripped, $chat_row['user']); |
150 | - if(!$history) { |
|
150 | + if (!$history) { |
|
151 | 151 | $nick = "<span style=\"cursor: pointer;\" onclick=\"addSmiley('({$nick_stripped})');\">{$nick}</span>"; |
152 | 152 | } |
153 | 153 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $template = gettemplate('chat_messages', $template); |
173 | 173 | $template->assign_recursive($template_result); |
174 | 174 | |
175 | - if($history) { |
|
175 | + if ($history) { |
|
176 | 176 | display($template, "{$classLocale['chat_history']} - {$classLocale[$alliance ? 'chat_ally' : 'chat_common']}", true, '', false, true); |
177 | 177 | } else { |
178 | 178 | $result['last_message'] = $last_message; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function debris_add_resource($resource_id, $resource_amount) { |
32 | 32 | // В обломках может быть только металл или кристалл |
33 | - if($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) { |
|
33 | + if ($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) { |
|
34 | 34 | return; |
35 | 35 | } |
36 | 36 | $this->debris[$resource_id] += $resource_amount; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param bool $is_simulator |
42 | 42 | */ |
43 | 43 | public function add_wrecks(array $wreckage, $is_simulator) { |
44 | - foreach($wreckage as $resource_id => $resource_amount) { |
|
44 | + foreach ($wreckage as $resource_id => $resource_amount) { |
|
45 | 45 | $this->debris_add_resource($resource_id, floor($resource_amount * |
46 | 46 | ($is_simulator |
47 | 47 | ? UBE_SHIP_WRECKS_TO_DEBRIS_AVG |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param bool $is_simulator |
58 | 58 | */ |
59 | 59 | public function add_cargo_drop(array $dropped_resources, $is_simulator) { |
60 | - foreach($dropped_resources as $resource_id => $resource_amount) { |
|
60 | + foreach ($dropped_resources as $resource_id => $resource_amount) { |
|
61 | 61 | $this->debris_add_resource($resource_id, floor($resource_amount * |
62 | 62 | ($is_simulator |
63 | 63 | ? UBE_CARGO_DROPPED_TO_DEBRIS_AVG |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @param $moon_debris_left_part |
97 | 97 | */ |
98 | 98 | public function debris_adjust_proportional($moon_debris_left_part) { |
99 | - foreach($this->debris as $resource_id => &$resource_amount) { |
|
99 | + foreach ($this->debris as $resource_id => &$resource_amount) { |
|
100 | 100 | $resource_amount = floor($resource_amount * $moon_debris_left_part); |
101 | 101 | } |
102 | 102 | } |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function report_generate_sql() { |
119 | 119 | return " |
120 | - `ube_report_debris_metal` = " . (float)$this->debris_get_resource(RES_METAL) . ", |
|
121 | - `ube_report_debris_crystal` = " . (float)$this->debris_get_resource(RES_CRYSTAL) . ", |
|
122 | - `ube_report_debris_total_in_metal` = " . (float)$this->debris_in_metal() . ", "; |
|
120 | + `ube_report_debris_metal` = " . (float) $this->debris_get_resource(RES_METAL) . ", |
|
121 | + `ube_report_debris_crystal` = " . (float) $this->debris_get_resource(RES_CRYSTAL) . ", |
|
122 | + `ube_report_debris_total_in_metal` = " . (float) $this->debris_in_metal() . ", "; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |