@@ -47,20 +47,20 @@ discard block |
||
47 | 47 | )); |
48 | 48 | |
49 | 49 | $ActualProd = floor($Prod[$BuildID]); |
50 | - if($BuildID != STRUC_MINE_FUSION) { |
|
50 | + if ($BuildID != STRUC_MINE_FUSION) { |
|
51 | 51 | $ActualNeed = floor($Prod[STRUC_MINE_SOLAR]); |
52 | 52 | } else { |
53 | 53 | $ActualNeed = floor($Prod[STRUC_MINE_DEUTERIUM]); |
54 | 54 | } |
55 | 55 | |
56 | 56 | $BuildStartLvl = $CurrentBuildtLvl - 2; |
57 | - if($BuildStartLvl < 1) { |
|
57 | + if ($BuildStartLvl < 1) { |
|
58 | 58 | $BuildStartLvl = 1; |
59 | 59 | } |
60 | 60 | $Table = ''; |
61 | 61 | $ProdFirst = 0; |
62 | - for($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 10; $BuildLevel++) { |
|
63 | - if($BuildID != STRUC_MOON_PHALANX) { |
|
62 | + for ($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 10; $BuildLevel++) { |
|
63 | + if ($BuildID != STRUC_MOON_PHALANX) { |
|
64 | 64 | $Prod[STRUC_MINE_METAL] = floor(mrc_modify_value( |
65 | 65 | $CurrentUser, |
66 | 66 | $CurrentPlanet, |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | )); |
88 | 88 | |
89 | 89 | $bloc['build_lvl'] = ($CurrentBuildtLvl == $BuildLevel) ? "<font color=\"#ff0000\">" . $BuildLevel . "</font>" : $BuildLevel; |
90 | - if($ProdFirst > 0) { |
|
91 | - if($BuildID != STRUC_MINE_FUSION) { |
|
90 | + if ($ProdFirst > 0) { |
|
91 | + if ($BuildID != STRUC_MINE_FUSION) { |
|
92 | 92 | $bloc['build_gain'] = "<font color=\"lime\">(" . pretty_number(floor($Prod[$BuildID] - $ProdFirst)) . ")</font>"; |
93 | 93 | } else { |
94 | 94 | $bloc['build_gain'] = "<font color=\"lime\">(" . pretty_number(floor($Prod[STRUC_MINE_SOLAR] - $ProdFirst)) . ")</font>"; |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } else { |
97 | 97 | $bloc['build_gain'] = ''; |
98 | 98 | } |
99 | - if($BuildID != STRUC_MINE_FUSION) { |
|
99 | + if ($BuildID != STRUC_MINE_FUSION) { |
|
100 | 100 | $bloc['build_prod'] = pretty_number(floor($Prod[$BuildID])); |
101 | 101 | $bloc['build_prod_diff'] = pretty_number(floor($Prod[$BuildID] - $ActualProd), true, true); |
102 | 102 | $bloc['build_need'] = pretty_number(floor($Prod[STRUC_MINE_SOLAR]), true, true); |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | $bloc['build_need'] = pretty_number(floor($Prod[STRUC_MINE_DEUTERIUM]), true, true); |
108 | 108 | $bloc['build_need_diff'] = pretty_number(floor($Prod[STRUC_MINE_DEUTERIUM] - $ActualNeed), true, true); |
109 | 109 | } |
110 | - if($ProdFirst == 0) { |
|
111 | - if($BuildID != STRUC_MINE_FUSION) { |
|
110 | + if ($ProdFirst == 0) { |
|
111 | + if ($BuildID != STRUC_MINE_FUSION) { |
|
112 | 112 | $ProdFirst = floor($Prod[$BuildID]); |
113 | 113 | } else { |
114 | 114 | $ProdFirst = floor($Prod[STRUC_MINE_SOLAR]); |
@@ -133,22 +133,22 @@ discard block |
||
133 | 133 | |
134 | 134 | $str_rapid_from = ''; |
135 | 135 | $str_rapid_to = ''; |
136 | - foreach(sn_get_groups(array('fleet', 'defense_active')) as $enemy_id) { |
|
136 | + foreach (sn_get_groups(array('fleet', 'defense_active')) as $enemy_id) { |
|
137 | 137 | $enemy_data = get_unit_param($enemy_id); |
138 | 138 | $enemy_durability = $enemy_data['shield'] + $enemy_data['armor']; |
139 | 139 | |
140 | 140 | $rapid = floor($unit_data['attack'] * (isset($unit_data['amplify'][$enemy_id]) ? $unit_data['amplify'][$enemy_id] : 1) / $enemy_durability); |
141 | - if($rapid >= 1) { |
|
141 | + if ($rapid >= 1) { |
|
142 | 142 | $str_rapid_to .= "{$classLocale['nfo_rf_again']} {$classLocale['tech'][$enemy_id]} <font color=\"#00ff00\">{$rapid}</font><br>"; |
143 | 143 | } |
144 | 144 | |
145 | 145 | $rapid = floor($enemy_data['attack'] * (isset($enemy_data['amplify'][$unit_id]) ? $enemy_data['amplify'][$unit_id] : 1) / $unit_durability); |
146 | - if($rapid >= 1) { |
|
146 | + if ($rapid >= 1) { |
|
147 | 147 | $str_rapid_from .= "{$classLocale['tech'][$enemy_id]} {$classLocale['nfo_rf_from']} <font color=\"#ff0000\">{$rapid}</font><br>"; |
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | - if($str_rapid_to && $str_rapid_from) { |
|
151 | + if ($str_rapid_to && $str_rapid_from) { |
|
152 | 152 | $str_rapid_to .= '<hr>'; |
153 | 153 | } |
154 | 154 | |
@@ -156,16 +156,16 @@ discard block |
||
156 | 156 | } |
157 | 157 | |
158 | 158 | $unit_id = sys_get_param_id('gid'); |
159 | -if($unit_id == RES_DARK_MATTER) { |
|
159 | +if ($unit_id == RES_DARK_MATTER) { |
|
160 | 160 | sys_redirect('dark_matter.php'); |
161 | 161 | } |
162 | 162 | |
163 | -if($unit_id == RES_METAMATTER) { |
|
163 | +if ($unit_id == RES_METAMATTER) { |
|
164 | 164 | sys_redirect('metamatter.php'); |
165 | 165 | } |
166 | 166 | |
167 | 167 | lng_include('infos'); |
168 | -if(!$unit_id || (!get_unit_param($unit_id) && !isset(classLocale::$lang['info'][$unit_id]))) { |
|
168 | +if (!$unit_id || (!get_unit_param($unit_id) && !isset(classLocale::$lang['info'][$unit_id]))) { |
|
169 | 169 | sys_redirect('index.php?page=techtree'); |
170 | 170 | } |
171 | 171 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $unit_data = get_unit_param($unit_id); |
175 | 175 | $unit_type = $unit_data['type']; |
176 | 176 | |
177 | -if($unit_type == UNIT_SHIPS) { |
|
177 | +if ($unit_type == UNIT_SHIPS) { |
|
178 | 178 | $template_result['UNIT_IS_SHIP'] = true; |
179 | 179 | |
180 | 180 | $ship_data = get_ship_data($unit_id, $user); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | ); |
191 | 191 | |
192 | 192 | $engine_template_info = array(); |
193 | - foreach($unit_data['engine'] as $unit_engine_data) { |
|
193 | + foreach ($unit_data['engine'] as $unit_engine_data) { |
|
194 | 194 | $unit_engine_data = get_engine_data($user, $unit_engine_data); |
195 | 195 | |
196 | 196 | $engine_template_info[] = array( |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | |
211 | 211 | $sn_data_group_combat = sn_get_groups('combat'); |
212 | -if(in_array($unit_id, $sn_data_group_combat)) { |
|
212 | +if (in_array($unit_id, $sn_data_group_combat)) { |
|
213 | 213 | $template_result['UNIT_IS_COMBAT'] = true; |
214 | 214 | |
215 | 215 | $unit_durability = $unit_data['shield'] + $unit_data['armor']; |
@@ -217,21 +217,21 @@ discard block |
||
217 | 217 | $volley_arr = $rapid_to = $rapid_from = array(); |
218 | 218 | $str_rapid_from = ''; |
219 | 219 | $str_rapid_to = ''; |
220 | - foreach($sn_data_group_combat as $enemy_id) { |
|
220 | + foreach ($sn_data_group_combat as $enemy_id) { |
|
221 | 221 | $enemy_data = get_unit_param($enemy_id); |
222 | 222 | $enemy_durability = $enemy_data['shield'] + $enemy_data['armor']; |
223 | 223 | |
224 | 224 | $rapid = $unit_data['attack'] * (isset($unit_data['amplify'][$enemy_id]) ? $unit_data['amplify'][$enemy_id] : 1) / $enemy_durability; |
225 | - if($rapid >= 1) { |
|
225 | + if ($rapid >= 1) { |
|
226 | 226 | $volley_arr[$enemy_id]['TO'] = floor($rapid); |
227 | 227 | } |
228 | 228 | |
229 | 229 | $rapid = $enemy_data['attack'] * (isset($enemy_data['amplify'][$unit_id]) ? $enemy_data['amplify'][$unit_id] : 1) / $unit_durability; |
230 | - if($rapid >= 1) { |
|
230 | + if ($rapid >= 1) { |
|
231 | 231 | $volley_arr[$enemy_id]['FROM'] = floor($rapid); |
232 | 232 | } |
233 | 233 | } |
234 | - foreach($volley_arr as $enemy_id => &$rapid) { |
|
234 | + foreach ($volley_arr as $enemy_id => &$rapid) { |
|
235 | 235 | $rapid['ENEMY_ID'] = $enemy_id; |
236 | 236 | $rapid['ENEMY_NAME'] = classLocale::$lang['tech'][$enemy_id]; |
237 | 237 | } |
@@ -249,11 +249,11 @@ discard block |
||
249 | 249 | |
250 | 250 | } |
251 | 251 | |
252 | -if(classLocale::$lang['info'][$unit_id]['effect']) { |
|
252 | +if (classLocale::$lang['info'][$unit_id]['effect']) { |
|
253 | 253 | $template_result['UNIT_EFFECT'] = classLocale::$lang['info'][$unit_id]['effect']; |
254 | 254 | } |
255 | 255 | |
256 | -if($unit_data['bonus']) { |
|
256 | +if ($unit_data['bonus']) { |
|
257 | 257 | $unit_bonus = !$unit_data['bonus'] || $unit_data['bonus_type'] == BONUS_ABILITY ? '' : ( |
258 | 258 | ($unit_data['bonus'] >= 0 ? '+' : '') . $unit_data['bonus'] . ($unit_data['bonus_type'] == BONUS_PERCENT ? '%' : '') |
259 | 259 | ); |
@@ -171,6 +171,10 @@ discard block |
||
171 | 171 | * @return bool |
172 | 172 | */ |
173 | 173 | // OK v4.5 |
174 | + |
|
175 | + /** |
|
176 | + * @param string $account_name_unsafe |
|
177 | + */ |
|
174 | 178 | public function db_get_by_name($account_name_unsafe) { |
175 | 179 | $this->reset(); |
176 | 180 | |
@@ -207,6 +211,11 @@ discard block |
||
207 | 211 | * |
208 | 212 | */ |
209 | 213 | // OK v4.5 |
214 | + |
|
215 | + /** |
|
216 | + * @param string $account_name_unsafe |
|
217 | + * @param string $email_unsafe |
|
218 | + */ |
|
210 | 219 | public function db_get_by_name_or_email($account_name_unsafe, $email_unsafe) { |
211 | 220 | $this->reset(); |
212 | 221 | |
@@ -223,6 +232,13 @@ discard block |
||
223 | 232 | * @throws Exception |
224 | 233 | */ |
225 | 234 | // OK v4.5 |
235 | + |
|
236 | + /** |
|
237 | + * @param string $account_name_unsafe |
|
238 | + * @param string $password_raw |
|
239 | + * @param string $email_unsafe |
|
240 | + * @param string $language_unsafe |
|
241 | + */ |
|
226 | 242 | public function db_create($account_name_unsafe, $password_raw, $email_unsafe, $language_unsafe = null, $salt_unsafe = null) { |
227 | 243 | $this->reset(); |
228 | 244 | |
@@ -317,6 +333,11 @@ discard block |
||
317 | 333 | * @return int|string |
318 | 334 | */ |
319 | 335 | // OK 4.8 |
336 | + |
|
337 | + /** |
|
338 | + * @param integer $change_type |
|
339 | + * @param double $metamatter |
|
340 | + */ |
|
320 | 341 | protected function db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe) { |
321 | 342 | $provider_id_safe = intval(core_auth::$main_provider->provider_id); |
322 | 343 | //$account_id_safe = $this->db->db_escape($this->account_id); |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | $this->reset(); |
80 | 80 | $this->db = is_object($db) ? $db : classSupernova::$db; |
81 | 81 | |
82 | - foreach($this->table_check as $table_name) { |
|
83 | - if(empty($this->db->table_list[$table_name])) { |
|
82 | + foreach ($this->table_check as $table_name) { |
|
83 | + if (empty($this->db->table_list[$table_name])) { |
|
84 | 84 | die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br /> |
85 | 85 | В противном случае - сообщите Администрации сервера об ошибке.<br/> |
86 | 86 | Не хватает таблицы для работы системы авторизации: ' . $table_name); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | // OK v4.6 |
106 | 106 | public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) { |
107 | - if(!$this->password_check($old_password_unsafe)) { |
|
107 | + if (!$this->password_check($old_password_unsafe)) { |
|
108 | 108 | return false; |
109 | 109 | } |
110 | 110 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | // OK v4.5 |
126 | 126 | public function assign_from_db_row($row) { |
127 | 127 | $this->reset(); |
128 | - if(empty($row) || !is_array($row)) { |
|
128 | + if (empty($row) || !is_array($row)) { |
|
129 | 129 | return false; |
130 | 130 | } |
131 | 131 | $this->account_id = $row['account_id']; |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | `account_email` = LOWER('{$email_safe}'), |
243 | 243 | `account_language` = '{$language_safe}'" |
244 | 244 | ); |
245 | - if(!$result) { |
|
245 | + if (!$result) { |
|
246 | 246 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
247 | 247 | } |
248 | 248 | |
249 | - if(!($account_id = $this->db->db_insert_id())) { |
|
249 | + if (!($account_id = $this->db->db_insert_id())) { |
|
250 | 250 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
251 | 251 | } |
252 | 252 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | WHERE `account_id` = '{$account_id_safe}'" |
277 | 277 | ) ? true : false; |
278 | 278 | |
279 | - if($result) { |
|
279 | + if ($result) { |
|
280 | 280 | $result = $this->db_get_by_id($this->account_id); |
281 | 281 | } |
282 | 282 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | public function metamatter_change($change_type, $metamatter, $comment = '', $already_changed = false) { |
364 | 364 | global $debug, $mm_change_legit; |
365 | 365 | |
366 | - if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
366 | + if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
367 | 367 | $debug->error('Ошибка при попытке манипуляции с ММ'); |
368 | 368 | |
369 | 369 | return false; |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | |
374 | 374 | $mm_change_legit = true; |
375 | 375 | // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER); |
376 | - if($already_changed) { |
|
376 | + if ($already_changed) { |
|
377 | 377 | $metamatter_total_delta = 0; |
378 | 378 | $result = -1; |
379 | 379 | } else { |
@@ -387,13 +387,13 @@ discard block |
||
387 | 387 | ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$classConfig->player_metamatter_immortal}, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '') . |
388 | 388 | " WHERE `account_id` = {$account_id_safe}" |
389 | 389 | ); |
390 | - if(!$result) { |
|
390 | + if (!$result) { |
|
391 | 391 | $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
392 | 392 | } |
393 | 393 | $result = classSupernova::$db->db_affected_rows(); |
394 | 394 | } |
395 | 395 | |
396 | - if(empty(core_auth::$user['id'])) { |
|
396 | + if (empty(core_auth::$user['id'])) { |
|
397 | 397 | $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id); |
398 | 398 | reset($user_list); |
399 | 399 | $user_id_unsafe = key($user_list); |
@@ -402,30 +402,30 @@ discard block |
||
402 | 402 | } |
403 | 403 | $user_id_safe = $this->db->db_escape($user_id_unsafe); |
404 | 404 | |
405 | - if(!$result) { |
|
405 | + if (!$result) { |
|
406 | 406 | $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
407 | 407 | } |
408 | 408 | |
409 | - if(!$already_changed) { |
|
409 | + if (!$already_changed) { |
|
410 | 410 | $this->account_metamatter += $metamatter; |
411 | 411 | $this->account_metamatter_total += $metamatter_total_delta; |
412 | 412 | } |
413 | 413 | |
414 | - if(is_array($comment)) { |
|
414 | + if (is_array($comment)) { |
|
415 | 415 | $comment = call_user_func_array('sprintf', $comment); |
416 | 416 | } |
417 | 417 | |
418 | 418 | $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe); |
419 | 419 | |
420 | - if($metamatter > 0 && !empty($user_id_safe)) { |
|
420 | + if ($metamatter > 0 && !empty($user_id_safe)) { |
|
421 | 421 | $old_referral = db_referral_get_by_id($user_id_safe); |
422 | - if($old_referral['id']) { |
|
422 | + if ($old_referral['id']) { |
|
423 | 423 | $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM; |
424 | 424 | db_referral_update_dm($user_id_safe, $dark_matter_from_metamatter); |
425 | 425 | $new_referral = db_referral_get_by_id($user_id_safe); |
426 | 426 | |
427 | 427 | $partner_bonus = floor($new_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) : 0); |
428 | - if($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) { |
|
428 | + if ($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) { |
|
429 | 429 | rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}"); |
430 | 430 | } |
431 | 431 | } |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | 'factor' => 1.5, |
16 | 16 | ), |
17 | 17 | P_UNIT_PRODUCTION => array( |
18 | - RES_METAL => function ($level, $production_factor, $user, $planet_row) {return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
19 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
18 | + RES_METAL => function($level, $production_factor, $user, $planet_row) {return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
19 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
20 | 20 | ), |
21 | 21 | P_MINING_IS_MANAGED => true, |
22 | 22 | ), |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | 'factor' => 1.6, |
34 | 34 | ), |
35 | 35 | P_UNIT_PRODUCTION => array( |
36 | - RES_CRYSTAL => function ($level, $production_factor, $user, $planet_row) {return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
37 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
36 | + RES_CRYSTAL => function($level, $production_factor, $user, $planet_row) {return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
37 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
38 | 38 | ), |
39 | 39 | P_MINING_IS_MANAGED => true, |
40 | 40 | ), |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | 'factor' => 1.5, |
52 | 52 | ), |
53 | 53 | P_UNIT_PRODUCTION => array( |
54 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) {return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28);}, |
|
55 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
54 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) {return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28); }, |
|
55 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
56 | 56 | ), |
57 | 57 | P_MINING_IS_MANAGED => true, |
58 | 58 | ), |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | 'factor' => 1.5, |
70 | 70 | ), |
71 | 71 | P_UNIT_PRODUCTION => array( |
72 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
72 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
73 | 73 | ), |
74 | 74 | P_MINING_IS_MANAGED => true, |
75 | 75 | ), |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | 'factor' => 1.8, |
88 | 88 | ), |
89 | 89 | P_UNIT_PRODUCTION => array( |
90 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
91 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, null, TECH_ENERGY), $level) * (0.1 * $production_factor);}, |
|
90 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
91 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, null, TECH_ENERGY), $level) * (0.1 * $production_factor); }, |
|
92 | 92 | ), |
93 | 93 | P_MINING_IS_MANAGED => true, |
94 | 94 | ), |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | 'factor' => 2, |
106 | 106 | ), |
107 | 107 | 'storage' => array( |
108 | - RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
108 | + RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
109 | 109 | ), |
110 | 110 | ), |
111 | 111 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | 'factor' => 2, |
122 | 122 | ), |
123 | 123 | 'storage' => array( |
124 | - RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
124 | + RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
125 | 125 | ), |
126 | 126 | ), |
127 | 127 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | 'factor' => 2, |
138 | 138 | ), |
139 | 139 | 'storage' => array( |
140 | - RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
140 | + RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
141 | 141 | ), |
142 | 142 | ), |
143 | 143 |
@@ -81,6 +81,10 @@ discard block |
||
81 | 81 | // ------------------------------------------------------------------------- |
82 | 82 | // Here comes low-level functions - those that directly works with cacher engines |
83 | 83 | // ------------------------------------------------------------------------- |
84 | + |
|
85 | + /** |
|
86 | + * @param string $name |
|
87 | + */ |
|
84 | 88 | public function __set($name, $value) { |
85 | 89 | switch ($name) { |
86 | 90 | case '_MODE': |
@@ -132,6 +136,9 @@ discard block |
||
132 | 136 | return null; |
133 | 137 | } |
134 | 138 | |
139 | + /** |
|
140 | + * @param string $name |
|
141 | + */ |
|
135 | 142 | public function __isset($name) { |
136 | 143 | switch (self::$mode) { |
137 | 144 | case CACHER_NO_CACHE: |
@@ -46,19 +46,19 @@ discard block |
||
46 | 46 | protected static $cacheObject; |
47 | 47 | |
48 | 48 | public function __construct($prefIn = 'CACHE_', $init_mode = false) { |
49 | - if(!($init_mode === false || $init_mode === CACHER_NO_CACHE || ($init_mode === CACHER_XCACHE && extension_loaded('xcache')))) { |
|
49 | + if (!($init_mode === false || $init_mode === CACHER_NO_CACHE || ($init_mode === CACHER_XCACHE && extension_loaded('xcache')))) { |
|
50 | 50 | throw new UnexpectedValueException('Wrong work mode or current mode does not supported on your server'); |
51 | 51 | } |
52 | 52 | |
53 | 53 | $this->prefix = $prefIn; |
54 | - if(extension_loaded('xcache') && ($init_mode === CACHER_XCACHE || $init_mode === false)) { |
|
55 | - if(self::$mode === CACHER_NOT_INIT) { |
|
54 | + if (extension_loaded('xcache') && ($init_mode === CACHER_XCACHE || $init_mode === false)) { |
|
55 | + if (self::$mode === CACHER_NOT_INIT) { |
|
56 | 56 | self::$mode = CACHER_XCACHE; |
57 | 57 | } |
58 | 58 | } else { |
59 | - if(self::$mode === CACHER_NOT_INIT) { |
|
59 | + if (self::$mode === CACHER_NOT_INIT) { |
|
60 | 60 | self::$mode = CACHER_NO_CACHE; |
61 | - if(!self::$data) { |
|
61 | + if (!self::$data) { |
|
62 | 62 | self::$data = array(); |
63 | 63 | } |
64 | 64 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | public static function getInstance($prefIn = 'CACHE_', $table_name = '') { |
69 | - if(!isset(self::$cacheObject)) { |
|
69 | + if (!isset(self::$cacheObject)) { |
|
70 | 70 | $className = get_class(); |
71 | 71 | self::$cacheObject = new $className($prefIn); |
72 | 72 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | // Here comes low-level functions - those that directly works with cacher engines |
84 | 84 | // ------------------------------------------------------------------------- |
85 | 85 | public function __set($name, $value) { |
86 | - switch($name) { |
|
86 | + switch ($name) { |
|
87 | 87 | case '_MODE': |
88 | 88 | throw new UnexpectedValueException('You can not change cacher mode on-the-fly!'); |
89 | 89 | break; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | break; |
94 | 94 | |
95 | 95 | default: |
96 | - switch(self::$mode) { |
|
96 | + switch (self::$mode) { |
|
97 | 97 | case CACHER_NO_CACHE: |
98 | 98 | self::$data[$this->prefix . $name] = $value; |
99 | 99 | break; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | public function __get($name) { |
110 | - switch($name) { |
|
110 | + switch ($name) { |
|
111 | 111 | case '_MODE': |
112 | 112 | return self::$mode; |
113 | 113 | break; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | break; |
118 | 118 | |
119 | 119 | default: |
120 | - switch(self::$mode) { |
|
120 | + switch (self::$mode) { |
|
121 | 121 | case CACHER_NO_CACHE: |
122 | 122 | return self::$data[$this->prefix . $name]; |
123 | 123 | break; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | } |
135 | 135 | |
136 | 136 | public function __isset($name) { |
137 | - switch(self::$mode) { |
|
137 | + switch (self::$mode) { |
|
138 | 138 | case CACHER_NO_CACHE: |
139 | 139 | return isset(self::$data[$this->prefix . $name]); |
140 | 140 | break; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | public function __unset($name) { |
151 | - switch(self::$mode) { |
|
151 | + switch (self::$mode) { |
|
152 | 152 | case CACHER_NO_CACHE: |
153 | 153 | unset(self::$data[$this->prefix . $name]); |
154 | 154 | break; |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | |
162 | 162 | public function unset_by_prefix($prefix_unset = '') { |
163 | 163 | static $array_clear; |
164 | - !$array_clear ? $array_clear = function (&$v, $k, $p) { |
|
164 | + !$array_clear ? $array_clear = function(&$v, $k, $p) { |
|
165 | 165 | strpos($k, $p) === 0 ? $v = null : false; |
166 | 166 | } : false; |
167 | 167 | |
168 | - switch(self::$mode) { |
|
168 | + switch (self::$mode) { |
|
169 | 169 | case CACHER_NO_CACHE: |
170 | 170 | // array_walk(self::$data, create_function('&$v,$k,$p', 'if(strpos($k, $p) === 0)$v = NULL;'), $this->prefix.$prefix_unset); |
171 | 171 | array_walk(self::$data, $array_clear, $this->prefix . $prefix_unset); |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | break; |
175 | 175 | |
176 | 176 | case CACHER_XCACHE: |
177 | - if(!function_exists('xcache_unset_by_prefix')) { |
|
177 | + if (!function_exists('xcache_unset_by_prefix')) { |
|
178 | 178 | return false; |
179 | 179 | } |
180 | 180 | |
@@ -191,13 +191,13 @@ discard block |
||
191 | 191 | protected function make_element_name($args, $diff = 0) { |
192 | 192 | $num_args = count($args); |
193 | 193 | |
194 | - if($num_args < 1) { |
|
194 | + if ($num_args < 1) { |
|
195 | 195 | return false; |
196 | 196 | } |
197 | 197 | |
198 | 198 | $name = ''; |
199 | 199 | $aName = array(); |
200 | - for($i = 0; $i <= $num_args - 1 - $diff; $i++) { |
|
200 | + for ($i = 0; $i <= $num_args - 1 - $diff; $i++) { |
|
201 | 201 | $name .= "[{$args[$i]}]"; |
202 | 202 | array_unshift($aName, $name); |
203 | 203 | } |
@@ -209,15 +209,15 @@ discard block |
||
209 | 209 | $args = func_get_args(); |
210 | 210 | $name = $this->make_element_name($args, 1); |
211 | 211 | |
212 | - if(!$name) { |
|
212 | + if (!$name) { |
|
213 | 213 | return null; |
214 | 214 | } |
215 | 215 | |
216 | - if($this->$name[0] === null) { |
|
217 | - for($i = count($name) - 1; $i > 0; $i--) { |
|
216 | + if ($this->$name[0] === null) { |
|
217 | + for ($i = count($name) - 1; $i > 0; $i--) { |
|
218 | 218 | $cName = "{$name[$i]}_COUNT"; |
219 | - $cName1 = "{$name[$i-1]}_COUNT"; |
|
220 | - if($this->$cName1 == null || $i == 1) { |
|
219 | + $cName1 = "{$name[$i - 1]}_COUNT"; |
|
220 | + if ($this->$cName1 == null || $i == 1) { |
|
221 | 221 | $this->$cName++; |
222 | 222 | } |
223 | 223 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | public function array_get() { |
232 | 232 | $name = $this->make_element_name(func_get_args()); |
233 | - if(!$name) { |
|
233 | + if (!$name) { |
|
234 | 234 | return null; |
235 | 235 | } |
236 | 236 | |
@@ -239,12 +239,12 @@ discard block |
||
239 | 239 | |
240 | 240 | public function array_count() { |
241 | 241 | $name = $this->make_element_name(func_get_args()); |
242 | - if(!$name) { |
|
242 | + if (!$name) { |
|
243 | 243 | return 0; |
244 | 244 | } |
245 | 245 | $cName = "{$name[0]}_COUNT"; |
246 | 246 | $retVal = $this->$cName; |
247 | - if(!$retVal) { |
|
247 | + if (!$retVal) { |
|
248 | 248 | $retVal = null; |
249 | 249 | } |
250 | 250 | |
@@ -254,18 +254,18 @@ discard block |
||
254 | 254 | public function array_unset() { |
255 | 255 | $name = $this->make_element_name(func_get_args()); |
256 | 256 | |
257 | - if(!$name) { |
|
257 | + if (!$name) { |
|
258 | 258 | return false; |
259 | 259 | } |
260 | 260 | $this->unset_by_prefix($name[0]); |
261 | 261 | |
262 | - for($i = 1; $i < count($name); $i++) { |
|
262 | + for ($i = 1; $i < count($name); $i++) { |
|
263 | 263 | $cName = "{$name[$i]}_COUNT"; |
264 | - $cName1 = "{$name[$i-1]}_COUNT"; |
|
264 | + $cName1 = "{$name[$i - 1]}_COUNT"; |
|
265 | 265 | |
266 | - if($i == 1 || $this->$cName1 === null) { |
|
266 | + if ($i == 1 || $this->$cName1 === null) { |
|
267 | 267 | $this->$cName--; |
268 | - if($this->$cName <= 0) { |
|
268 | + if ($this->$cName <= 0) { |
|
269 | 269 | unset($this->$cName); |
270 | 270 | } |
271 | 271 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | } |
276 | 276 | |
277 | 277 | public function dumpData() { |
278 | - switch(self::$mode) { |
|
278 | + switch (self::$mode) { |
|
279 | 279 | case CACHER_NO_CACHE: |
280 | 280 | return dump(self::$data, $this->prefix); |
281 | 281 | break; |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | $this->sql_index_field = "{$table_name}_name"; |
327 | 327 | $this->sql_value_field = "{$table_name}_value"; |
328 | 328 | |
329 | - if(!$this->_DB_LOADED) { |
|
329 | + if (!$this->_DB_LOADED) { |
|
330 | 330 | $this->db_loadAll(); |
331 | 331 | } |
332 | 332 | } |
333 | 333 | |
334 | 334 | public static function getInstance($gamePrefix = 'sn_', $table_name = '') { |
335 | - if(!isset(self::$cacheObject)) { |
|
335 | + if (!isset(self::$cacheObject)) { |
|
336 | 336 | $className = get_class(); |
337 | 337 | self::$cacheObject = new $className($gamePrefix, $table_name); |
338 | 338 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | |
343 | 343 | public function db_loadItem($index) { |
344 | 344 | $result = null; |
345 | - if($index) { |
|
345 | + if ($index) { |
|
346 | 346 | $index_safe = db_escape($index); |
347 | 347 | $result = doquery("SELECT `{$this->sql_value_field}` FROM `{{{$this->table_name}}}` WHERE `{$this->sql_index_field}` = '{$index_safe}' FOR UPDATE", true); |
348 | 348 | // В две строки - что бы быть уверенным в порядке выполнения |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | $this->loadDefaults(); |
358 | 358 | |
359 | 359 | $query = doquery("SELECT * FROM {{{$this->table_name}}} FOR UPDATE;"); |
360 | - while($row = db_fetch($query)) { |
|
360 | + while ($row = db_fetch($query)) { |
|
361 | 361 | $this->$row[$this->sql_index_field] = $row[$this->sql_value_field]; |
362 | 362 | } |
363 | 363 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | } |
366 | 366 | |
367 | 367 | public function loadDefaults() { |
368 | - foreach($this->defaults as $defName => $defValue) { |
|
368 | + foreach ($this->defaults as $defName => $defValue) { |
|
369 | 369 | $this->$defName = $defValue; |
370 | 370 | } |
371 | 371 | } |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | } |
382 | 382 | |
383 | 383 | public function db_saveItem($item_list, $value = null) { |
384 | - if(empty($item_list)) { |
|
384 | + if (empty($item_list)) { |
|
385 | 385 | return; |
386 | 386 | } |
387 | 387 | |
@@ -389,8 +389,8 @@ discard block |
||
389 | 389 | |
390 | 390 | // Сначала записываем данные в базу - что бы поймать все блокировки |
391 | 391 | $qry = array(); |
392 | - foreach($item_list as $item_name => $item_value) { |
|
393 | - if($item_name) { |
|
392 | + foreach ($item_list as $item_name => $item_value) { |
|
393 | + if ($item_name) { |
|
394 | 394 | $item_value = db_escape($item_value === null ? $this->$item_name : $item_value); |
395 | 395 | $item_name = db_escape($item_name); |
396 | 396 | $qry[] = "('{$item_name}', '{$item_value}')"; |
@@ -399,8 +399,8 @@ discard block |
||
399 | 399 | doquery("REPLACE INTO `{{" . $this->table_name . "}}` (`{$this->sql_index_field}`, `{$this->sql_value_field}`) VALUES " . implode(',', $qry) . ";"); |
400 | 400 | |
401 | 401 | // И только после взятия блокировок - меняем значения в кэше |
402 | - foreach($item_list as $item_name => $item_value) { |
|
403 | - if($item_name && $item_value !== null) { |
|
402 | + foreach ($item_list as $item_name => $item_value) { |
|
403 | + if ($item_name && $item_value !== null) { |
|
404 | 404 | $this->$item_name = $item_value; |
405 | 405 | } |
406 | 406 | } |
@@ -587,9 +587,9 @@ discard block |
||
587 | 587 | 'advGoogleLeftMenuCode' => '(Place here code for banner)', |
588 | 588 | |
589 | 589 | // Alliance bonus calculations |
590 | - 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
590 | + 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
591 | 591 | 'ali_bonus_brackets' => 10, // Brackets count for ALI_BONUS_BY_RANK |
592 | - 'ali_bonus_brackets_divisor' => 10,// Bonus divisor for ALI_BONUS_BY_RANK |
|
592 | + 'ali_bonus_brackets_divisor' => 10, // Bonus divisor for ALI_BONUS_BY_RANK |
|
593 | 593 | 'ali_bonus_divisor' => 10000000, // Rank divisor for ALI_BONUS_BY_POINTS |
594 | 594 | 'ali_bonus_members' => 10, // Minumum alliace size to start using bonus |
595 | 595 | |
@@ -620,25 +620,25 @@ discard block |
||
620 | 620 | 'deuterium_basic_income' => 0, |
621 | 621 | 'eco_scale_storage' => 1, |
622 | 622 | 'eco_stockman_fleet' => '', // Black Market - Starting amount of s/h ship merchant to sell |
623 | - 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
623 | + 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
624 | 624 | 'empire_mercenary_base_period' => PERIOD_MONTH, // Base |
625 | 625 | 'empire_mercenary_temporary' => 0, // Temporary empire-wide mercenaries |
626 | 626 | 'energy_basic_income' => 0, |
627 | 627 | |
628 | 628 | // Bashing protection settings |
629 | - 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
630 | - 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
631 | - 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
632 | - 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
633 | - 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
629 | + 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
630 | + 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
631 | + 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
632 | + 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
633 | + 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
634 | 634 | |
635 | 635 | 'Fleet_Cdr' => 30, |
636 | 636 | 'fleet_speed' => 1, |
637 | 637 | |
638 | 638 | 'fleet_update_interval' => 4, |
639 | 639 | |
640 | - 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
641 | - 'game_counter' => 0, // Does built-in page hit counter is on? |
|
640 | + 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
641 | + 'game_counter' => 0, // Does built-in page hit counter is on? |
|
642 | 642 | // Defaults |
643 | 643 | 'game_default_language' => 'ru', |
644 | 644 | 'game_default_skin' => 'skins/EpicBlue/', |
@@ -652,13 +652,13 @@ discard block |
||
652 | 652 | 'game_maxSystem' => 199, |
653 | 653 | 'game_maxPlanet' => 15, |
654 | 654 | // Game global settings |
655 | - 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
655 | + 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
656 | 656 | 'game_name' => 'SuperNova', // Server name (would be on banners and on top of left menu) |
657 | 657 | |
658 | 658 | 'game_news_actual' => 259200, // How long announcement would be marked as "New". In seconds. Default - 3 days |
659 | - 'game_news_overview' => 3, // How much last news to show in Overview page |
|
659 | + 'game_news_overview' => 3, // How much last news to show in Overview page |
|
660 | 660 | // Noob protection |
661 | - 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
661 | + 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
662 | 662 | 'game_noob_points' => 5000, // Below this point user threated as noob. 0 to disable |
663 | 663 | |
664 | 664 | 'game_multiaccount_enabled' => 0, // 1 - allow interactions for players with same IP (multiaccounts) |
@@ -707,8 +707,8 @@ discard block |
||
707 | 707 | 'payment_currency_exchange_wmu' => 30, |
708 | 708 | 'payment_currency_exchange_wmz' => 1, |
709 | 709 | |
710 | - 'payment_lot_price' => 1, // Lot price in default currency |
|
711 | - 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
710 | + 'payment_lot_price' => 1, // Lot price in default currency |
|
711 | + 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
712 | 712 | |
713 | 713 | 'planet_teleport_cost' => 50000, // |
714 | 714 | 'planet_teleport_timeout' => 86400, // |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | 'resource_multiplier' => 1, |
727 | 727 | |
728 | 728 | //Roleplay system |
729 | - 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
729 | + 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
730 | 730 | 'rpg_bonus_minimum' => 10000, // Minimum DM ammount for starting paying bonuses to affiliate |
731 | 731 | |
732 | 732 | // Black Market - General |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | } |
814 | 814 | |
815 | 815 | public static function getInstance($gamePrefix = 'sn_', $table_name = 'config') { |
816 | - if(!isset(self::$cacheObject)) { |
|
816 | + if (!isset(self::$cacheObject)) { |
|
817 | 817 | $className = get_class(); |
818 | 818 | self::$cacheObject = new $className($gamePrefix, $table_name); |
819 | 819 | } |
@@ -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; |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | // @version 1.0 |
4 | 4 | // @copyright 2008 by Chlorel for XNova |
5 | 5 | |
6 | -if(SN_IN_FLEET !== true) { |
|
6 | +if (SN_IN_FLEET !== true) { |
|
7 | 7 | $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
8 | 8 | } |
9 | 9 | |
@@ -20,25 +20,25 @@ discard block |
||
20 | 20 | |
21 | 21 | // Test de coherance de la destination (voir si elle se trouve dans les limites de l'univers connu |
22 | 22 | $errorlist = ''; |
23 | - if(!$galaxy || $galaxy > classSupernova::$config->game_maxGalaxy || $galaxy < 1) { |
|
23 | + if (!$galaxy || $galaxy > classSupernova::$config->game_maxGalaxy || $galaxy < 1) { |
|
24 | 24 | $errorlist .= classLocale::$lang['fl_limit_galaxy']; |
25 | 25 | } |
26 | - if(!$system || $system > classSupernova::$config->game_maxSystem || $system < 1) { |
|
26 | + if (!$system || $system > classSupernova::$config->game_maxSystem || $system < 1) { |
|
27 | 27 | $errorlist .= classLocale::$lang['fl_limit_system']; |
28 | 28 | } |
29 | - if(!$planet || $planet < 1 || ($planet > classSupernova::$config->game_maxPlanet && $target_mission != MT_EXPLORE)) { |
|
29 | + if (!$planet || $planet < 1 || ($planet > classSupernova::$config->game_maxPlanet && $target_mission != MT_EXPLORE)) { |
|
30 | 30 | $errorlist .= classLocale::$lang['fl_limit_planet']; |
31 | 31 | } |
32 | - if($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) { |
|
32 | + if ($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) { |
|
33 | 33 | $errorlist .= classLocale::$lang['fl_ownpl_err']; |
34 | 34 | } |
35 | - if(!$planet_type) { |
|
35 | + if (!$planet_type) { |
|
36 | 36 | $errorlist .= classLocale::$lang['fl_no_planettype']; |
37 | 37 | } |
38 | - if($planet_type != PT_PLANET && $planet_type != PT_DEBRIS && $planet_type != PT_MOON) { |
|
38 | + if ($planet_type != PT_PLANET && $planet_type != PT_DEBRIS && $planet_type != PT_MOON) { |
|
39 | 39 | $errorlist .= classLocale::$lang['fl_fleet_err_pl']; |
40 | 40 | } |
41 | - if(empty($missiontype[$target_mission])) { |
|
41 | + if (empty($missiontype[$target_mission])) { |
|
42 | 42 | $errorlist .= classLocale::$lang['fl_bad_mission']; |
43 | 43 | } |
44 | 44 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $TransDeuterium = max(0, sys_get_param_float('resource2')); |
48 | 48 | $StorageNeeded = $TransMetal + $TransCrystal + $TransDeuterium; |
49 | 49 | |
50 | - if(!$StorageNeeded && $target_mission == MT_TRANSPORT) { |
|
50 | + if (!$StorageNeeded && $target_mission == MT_TRANSPORT) { |
|
51 | 51 | $errorlist .= classLocale::$lang['fl_noenoughtgoods']; |
52 | 52 | } |
53 | 53 | |
@@ -56,41 +56,41 @@ discard block |
||
56 | 56 | $user = db_user_by_id($user['id'], true); |
57 | 57 | $planetrow = db_planet_by_id($planetrow['id'], true); |
58 | 58 | |
59 | - if($target_mission == MT_EXPLORE) { |
|
60 | - if($MaxExpeditions == 0) { |
|
59 | + if ($target_mission == MT_EXPLORE) { |
|
60 | + if ($MaxExpeditions == 0) { |
|
61 | 61 | $errorlist .= classLocale::$lang['fl_expe_notech']; |
62 | - } elseif($FlyingExpeditions >= $MaxExpeditions) { |
|
62 | + } elseif ($FlyingExpeditions >= $MaxExpeditions) { |
|
63 | 63 | $errorlist .= classLocale::$lang['fl_expe_max']; |
64 | 64 | } |
65 | 65 | } else { |
66 | - if($TargetPlanet['id_owner']) { |
|
67 | - if($target_mission == MT_COLONIZE) { |
|
66 | + if ($TargetPlanet['id_owner']) { |
|
67 | + if ($target_mission == MT_COLONIZE) { |
|
68 | 68 | $errorlist .= classLocale::$lang['fl_colonized']; |
69 | 69 | } |
70 | 70 | |
71 | - if($TargetPlanet['id_owner'] == $planetrow['id_owner']) { |
|
72 | - if($target_mission == MT_ATTACK) { |
|
71 | + if ($TargetPlanet['id_owner'] == $planetrow['id_owner']) { |
|
72 | + if ($target_mission == MT_ATTACK) { |
|
73 | 73 | $errorlist .= classLocale::$lang['fl_no_self_attack']; |
74 | 74 | } |
75 | 75 | |
76 | - if($target_mission == MT_SPY) { |
|
76 | + if ($target_mission == MT_SPY) { |
|
77 | 77 | $errorlist .= classLocale::$lang['fl_no_self_spy']; |
78 | 78 | } |
79 | 79 | } else { |
80 | - if($target_mission == MT_RELOCATE) { |
|
80 | + if ($target_mission == MT_RELOCATE) { |
|
81 | 81 | $errorlist .= classLocale::$lang['fl_only_stay_at_home']; |
82 | 82 | } |
83 | 83 | } |
84 | 84 | } else { |
85 | - if($target_mission < MT_COLONIZE) { |
|
85 | + if ($target_mission < MT_COLONIZE) { |
|
86 | 86 | $errorlist .= classLocale::$lang['fl_unknow_target']; |
87 | 87 | } else { |
88 | - if($target_mission == MT_DESTROY) { |
|
88 | + if ($target_mission == MT_DESTROY) { |
|
89 | 89 | $errorlist .= classLocale::$lang['fl_nomoon']; |
90 | 90 | } |
91 | 91 | |
92 | - if($target_mission == MT_RECYCLE) { |
|
93 | - if($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) { |
|
92 | + if ($target_mission == MT_RECYCLE) { |
|
93 | + if ($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) { |
|
94 | 94 | $errorlist .= classLocale::$lang['fl_nodebris']; |
95 | 95 | } |
96 | 96 | } |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | |
102 | - if(sn_module::$sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) { |
|
102 | + if (sn_module::$sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) { |
|
103 | 103 | $captain = sn_module::$sn_module['unit_captain']->unit_captain_get($planetrow['id']); |
104 | 104 | // mrc_get_level($user, $planetrow, UNIT_CAPTAIN, true); |
105 | - if(!$captain) { |
|
105 | + if (!$captain) { |
|
106 | 106 | $errorlist .= classLocale::$lang['module_unit_captain_error_no_captain']; |
107 | - } elseif($captain['unit_location_type'] == LOC_PLANET) { |
|
108 | - if($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) { |
|
107 | + } elseif ($captain['unit_location_type'] == LOC_PLANET) { |
|
108 | + if ($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) { |
|
109 | 109 | $errorlist .= classLocale::$lang['module_unit_captain_error_captain_already_bound']; |
110 | 110 | } |
111 | 111 | } else { |
@@ -113,14 +113,14 @@ discard block |
||
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | - if($errorlist) { |
|
116 | + if ($errorlist) { |
|
117 | 117 | sn_db_transaction_rollback(); |
118 | 118 | message("<span class='error'><ul>{$errorlist}</ul></span>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, false); |
119 | 119 | } |
120 | 120 | |
121 | 121 | // On verifie s'il y a assez de vaisseaux sur la planete ! |
122 | - foreach($fleetarray as $Ship => $Count) { |
|
123 | - if($Count > mrc_get_level($user, $planetrow, $Ship)) { |
|
122 | + foreach ($fleetarray as $Ship => $Count) { |
|
123 | + if ($Count > mrc_get_level($user, $planetrow, $Ship)) { |
|
124 | 124 | message("<span class='error'><b>{$classLocale['fl_fleet_err']}</b></span>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
125 | 125 | } |
126 | 126 | } |
@@ -131,10 +131,10 @@ discard block |
||
131 | 131 | //But is it acs?? |
132 | 132 | //Well all acs fleets must have a fleet code. |
133 | 133 | //The co-ords must be the same as where the acs fleet is going. |
134 | - if($fleet_group && sys_get_param_str('acs_target_mr') == "g{$galaxy}s{$system}p{$planet}t{$planet_type}") { |
|
134 | + if ($fleet_group && sys_get_param_str('acs_target_mr') == "g{$galaxy}s{$system}p{$planet}t{$planet_type}") { |
|
135 | 135 | //ACS attack must exist (if acs fleet has arrived this will also return false (2 checks in 1!!!) |
136 | 136 | $aks = db_acs_get_by_group_id($fleet_group); |
137 | - if(!$aks) { |
|
137 | + if (!$aks) { |
|
138 | 138 | $fleet_group = 0; |
139 | 139 | } else { |
140 | 140 | //Also it must be mission type 2 |
@@ -145,31 +145,31 @@ discard block |
||
145 | 145 | $planet = $aks['planet']; |
146 | 146 | $planet_type = $aks['planet_type']; |
147 | 147 | } |
148 | - } elseif($target_mission == MT_AKS) { |
|
148 | + } elseif ($target_mission == MT_AKS) { |
|
149 | 149 | //Check that a failed acs attack isn't being sent, if it is, make it an attack fleet. |
150 | 150 | $target_mission = MT_ATTACK; |
151 | 151 | } |
152 | 152 | |
153 | - if($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) { |
|
153 | + if ($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) { |
|
154 | 154 | $TargetPlanet = array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet, 'id_owner' => 0); |
155 | 155 | } |
156 | 156 | $options = array('fleet_speed_percent' => $speed_percent, 'fleet_group' => $fleet_group, 'resources' => $StorageNeeded); |
157 | 157 | $cant_attack = flt_can_attack($planetrow, $TargetPlanet, $fleetarray, $target_mission, $options); |
158 | 158 | |
159 | - if($cant_attack !== ATTACK_ALLOWED) { |
|
159 | + if ($cant_attack !== ATTACK_ALLOWED) { |
|
160 | 160 | message("<span class='error'><b>{$classLocale['fl_attack_error'][$cant_attack]}</b></span>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 99); |
161 | 161 | } |
162 | 162 | |
163 | 163 | $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1); |
164 | - if(!in_array($speed_percent, $speed_possible)) { |
|
164 | + if (!in_array($speed_percent, $speed_possible)) { |
|
165 | 165 | message("<span class='error'><b>" . classLocale::$lang['fl_cheat_speed'] . "</b></span>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
166 | 166 | } |
167 | 167 | |
168 | 168 | $mission_time_in_seconds = 0; |
169 | 169 | $arrival_time = SN_TIME_NOW + $time_to_travel; |
170 | - if($target_mission == MT_AKS && $aks) { |
|
170 | + if ($target_mission == MT_AKS && $aks) { |
|
171 | 171 | // if($fleet_start_time > $aks['ankunft']) { |
172 | - if($arrival_time > $aks['ankunft']) { |
|
172 | + if ($arrival_time > $aks['ankunft']) { |
|
173 | 173 | message(classLocale::$lang['fl_aks_too_slow'] . 'Fleet arrival: ' . date(FMT_DATE_TIME, $arrival_time) . " AKS arrival: " . date(FMT_DATE_TIME, $aks['ankunft']), classLocale::$lang['fl_error']); |
174 | 174 | } |
175 | 175 | $group_sync_delta_time = $aks['ankunft'] - $arrival_time; |
@@ -178,11 +178,11 @@ discard block |
||
178 | 178 | // Set return time to ACS return time + fleet's time to travel |
179 | 179 | $return_time = $aks['ankunft'] + $time_to_travel; |
180 | 180 | } else { |
181 | - if($target_mission == MT_EXPLORE || $target_mission == MT_HOLD) { |
|
181 | + if ($target_mission == MT_EXPLORE || $target_mission == MT_HOLD) { |
|
182 | 182 | $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : ($target_mission == MT_HOLD ? 12 : 0); |
183 | - if($max_duration) { |
|
183 | + if ($max_duration) { |
|
184 | 184 | $mission_time_in_hours = sys_get_param_id('missiontime'); |
185 | - if($mission_time_in_hours > $max_duration || $mission_time_in_hours < 1) { |
|
185 | + if ($mission_time_in_hours > $max_duration || $mission_time_in_hours < 1) { |
|
186 | 186 | $debug->warning('Supplying wrong mission time', 'Hack attempt', 302, array('base_dump' => true)); |
187 | 187 | die(); |
188 | 188 | } |
@@ -196,19 +196,19 @@ discard block |
||
196 | 196 | $FleetStorage = 0; |
197 | 197 | |
198 | 198 | $db_changeset = array(); |
199 | - foreach($fleetarray as $Ship => $Count) { |
|
199 | + foreach ($fleetarray as $Ship => $Count) { |
|
200 | 200 | $FleetStorage += get_unit_param($Ship, P_CAPACITY) * $Count; |
201 | 201 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($Ship, -$Count, $user, $planetrow['id']); |
202 | 202 | } |
203 | 203 | $FleetStorage -= $consumption; |
204 | 204 | |
205 | - if($StorageNeeded > $FleetStorage) { |
|
205 | + if ($StorageNeeded > $FleetStorage) { |
|
206 | 206 | message("<span class='error'><b>" . classLocale::$lang['fl_nostoragespa'] . pretty_number($StorageNeeded - $FleetStorage) . "</b></span>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
207 | 207 | } |
208 | - if($planetrow['deuterium'] < $TransDeuterium + $consumption) { |
|
208 | + if ($planetrow['deuterium'] < $TransDeuterium + $consumption) { |
|
209 | 209 | message("<font color=\"red\"><b>" . classLocale::$lang['fl_no_deuterium'] . pretty_number($TransDeuterium + $consumption - $planetrow['deuterium']) . "</b></font>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
210 | 210 | } |
211 | - if(($planetrow['metal'] < $TransMetal) || ($planetrow['crystal'] < $TransCrystal)) { |
|
211 | + if (($planetrow['metal'] < $TransMetal) || ($planetrow['crystal'] < $TransCrystal)) { |
|
212 | 212 | message("<font color=\"red\"><b>" . classLocale::$lang['fl_no_resources'] . "</b></font>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
213 | 213 | } |
214 | 214 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | |
239 | 239 | $template = gettemplate('fleet3', true); |
240 | 240 | |
241 | - if(is_array($captain)) { |
|
241 | + if (is_array($captain)) { |
|
242 | 242 | db_unit_set_by_id($captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$objFleet->dbId}"); |
243 | 243 | } |
244 | 244 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | 'START_LEFT' => floor($return_time + 1 - SN_TIME_NOW), |
252 | 252 | ); |
253 | 253 | |
254 | - if(!empty($TargetPlanet)) { |
|
254 | + if (!empty($TargetPlanet)) { |
|
255 | 255 | $template_route += array( |
256 | 256 | 'END_TYPE_TEXT_SH' => classLocale::$lang['sys_planet_type_sh'][$TargetPlanet['planet_type']], |
257 | 257 | 'END_COORDS' => uni_render_coordinates($TargetPlanet), |
@@ -264,8 +264,8 @@ discard block |
||
264 | 264 | $template->assign_block_vars('fleets', $template_route); |
265 | 265 | |
266 | 266 | $sn_groups_fleet = sn_get_groups('fleet'); |
267 | - foreach($fleetarray as $ship_id => $ship_count) { |
|
268 | - if(in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
267 | + foreach ($fleetarray as $ship_id => $ship_count) { |
|
268 | + if (in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
269 | 269 | // $ship_base_data = get_ship_data($ship_id, $user); |
270 | 270 | $template->assign_block_vars('fleets.ships', array( |
271 | 271 | 'ID' => $ship_id, |
@@ -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, |