@@ -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,8 +21,8 @@ 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 | DBStaticPlanet::db_planet_set_by_owner( |
28 | 28 | $user['id'], |
@@ -39,27 +39,27 @@ discard block |
||
39 | 39 | ); |
40 | 40 | } |
41 | 41 | |
42 | - if(sys_get_param_int('vacation') && !classSupernova::$config->user_vacation_disable) { |
|
42 | + if (sys_get_param_int('vacation') && !classSupernova::$config->user_vacation_disable) { |
|
43 | 43 | sn_db_transaction_start(); |
44 | - if($user['authlevel'] < 3) { |
|
45 | - if($user['vacation_next'] > SN_TIME_NOW) { |
|
44 | + if ($user['authlevel'] < 3) { |
|
45 | + if ($user['vacation_next'] > SN_TIME_NOW) { |
|
46 | 46 | message(classLocale::$lang['opt_vacation_err_timeout'], classLocale::$lang['Error'], 'index.php?page=options', 5); |
47 | 47 | die(); |
48 | 48 | } |
49 | 49 | |
50 | - if(FleetList::fleet_count_flying($user['id'])) { |
|
50 | + if (FleetList::fleet_count_flying($user['id'])) { |
|
51 | 51 | message(classLocale::$lang['opt_vacation_err_your_fleet'], classLocale::$lang['Error'], 'index.php?page=options', 5); |
52 | 52 | die(); |
53 | 53 | } |
54 | 54 | |
55 | 55 | $que = que_get($user['id'], false); |
56 | - if(!empty($que)) { |
|
56 | + if (!empty($que)) { |
|
57 | 57 | message(classLocale::$lang['opt_vacation_err_que'], classLocale::$lang['Error'], 'index.php?page=options', 5); |
58 | 58 | die(); |
59 | 59 | } |
60 | 60 | |
61 | 61 | $query = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_PLANET, "`id_owner` = {$user['id']}"); |
62 | - foreach($query as $planet) { |
|
62 | + foreach ($query as $planet) { |
|
63 | 63 | $classConfig = classSupernova::$config; |
64 | 64 | DBStaticPlanet::db_planet_update_set_by_id( |
65 | 65 | $planet['id'], |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | sn_db_transaction_commit(); |
88 | 88 | } |
89 | 89 | |
90 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
91 | - foreach($option_group as $option_name => $option_value) { |
|
92 | - if($user[$option_name] !== null) { |
|
90 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
91 | + foreach ($option_group as $option_name => $option_value) { |
|
92 | + if ($user[$option_name] !== null) { |
|
93 | 93 | $user[$option_name] = sys_get_param_str($option_name); |
94 | 94 | } else { |
95 | 95 | $user[$option_name] = $option_value; |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | |
101 | 101 | |
102 | 102 | $player_options = sys_get_param('options'); |
103 | - if(!empty($player_options)) { |
|
104 | - array_walk($player_options, function (&$value) { |
|
103 | + if (!empty($player_options)) { |
|
104 | + array_walk($player_options, function(&$value) { |
|
105 | 105 | // TODO - Когда будет больше параметров - сделать больше проверок |
106 | 106 | $value = intval($value); |
107 | 107 | }); |
@@ -112,15 +112,15 @@ discard block |
||
112 | 112 | |
113 | 113 | $username = substr(sys_get_param_str_unsafe('username'), 0, 32); |
114 | 114 | $username_safe = db_escape($username); |
115 | - 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)) { |
|
115 | + 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)) { |
|
116 | 116 | // проверка на корректность |
117 | 117 | sn_db_transaction_start(); |
118 | 118 | $name_check = db_player_name_history_get_name_by_name($username_safe); |
119 | - if(!$name_check || $name_check['player_id'] == $user['id']) { |
|
119 | + if (!$name_check || $name_check['player_id'] == $user['id']) { |
|
120 | 120 | $user = DBStaticUser::db_user_by_id($user['id'], true); |
121 | - switch(classSupernova::$config->game_user_changename) { |
|
121 | + switch (classSupernova::$config->game_user_changename) { |
|
122 | 122 | case SERVER_PLAYER_NAME_CHANGE_PAY: |
123 | - if(mrc_get_level($user, $planetrow, RES_DARK_MATTER) < classSupernova::$config->game_user_changename_cost) { |
|
123 | + if (mrc_get_level($user, $planetrow, RES_DARK_MATTER) < classSupernova::$config->game_user_changename_cost) { |
|
124 | 124 | $template_result['.']['result'][] = array( |
125 | 125 | 'STATUS' => ERR_ERROR, |
126 | 126 | 'MESSAGE' => classLocale::$lang['opt_msg_name_change_err_no_dm'], |
@@ -156,18 +156,18 @@ discard block |
||
156 | 156 | sn_db_transaction_commit(); |
157 | 157 | } |
158 | 158 | |
159 | - if($new_password = sys_get_param('newpass1')) { |
|
159 | + if ($new_password = sys_get_param('newpass1')) { |
|
160 | 160 | try { |
161 | - if($new_password != sys_get_param('newpass2')) { |
|
161 | + if ($new_password != sys_get_param('newpass2')) { |
|
162 | 162 | throw new Exception(classLocale::$lang['opt_err_pass_unmatched'], ERR_WARNING); |
163 | 163 | } |
164 | 164 | |
165 | - if(!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) { |
|
165 | + if (!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) { |
|
166 | 166 | throw new Exception(classLocale::$lang['opt_err_pass_wrong'], ERR_WARNING); |
167 | 167 | } |
168 | 168 | |
169 | 169 | throw new Exception(classLocale::$lang['opt_msg_pass_changed'], ERR_NONE); |
170 | - } catch(Exception $e) { |
|
170 | + } catch (Exception $e) { |
|
171 | 171 | $template_result['.']['result'][] = array( |
172 | 172 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
173 | 173 | 'MESSAGE' => $e->getMessage() |
@@ -189,12 +189,12 @@ discard block |
||
189 | 189 | $user['gender'] = $user['gender'] == GENDER_UNKNOWN ? $gender : $user['gender']; |
190 | 190 | |
191 | 191 | try { |
192 | - if($user['birthday']) { |
|
192 | + if ($user['birthday']) { |
|
193 | 193 | throw new exception(); |
194 | 194 | } |
195 | 195 | |
196 | 196 | $user_birthday = sys_get_param_str_unsafe('user_birthday'); |
197 | - if(!$user_birthday || $user_birthday == $FMT_DATE) { |
|
197 | + if (!$user_birthday || $user_birthday == $FMT_DATE) { |
|
198 | 198 | throw new exception(); |
199 | 199 | } |
200 | 200 | |
@@ -204,16 +204,16 @@ discard block |
||
204 | 204 | $pos['Y'] = strpos(FMT_DATE, 'Y'); |
205 | 205 | asort($pos); |
206 | 206 | $i = 0; |
207 | - foreach($pos as &$position) { |
|
207 | + foreach ($pos as &$position) { |
|
208 | 208 | $position = ++$i; |
209 | 209 | } |
210 | 210 | |
211 | - $regexp = "/" . preg_replace(array('/\\\\/', '/\//', '/\./', '/\-/', '/d/', '/m/', '/Y/'), array('\\\\\\', '\/', '\.', '\-', '(\d?\d)', '(\d?\d)', '(\d{4})'), FMT_DATE) . "/"; |
|
212 | - if(!preg_match($regexp, $user_birthday, $match)) { |
|
211 | + $regexp = "/".preg_replace(array('/\\\\/', '/\//', '/\./', '/\-/', '/d/', '/m/', '/Y/'), array('\\\\\\', '\/', '\.', '\-', '(\d?\d)', '(\d?\d)', '(\d{4})'), FMT_DATE)."/"; |
|
212 | + if (!preg_match($regexp, $user_birthday, $match)) { |
|
213 | 213 | throw new exception(); |
214 | 214 | } |
215 | 215 | |
216 | - if(!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) { |
|
216 | + if (!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) { |
|
217 | 217 | throw new exception(); |
218 | 218 | } |
219 | 219 | |
@@ -221,12 +221,12 @@ discard block |
||
221 | 221 | // EOF black magic! Now we have valid SQL date in $user['user_birthday'] - independent of date format |
222 | 222 | |
223 | 223 | $year = date('Y', SN_TIME_NOW); |
224 | - if(mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) { |
|
224 | + if (mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) { |
|
225 | 225 | $year--; |
226 | 226 | } |
227 | 227 | $user['user_birthday_celebrated'] = "{$year}-{$match[$pos['m']]}-{$match[$pos['d']]}"; |
228 | 228 | |
229 | - } catch(Exception $e) { |
|
229 | + } catch (Exception $e) { |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | require_once('includes/includes/sys_avatar.php'); |
@@ -235,14 +235,14 @@ discard block |
||
235 | 235 | $template_result['.']['result'][] = $avatar_upload_result; |
236 | 236 | |
237 | 237 | $user_time_diff = playerTimeDiff::user_time_diff_get(); |
238 | - if(sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) { |
|
238 | + if (sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) { |
|
239 | 239 | playerTimeDiff::user_time_diff_set(array( |
240 | 240 | PLAYER_OPTION_TIME_DIFF => sys_get_param_int('PLAYER_OPTION_TIME_DIFF'), |
241 | 241 | PLAYER_OPTION_TIME_DIFF_UTC_OFFSET => 0, |
242 | 242 | PLAYER_OPTION_TIME_DIFF_FORCED => 1, |
243 | 243 | PLAYER_OPTION_TIME_DIFF_MEASURE_TIME => SN_TIME_SQL, |
244 | 244 | )); |
245 | - } elseif(sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) { |
|
245 | + } elseif (sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) { |
|
246 | 246 | playerTimeDiff::user_time_diff_set(array( |
247 | 247 | PLAYER_OPTION_TIME_DIFF => '', |
248 | 248 | PLAYER_OPTION_TIME_DIFF_UTC_OFFSET => 0, |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | 'STATUS' => ERR_NONE, |
274 | 274 | 'MESSAGE' => classLocale::$lang['opt_msg_saved'] |
275 | 275 | ); |
276 | - } elseif(sys_get_param_str('result') == 'ok') { |
|
276 | + } elseif (sys_get_param_str('result') == 'ok') { |
|
277 | 277 | $template_result['.']['result'][] = array( |
278 | 278 | 'STATUS' => ERR_NONE, |
279 | 279 | 'MESSAGE' => classLocale::$lang['opt_msg_saved'] |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | |
297 | 297 | $template = gettemplate('options', $template); |
298 | 298 | |
299 | - $dir = dir(SN_ROOT_PHYSICAL . 'skins'); |
|
300 | - while(($entry = $dir->read()) !== false) { |
|
301 | - if(is_dir("skins/{$entry}") && $entry[0] != '.') { |
|
299 | + $dir = dir(SN_ROOT_PHYSICAL.'skins'); |
|
300 | + while (($entry = $dir->read()) !== false) { |
|
301 | + if (is_dir("skins/{$entry}") && $entry[0] != '.') { |
|
302 | 302 | $template_result['.']['skin_list'][] = array( |
303 | 303 | 'VALUE' => $entry, |
304 | 304 | 'NAME' => $entry, |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | } |
309 | 309 | $dir->close(); |
310 | 310 | |
311 | - foreach(classLocale::$lang['opt_planet_sort_options'] as $key => &$value) { |
|
311 | + foreach (classLocale::$lang['opt_planet_sort_options'] as $key => &$value) { |
|
312 | 312 | $template_result['.']['planet_sort_options'][] = array( |
313 | 313 | 'VALUE' => $key, |
314 | 314 | 'NAME' => $value, |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | ); |
317 | 317 | } |
318 | 318 | |
319 | - foreach(classLocale::$lang['sys_gender_list'] as $key => $value) { |
|
319 | + foreach (classLocale::$lang['sys_gender_list'] as $key => $value) { |
|
320 | 320 | $template_result['.']['gender_list'][] = array( |
321 | 321 | 'VALUE' => $key, |
322 | 322 | 'NAME' => $value, |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | } |
326 | 326 | |
327 | 327 | $lang_list = lng_get_list(); |
328 | - foreach($lang_list as $lang_id => $lang_data) { |
|
328 | + foreach ($lang_list as $lang_id => $lang_data) { |
|
329 | 329 | $template_result['.']['languages'][] = array( |
330 | 330 | 'VALUE' => $lang_id, |
331 | 331 | 'NAME' => $lang_data['LANG_NAME_NATIVE'], |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | } |
335 | 335 | |
336 | 336 | |
337 | - if(isset(classLocale::$lang['menu_customize_show_hide_button_state'])) { |
|
338 | - foreach(classLocale::$lang['menu_customize_show_hide_button_state'] as $key => $value) { |
|
337 | + if (isset(classLocale::$lang['menu_customize_show_hide_button_state'])) { |
|
338 | + foreach (classLocale::$lang['menu_customize_show_hide_button_state'] as $key => $value) { |
|
339 | 339 | $template->assign_block_vars('menu_customize_show_hide_button_state', array( |
340 | 340 | 'ID' => $key, |
341 | 341 | 'NAME' => $value, |
@@ -442,10 +442,10 @@ discard block |
||
442 | 442 | 'PAGE_HEADER' => classLocale::$lang['opt_header'], |
443 | 443 | )); |
444 | 444 | |
445 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
446 | - if($option_group_id == OPT_MESSAGE) { |
|
447 | - foreach(DBStaticMessages::$snMessageClassList as $message_class_id => $message_class_data) { |
|
448 | - if($message_class_data['switchable'] || ($message_class_data['email'] && classSupernova::$config->game_email_pm)) { |
|
445 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
446 | + if ($option_group_id == OPT_MESSAGE) { |
|
447 | + foreach (DBStaticMessages::$snMessageClassList as $message_class_id => $message_class_data) { |
|
448 | + if ($message_class_data['switchable'] || ($message_class_data['email'] && classSupernova::$config->game_email_pm)) { |
|
449 | 449 | $option_name = $message_class_data['name']; |
450 | 450 | |
451 | 451 | $template->assign_block_vars("options_{$option_group_id}", array( |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | } |
458 | 458 | } |
459 | 459 | } else { |
460 | - foreach($option_group as $option_name => $option_value) { |
|
461 | - if(array_key_exists($option_name, $user_option_types)) { |
|
460 | + foreach ($option_group as $option_name => $option_value) { |
|
461 | + if (array_key_exists($option_name, $user_option_types)) { |
|
462 | 462 | $option_type = $user_option_types[$option_name]; |
463 | 463 | } else { |
464 | 464 | $option_type = 'switch'; |
@@ -2,11 +2,11 @@ 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 | classSupernova::$debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403); |
7 | 7 | } |
8 | 8 | |
9 | -$page_title .= ' - ' . classLocale::$lang["eco_mrk_{$submode}"]; |
|
9 | +$page_title .= ' - '.classLocale::$lang["eco_mrk_{$submode}"]; |
|
10 | 10 | |
11 | 11 | $template = gettemplate('market_fleet', true); |
12 | 12 | $template->assign_vars(array( |
@@ -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 | |
@@ -28,32 +28,32 @@ discard block |
||
28 | 28 | // Блокируем запись о запасах кораблей у трейдера |
29 | 29 | db_config_get_stockman_fleet(); |
30 | 30 | |
31 | - $message .= classLocale::$lang["eco_mrk_{$submode}_ships"] . '<ul>'; |
|
31 | + $message .= classLocale::$lang["eco_mrk_{$submode}_ships"].'<ul>'; |
|
32 | 32 | $total = array(); |
33 | - foreach($shipList as $shipID => &$shipCount) { |
|
33 | + foreach ($shipList as $shipID => &$shipCount) { |
|
34 | 34 | $shipCount = ceil(floatval($shipCount)); |
35 | - if(!$shipCount) { |
|
35 | + if (!$shipCount) { |
|
36 | 36 | continue; |
37 | 37 | } |
38 | 38 | |
39 | - if($shipCount < 0) { |
|
39 | + if ($shipCount < 0) { |
|
40 | 40 | classSupernova::$debug->warning('User supplied negative ship count on Black Market page', 'Hack Attempt', 307); |
41 | 41 | $intError = MARKET_NEGATIVE_SHIPS; |
42 | 42 | break; |
43 | 43 | } |
44 | 44 | |
45 | - if($mode == MARKET_SCRAPPER) { |
|
45 | + if ($mode == MARKET_SCRAPPER) { |
|
46 | 46 | $amount = mrc_get_level($user, $planetrow, $shipID, true, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
47 | - } elseif($mode == MARKET_STOCKMAN) { |
|
47 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
48 | 48 | $amount = $stock[$shipID]; |
49 | 49 | } |
50 | 50 | |
51 | - if($amount < $shipCount) { |
|
51 | + if ($amount < $shipCount) { |
|
52 | 52 | $intError = $error_no_stock; |
53 | 53 | break; |
54 | 54 | } |
55 | 55 | |
56 | - if(!in_array($shipID, Fleet::$snGroupFleet)) { |
|
56 | + if (!in_array($shipID, Fleet::$snGroupFleet)) { |
|
57 | 57 | classSupernova::$debug->warning('Hack Attempt', 'User supplied non-ship unit ID on Black Market page', 306); |
58 | 58 | $intError = MARKET_NOT_A_SHIP; |
59 | 59 | break; |
@@ -69,16 +69,16 @@ discard block |
||
69 | 69 | $resTemp[RES_CRYSTAL] = floor($build_data[BUILD_CREATE][RES_CRYSTAL] * $shipCount * $config_rpg_scrape_crystal * (-$multiplier)); |
70 | 70 | $resTemp[RES_DEUTERIUM] = floor($build_data[BUILD_CREATE][RES_DEUTERIUM] * $shipCount * $config_rpg_scrape_deuterium * (-$multiplier)); |
71 | 71 | |
72 | - foreach($resTemp as $resID => $resCount) { |
|
72 | + foreach ($resTemp as $resID => $resCount) { |
|
73 | 73 | $total[$resID] += $resCount; |
74 | 74 | } |
75 | 75 | |
76 | - $message .= "<li>{$classLocale['tech'][$shipID]}: " . pretty_number($shipCount); |
|
76 | + $message .= "<li>{$classLocale['tech'][$shipID]}: ".pretty_number($shipCount); |
|
77 | 77 | } |
78 | 78 | |
79 | - if($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
80 | - foreach($total as $resID => $resCount) { |
|
81 | - if(mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
79 | + if ($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
80 | + foreach ($total as $resID => $resCount) { |
|
81 | + if (mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
82 | 82 | $intError = MARKET_NO_RESOURCES; |
83 | 83 | classSupernova::$debug->warning('Trying to use bug in s/h market', 'S/H Ship Market', 301); |
84 | 84 | break; |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | $intError = ($intError == MARKET_DEAL) && (array_sum($total) == 0) ? $error_zero_res : $intError; |
90 | 90 | |
91 | 91 | $qry = array(); |
92 | - if($intError == MARKET_DEAL) { |
|
93 | - $message .= '</ul>' . classLocale::$lang["eco_mrk_{$submode}_res"] . '<ul>'; |
|
94 | - foreach($total as $resID => $resCount) { |
|
95 | - if(!$resCount) { |
|
92 | + if ($intError == MARKET_DEAL) { |
|
93 | + $message .= '</ul>'.classLocale::$lang["eco_mrk_{$submode}_res"].'<ul>'; |
|
94 | + foreach ($total as $resID => $resCount) { |
|
95 | + if (!$resCount) { |
|
96 | 96 | continue; |
97 | 97 | } |
98 | 98 | |
99 | 99 | $qry[pname_resource_name($resID)] = $resCount; |
100 | - $message .= "<li>" . classLocale::$lang['sys_' . pname_resource_name($resID)] . ": " . pretty_number(abs($resCount)); |
|
100 | + $message .= "<li>".classLocale::$lang['sys_'.pname_resource_name($resID)].": ".pretty_number(abs($resCount)); |
|
101 | 101 | } |
102 | 102 | $message .= "</ul>"; |
103 | 103 | |
@@ -125,38 +125,38 @@ discard block |
||
125 | 125 | 'MESSAGE' => classLocale::$lang['eco_mrk_errors'][$intError], |
126 | 126 | )); |
127 | 127 | |
128 | - foreach($shipList as $shipID => $shipCount) { |
|
128 | + foreach ($shipList as $shipID => $shipCount) { |
|
129 | 129 | $data['ships'][$shipID] = max(0, intval($shipCount)); |
130 | 130 | } |
131 | 131 | } |
132 | 132 | } |
133 | 133 | $message = ''; |
134 | 134 | |
135 | -if(!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) { |
|
136 | - classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item){return mt_rand(1, 1000);}, Fleet::$snGroupFleet))); |
|
135 | +if (!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) { |
|
136 | + classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item) {return mt_rand(1, 1000); }, Fleet::$snGroupFleet))); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | tpl_set_resource_info($template, $planetrow, array()); |
140 | 140 | |
141 | -if(!$array) { |
|
141 | +if (!$array) { |
|
142 | 142 | $array = array(); |
143 | 143 | } |
144 | 144 | |
145 | 145 | $group_fleet = Fleet::$snGroupFleet; |
146 | -foreach($array as $key => $value) { |
|
147 | - if($mode == MARKET_SCRAPPER) { |
|
146 | +foreach ($array as $key => $value) { |
|
147 | + if ($mode == MARKET_SCRAPPER) { |
|
148 | 148 | $shipID = $value; |
149 | 149 | $amount = mrc_get_level($user, $planetrow, $shipID, false, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
150 | - } elseif($mode == MARKET_STOCKMAN) { |
|
150 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
151 | 151 | $shipID = $key; |
152 | 152 | $amount = $value; |
153 | 153 | } |
154 | 154 | |
155 | - if(!in_array($shipID, $group_fleet)) { |
|
155 | + if (!in_array($shipID, $group_fleet)) { |
|
156 | 156 | continue; |
157 | 157 | } |
158 | 158 | |
159 | - if($amount > 0) { |
|
159 | + if ($amount > 0) { |
|
160 | 160 | $build_data = eco_get_build_data($user, $planetrow, $shipID); |
161 | 161 | $template->assign_block_vars('ships', array( |
162 | 162 | 'ID' => $shipID, |
@@ -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(classSupernova::$design['smiles'] as $auth_level => $replaces) { |
|
53 | - if($auth_level > $user_auth_level) { |
|
52 | + foreach (classSupernova::$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,7 +77,7 @@ discard block |
||
77 | 77 | define('IN_AJAX', true); |
78 | 78 | $skip_fleet_update = true; |
79 | 79 | |
80 | - if( |
|
80 | + if ( |
|
81 | 81 | classSupernova::$config->getMode() != CACHER_NO_CACHE |
82 | 82 | && |
83 | 83 | classSupernova::$config->chat_timeout |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | die(); |
88 | 88 | } |
89 | 89 | |
90 | - if(($message = sys_get_param_str('message')) && $user['username']) { |
|
90 | + if (($message = sys_get_param_str('message')) && $user['username']) { |
|
91 | 91 | $ally_id = sys_get_param('ally') && $user['ally_id'] ? $user['ally_id'] : 0; |
92 | 92 | $nickUnsafe = player_nick_compact(player_nick_render_current_to_array($user, array('color' => true, 'icons' => true, 'ally' => !$ally_id))); |
93 | 93 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $skip_fleet_update = true; |
110 | 110 | |
111 | 111 | $history = sys_get_param_str('history'); |
112 | - if(!$history) { |
|
112 | + if (!$history) { |
|
113 | 113 | classSupernova::$config->array_set('users', $user['id'], 'chat_last_refresh', SN_TIME_MICRO); |
114 | 114 | } |
115 | 115 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $last_message = ''; |
118 | 118 | $alliance = 0; |
119 | 119 | $template_result['.']['chat'] = array(); |
120 | - if( |
|
120 | + if ( |
|
121 | 121 | !$history |
122 | 122 | && |
123 | 123 | classSupernova::$config->getMode() != CACHER_NO_CACHE |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | |
139 | 139 | $where_add = ''; |
140 | 140 | $last_message = 0; |
141 | - if($history) { |
|
141 | + if ($history) { |
|
142 | 142 | $rows = DBStaticChat::db_chat_message_count_by_ally($alliance); |
143 | 143 | $page_count = ceil($rows['CNT'] / $page_limit); |
144 | 144 | |
145 | - for($i = 0; $i < $page_count; $i++) { |
|
145 | + for ($i = 0; $i < $page_count; $i++) { |
|
146 | 146 | $template_result['.']['page'][] = array( |
147 | 147 | 'NUMBER' => $i |
148 | 148 | ); |
@@ -156,12 +156,12 @@ discard block |
||
156 | 156 | |
157 | 157 | $start_row = $page * $page_limit; |
158 | 158 | $query = DBStaticChat::db_chat_message_get_page($alliance, $where_add, $start_row, $page_limit); |
159 | - while($chat_row = db_fetch($query)) { |
|
159 | + while ($chat_row = db_fetch($query)) { |
|
160 | 160 | // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick |
161 | 161 | $chat_row['user'] = player_nick_render_to_html($chat_row['user']); |
162 | 162 | $nick_stripped = htmlentities(strip_tags($chat_row['user']), ENT_QUOTES, 'utf-8'); |
163 | 163 | $nick = str_replace(strip_tags($chat_row['user']), $nick_stripped, $chat_row['user']); |
164 | - if(!$history) { |
|
164 | + if (!$history) { |
|
165 | 165 | $nick = "<span style=\"cursor: pointer;\" onclick=\"addSmiley('({$nick_stripped})');\">{$nick}</span>"; |
166 | 166 | } |
167 | 167 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $template = gettemplate('chat_messages', $template); |
187 | 187 | $template->assign_recursive($template_result); |
188 | 188 | |
189 | - if($history) { |
|
189 | + if ($history) { |
|
190 | 190 | display($template, "{$classLocale['chat_history']} - {$classLocale[$alliance ? 'chat_ally' : 'chat_common']}", true, '', false, true); |
191 | 191 | } else { |
192 | 192 | $result['last_message'] = $last_message; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | // ------------------------------------------------------------------------------------------------------------------------------ |
4 | 4 | function sn_sys_load_php_files($dir_name, $load_extension = '.php', $modules = false) { |
5 | - if(!file_exists($dir_name) || !is_dir($dir_name)) { |
|
5 | + if (!file_exists($dir_name) || !is_dir($dir_name)) { |
|
6 | 6 | return; |
7 | 7 | } |
8 | 8 | |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | continue; |
13 | 13 | } |
14 | 14 | |
15 | - $full_filename = $dir_name . $file; |
|
15 | + $full_filename = $dir_name.$file; |
|
16 | 16 | if ($modules && is_dir($full_filename)) { |
17 | 17 | if (file_exists($full_filename = "{$full_filename}/{$file}{$load_extension}")) { |
18 | 18 | require_once($full_filename); |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | * |
39 | 39 | */ |
40 | 40 | function init_update() { |
41 | - $update_file = SN_ROOT_PHYSICAL . "includes/update" . DOT_PHP_EX; |
|
42 | - if(file_exists($update_file)) { |
|
43 | - if(filemtime($update_file) > classSupernova::$config->db_loadItem('var_db_update') || classSupernova::$config->db_loadItem('db_version') < DB_VERSION) { |
|
44 | - if(defined('IN_ADMIN')) { |
|
41 | + $update_file = SN_ROOT_PHYSICAL."includes/update".DOT_PHP_EX; |
|
42 | + if (file_exists($update_file)) { |
|
43 | + if (filemtime($update_file) > classSupernova::$config->db_loadItem('var_db_update') || classSupernova::$config->db_loadItem('db_version') < DB_VERSION) { |
|
44 | + if (defined('IN_ADMIN')) { |
|
45 | 45 | sn_db_transaction_start(); // Для защиты от двойного запуска апдейта - начинаем транзакцию. Так запись в базе будет блокирована |
46 | - if(SN_TIME_NOW >= classSupernova::$config->db_loadItem('var_db_update_end')) { |
|
46 | + if (SN_TIME_NOW >= classSupernova::$config->db_loadItem('var_db_update_end')) { |
|
47 | 47 | classSupernova::$config->db_saveItem('var_db_update_end', SN_TIME_NOW + (classSupernova::$config->upd_lock_time ? classSupernova::$config->upd_lock_time : 300)); |
48 | 48 | sn_db_transaction_commit(); |
49 | 49 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $current_time = time(); |
54 | 54 | classSupernova::$config->db_saveItem('var_db_update', $current_time); |
55 | 55 | classSupernova::$config->db_saveItem('var_db_update_end', $current_time); |
56 | - } elseif(filemtime($update_file) > classSupernova::$config->var_db_update) { |
|
56 | + } elseif (filemtime($update_file) > classSupernova::$config->var_db_update) { |
|
57 | 57 | $timeout = classSupernova::$config->var_db_update_end - SN_TIME_NOW; |
58 | 58 | die( |
59 | 59 | "Обновляется база данных. Рассчетное время окончания - {$timeout} секунд (время обновления может увеличиваться). Пожалуйста, подождите...<br /> |
@@ -13,9 +13,9 @@ |
||
13 | 13 | |
14 | 14 | $allow_anonymous = true; |
15 | 15 | |
16 | -include('includes/init.' . substr(strrchr(__FILE__, '.'), 1)); |
|
16 | +include('includes/init.'.substr(strrchr(__FILE__, '.'), 1)); |
|
17 | 17 | // die(); |
18 | -if($template_result[F_USER_IS_AUTHORIZED]) { |
|
18 | +if ($template_result[F_USER_IS_AUTHORIZED]) { |
|
19 | 19 | sys_redirect('index.php'); |
20 | 20 | } |
21 | 21 | lng_include('login'); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | global $user, $planetrow; |
17 | 17 | |
18 | -include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
18 | +include('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
19 | 19 | |
20 | 20 | lng_include('infos'); |
21 | 21 | lng_include('artifacts'); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | die(); |
67 | 67 | break; |
68 | 68 | } |
69 | - message($Message, classLocale::$lang['tech'][UNIT_ARTIFACTS], 'artifacts' . DOT_PHP_EX, 5); |
|
69 | + message($Message, classLocale::$lang['tech'][UNIT_ARTIFACTS], 'artifacts'.DOT_PHP_EX, 5); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | $template = gettemplate('artifacts', true); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | define('INSTALL', false); |
13 | 13 | define('IN_ADMIN', true); |
14 | 14 | |
15 | -require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
15 | +require('../common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
16 | 16 | |
17 | 17 | if ($user['authlevel'] < 3) { |
18 | 18 | AdminMessage(classLocale::$lang['adm_err_denied']); |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | print("<td>Last online</td>"); |
102 | 102 | print("</tr>"); |
103 | 103 | foreach ($session_list as $user_id => $value) { |
104 | - $user_record = classSupernova::$db->doSelect("SELECT * FROM `{{users}}` WHERE `id` = " . idval($user_id)); |
|
104 | + $user_record = classSupernova::$db->doSelect("SELECT * FROM `{{users}}` WHERE `id` = ".idval($user_id)); |
|
105 | 105 | foreach ($value as $interval_data) { |
106 | 106 | print("<tr>"); |
107 | 107 | print("<td>{$user_id}</td><td>{$user_record['username']}</td><td>{$interval_data[0]}</td><td>{$interval_data[1]}</td><td>{$interval_data[2]}</td>"); |
108 | - print("<td>" . date(FMT_DATE_TIME_SQL, $user_record['onlinetime']) . "</td>"); |
|
108 | + print("<td>".date(FMT_DATE_TIME_SQL, $user_record['onlinetime'])."</td>"); |
|
109 | 109 | print("</tr>"); |
110 | 110 | } |
111 | 111 | } |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | // classSupernova::$db->sn_db_connect(); |
16 | 16 | if (!(strpos($query, '{{') === false)) { |
17 | 17 | foreach ($update_tables as $tableName => $cork) { |
18 | - $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix . $tableName, $query); |
|
18 | + $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix.$tableName, $query); |
|
19 | 19 | } |
20 | 20 | } |
21 | - !($result = classSupernova::$db->db_sql_query($query)) ? die('Query error for ' . $query . ': ' . classSupernova::$db->db_error()) : false; |
|
21 | + !($result = classSupernova::$db->db_sql_query($query)) ? die('Query error for '.$query.': '.classSupernova::$db->db_error()) : false; |
|
22 | 22 | |
23 | 23 | return $result; |
24 | 24 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | global $update_tables, $update_indexes, $update_indexes_full, $update_foreigns; |
86 | 86 | |
87 | 87 | $tableName = $prefixed ? str_replace(classSupernova::$config->db_prefix, '', $prefix_table_name) : $prefix_table_name; |
88 | - $prefix_table_name = $prefixed ? $prefix_table_name : classSupernova::$config->db_prefix . $prefix_table_name; |
|
88 | + $prefix_table_name = $prefixed ? $prefix_table_name : classSupernova::$config->db_prefix.$prefix_table_name; |
|
89 | 89 | |
90 | 90 | upd_unset_table_info($tableName); |
91 | 91 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $update_indexes_full[$tableName][$r1['Key_name']][$r1['Column_name']] = $r1; |
101 | 101 | } |
102 | 102 | |
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); |
|
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 | 104 | while ($r1 = db_fetch($q1)) { |
105 | 105 | $table_referenced = str_replace(classSupernova::$config->db_prefix, '', $r1['REFERENCED_TABLE_NAME']); |
106 | 106 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $result = upd_do_query("CREATE TABLE IF NOT EXISTS `{$db_prefix}{$table_name}` {$declaration}"); |
161 | 161 | $error = classSupernova::$db->db_error(); |
162 | 162 | if ($error) { |
163 | - die("Creating error for table `{$table_name}`: {$error}<br />" . dump($declaration)); |
|
163 | + die("Creating error for table `{$table_name}`: {$error}<br />".dump($declaration)); |
|
164 | 164 | } |
165 | 165 | upd_do_query('set foreign_key_checks = 1;', true); |
166 | 166 | upd_load_table_info($table_name, false); |
@@ -134,7 +134,6 @@ discard block |
||
134 | 134 | /** |
135 | 135 | * Попытка залогиниться с использованием метода $method |
136 | 136 | * |
137 | - * @param string $method_name |
|
138 | 137 | */ |
139 | 138 | public function login() { |
140 | 139 | // TODO Проверяем поддерживаемость метода |
@@ -162,6 +161,10 @@ discard block |
||
162 | 161 | * @return array|bool|resource |
163 | 162 | */ |
164 | 163 | // OK v4.5 |
164 | + |
|
165 | + /** |
|
166 | + * @param string $salt_unsafe |
|
167 | + */ |
|
165 | 168 | public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) { |
166 | 169 | $result = parent::password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe); |
167 | 170 | if($result) { |
@@ -171,6 +174,9 @@ discard block |
||
171 | 174 | return $result; |
172 | 175 | } |
173 | 176 | |
177 | + /** |
|
178 | + * @param Account $account_to_impersonate |
|
179 | + */ |
|
174 | 180 | public function impersonate($account_to_impersonate) { |
175 | 181 | $this->cookie_set($account_to_impersonate); |
176 | 182 | } |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | $this->prepare(); |
94 | 94 | |
95 | 95 | $this->manifest['active'] = false; |
96 | - if(!empty($this->config) && is_array($this->config['db'])) { |
|
96 | + if (!empty($this->config) && is_array($this->config['db'])) { |
|
97 | 97 | // БД, отличная от стандартной |
98 | 98 | $this->db = new db_mysql(); |
99 | 99 | |
100 | 100 | $this->db->sn_db_connect($this->config['db']); |
101 | - if($this->manifest['active'] = $this->db->connected) { |
|
101 | + if ($this->manifest['active'] = $this->db->connected) { |
|
102 | 102 | $this->provider_id = ACCOUNT_PROVIDER_CENTRAL; |
103 | 103 | |
104 | 104 | $this->domain = $this->config['domain']; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | // Fallback to local DB |
115 | - if(!$this->manifest['active']) { |
|
115 | + if (!$this->manifest['active']) { |
|
116 | 116 | $this->db = classSupernova::$db; |
117 | 117 | |
118 | 118 | $this->provider_id = ACCOUNT_PROVIDER_LOCAL; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $this->manifest['active'] = true; |
126 | 126 | } |
127 | 127 | |
128 | - $this->cookie_name_impersonate = $this->cookie_name . AUTH_COOKIE_IMPERSONATE_SUFFIX; |
|
128 | + $this->cookie_name_impersonate = $this->cookie_name.AUTH_COOKIE_IMPERSONATE_SUFFIX; |
|
129 | 129 | |
130 | 130 | $this->account = new Account($this->db); |
131 | 131 | $this->confirmation = new Confirmation($this->db); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | // OK v4.5 |
167 | 167 | public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) { |
168 | 168 | $result = parent::password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe); |
169 | - if($result) { |
|
169 | + if ($result) { |
|
170 | 170 | $this->cookie_set(); |
171 | 171 | } |
172 | 172 | |
@@ -194,12 +194,12 @@ discard block |
||
194 | 194 | */ |
195 | 195 | // OK v4.6 |
196 | 196 | protected function password_reset_send_code() { |
197 | - if(!$this->is_password_reset) { |
|
197 | + if (!$this->is_password_reset) { |
|
198 | 198 | return $this->account_login_status; |
199 | 199 | } |
200 | 200 | |
201 | 201 | // Проверяем поддержку сброса пароля |
202 | - if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
202 | + if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
203 | 203 | return $this->account_login_status; |
204 | 204 | } |
205 | 205 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | unset($this->account); |
210 | 210 | $this->account = new Account($this->db); |
211 | 211 | |
212 | - if(!$this->account->db_get_by_email($email_unsafe)) { |
|
212 | + if (!$this->account->db_get_by_email($email_unsafe)) { |
|
213 | 213 | throw new Exception(PASSWORD_RESTORE_ERROR_EMAIL_NOT_EXISTS, ERR_ERROR); |
214 | 214 | // return $this->account_login_status; |
215 | 215 | } |
@@ -219,14 +219,14 @@ discard block |
||
219 | 219 | |
220 | 220 | // TODO - Проверять уровень доступа аккаунта! |
221 | 221 | // Аккаунты с АУТЛЕВЕЛ больше 0 - НЕ СБРАСЫВАЮТ ПАРОЛИ! |
222 | - foreach($user_list as $user_id => $user_data) { |
|
223 | - if($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) { |
|
222 | + foreach ($user_list as $user_id => $user_data) { |
|
223 | + if ($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) { |
|
224 | 224 | throw new Exception(PASSWORD_RESTORE_ERROR_ADMIN_ACCOUNT, ERR_ERROR); |
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | 228 | $confirmation = $this->confirmation->db_confirmation_get_latest_by_type_and_email(CONFIRM_PASSWORD_RESET, $email_unsafe); // OK 4.5 |
229 | - if(isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) { |
|
229 | + if (isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) { |
|
230 | 230 | throw new Exception(PASSWORD_RESTORE_ERROR_TOO_OFTEN, ERR_ERROR); |
231 | 231 | } |
232 | 232 | |
@@ -239,11 +239,11 @@ discard block |
||
239 | 239 | |
240 | 240 | @$result = mymail($email_unsafe, |
241 | 241 | sprintf(classLocale::$lang['log_lost_email_title'], classSupernova::$config->game_name), |
242 | - sprintf(classLocale::$lang['log_lost_email_code'], SN_ROOT_VIRTUAL . 'login.php', $confirm_code_unsafe, date(FMT_DATE_TIME, SN_TIME_NOW + AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE), classSupernova::$config->game_name) |
|
242 | + sprintf(classLocale::$lang['log_lost_email_code'], SN_ROOT_VIRTUAL.'login.php', $confirm_code_unsafe, date(FMT_DATE_TIME, SN_TIME_NOW + AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE), classSupernova::$config->game_name) |
|
243 | 243 | ); |
244 | 244 | |
245 | 245 | $result = $result ? PASSWORD_RESTORE_SUCCESS_CODE_SENT : PASSWORD_RESTORE_ERROR_SENDING; |
246 | - } catch(Exception $e) { |
|
246 | + } catch (Exception $e) { |
|
247 | 247 | sn_db_transaction_rollback(); |
248 | 248 | $result = $e->getMessage(); |
249 | 249 | } |
@@ -256,46 +256,46 @@ discard block |
||
256 | 256 | * @return int|string |
257 | 257 | */ |
258 | 258 | protected function password_reset_confirm() { |
259 | - if(!$this->is_password_reset_confirm) { |
|
259 | + if (!$this->is_password_reset_confirm) { |
|
260 | 260 | return $this->account_login_status; |
261 | 261 | } |
262 | 262 | |
263 | - if($this->account_login_status != LOGIN_UNDEFINED) { |
|
263 | + if ($this->account_login_status != LOGIN_UNDEFINED) { |
|
264 | 264 | return $this->account_login_status; |
265 | 265 | } |
266 | 266 | |
267 | 267 | // Проверяем поддержку сброса пароля |
268 | - if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
268 | + if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
269 | 269 | return $this->account_login_status; |
270 | 270 | } |
271 | 271 | |
272 | 272 | try { |
273 | 273 | $code_unsafe = sys_get_param_str_unsafe('password_reset_code'); |
274 | - if(empty($code_unsafe)) { |
|
274 | + if (empty($code_unsafe)) { |
|
275 | 275 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_EMPTY, ERR_ERROR); |
276 | 276 | } |
277 | 277 | |
278 | 278 | sn_db_transaction_start(); |
279 | 279 | $confirmation = $this->confirmation->db_confirmation_get_by_type_and_code(CONFIRM_PASSWORD_RESET, $code_unsafe); // OK 4.5 |
280 | 280 | |
281 | - if(empty($confirmation)) { |
|
281 | + if (empty($confirmation)) { |
|
282 | 282 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_WRONG, ERR_ERROR); |
283 | 283 | } |
284 | 284 | |
285 | - if(SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) { |
|
285 | + if (SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) { |
|
286 | 286 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_TOO_OLD, ERR_ERROR); |
287 | 287 | } |
288 | 288 | |
289 | 289 | unset($this->account); |
290 | 290 | $this->account = new Account($this->db); |
291 | 291 | |
292 | - if(!$this->account->db_get_by_email($confirmation['email'])) { |
|
292 | + if (!$this->account->db_get_by_email($confirmation['email'])) { |
|
293 | 293 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_OK_BUT_NO_ACCOUNT_FOR_EMAIL, ERR_ERROR); |
294 | 294 | } |
295 | 295 | |
296 | 296 | $new_password_unsafe = $this->make_random_password(); |
297 | 297 | $salt_unsafe = $this->password_salt_generate(); |
298 | - if(!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) { |
|
298 | + if (!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) { |
|
299 | 299 | // Ошибка смены пароля |
300 | 300 | throw new Exception(AUTH_ERROR_INTERNAL_PASSWORD_CHANGE_ON_RESTORE, ERR_ERROR); |
301 | 301 | } |
@@ -305,14 +305,14 @@ discard block |
||
305 | 305 | $this->cookie_set(); |
306 | 306 | $this->login_cookie(); |
307 | 307 | |
308 | - if($this->account_login_status == LOGIN_SUCCESS) { |
|
308 | + if ($this->account_login_status == LOGIN_SUCCESS) { |
|
309 | 309 | // TODO - НЕ ОБЯЗАТЕЛЬНО ОТПРАВЛЯТЬ ЧЕРЕЗ ЕМЕЙЛ! ЕСЛИ ЭТО ФЕЙСБУЧЕК ИЛИ ВКШЕЧКА - МОЖНО ЧЕРЕЗ ЛС ПИСАТЬ!! |
310 | 310 | $message_header = sprintf(classLocale::$lang['log_lost_email_title'], classSupernova::$config->game_name); |
311 | 311 | $message = sprintf(classLocale::$lang['log_lost_email_pass'], classSupernova::$config->game_name, $this->account->account_name, $new_password_unsafe); |
312 | 312 | @$operation_result = mymail($confirmation['email'], $message_header, htmlspecialchars($message)); |
313 | 313 | |
314 | 314 | $users_translated = PlayerToAccountTranslate::db_translate_get_users_from_account_list($this->provider_id, $this->account->account_id); // OK 4.5 |
315 | - if(!empty($users_translated)) { |
|
315 | + if (!empty($users_translated)) { |
|
316 | 316 | // Отправляем в лички письмо о сбросе пароля |
317 | 317 | |
318 | 318 | // ПО ОПРЕДЕЛЕНИЮ в $users_translated только |
@@ -321,9 +321,9 @@ discard block |
||
321 | 321 | // - игроки, привязанные только к этим аккаунтам |
322 | 322 | // Значит им всем сразу скопом можно отправлять сообщения |
323 | 323 | $message = sprintf(classLocale::$lang['sys_password_reset_message_body'], $new_password_unsafe); |
324 | - $message = sys_bbcodeParse($message) . '<br><br>'; |
|
324 | + $message = sys_bbcodeParse($message).'<br><br>'; |
|
325 | 325 | |
326 | - foreach($users_translated as $user_id => $providers_list) { |
|
326 | + foreach ($users_translated as $user_id => $providers_list) { |
|
327 | 327 | msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN, classLocale::$lang['sys_administration'], classLocale::$lang['sys_login_register_message_title'], $message); |
328 | 328 | } |
329 | 329 | } else { |
@@ -375,10 +375,10 @@ discard block |
||
375 | 375 | // OK v4.5 |
376 | 376 | protected function register() { |
377 | 377 | // TODO РЕГИСТРАЦИЯ ВСЕГДА ДОЛЖНА ЛОГИНИТЬ ПОЛЬЗОВАТЕЛЯ! |
378 | - $this->flog('Регистрация: начинаем. Провайдер ' . $this->provider_id); |
|
378 | + $this->flog('Регистрация: начинаем. Провайдер '.$this->provider_id); |
|
379 | 379 | |
380 | 380 | try { |
381 | - if(!$this->is_register) { |
|
381 | + if (!$this->is_register) { |
|
382 | 382 | $this->flog('Регистрация: не выставлен флаг регистрации - пропускаем'); |
383 | 383 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
384 | 384 | } |
@@ -388,8 +388,8 @@ discard block |
||
388 | 388 | sn_db_transaction_start(); |
389 | 389 | |
390 | 390 | $this->account->db_get_by_name_or_email($this->input_login_unsafe, $this->input_email_unsafe); |
391 | - if($this->account->is_exists) { |
|
392 | - if($this->account->account_email == $this->input_email_unsafe) { |
|
391 | + if ($this->account->is_exists) { |
|
392 | + if ($this->account->account_email == $this->input_email_unsafe) { |
|
393 | 393 | throw new Exception(REGISTER_ERROR_EMAIL_EXISTS, ERR_ERROR); |
394 | 394 | } else { |
395 | 395 | throw new Exception(REGISTER_ERROR_ACCOUNT_NAME_EXISTS, ERR_ERROR); |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | // А вот это пока не нужно. Трансляцией аккаунтов в юзеров и созданием новых юзеров для новозашедших аккаунтов занимается Auth |
412 | 412 | // $this->register_account(); |
413 | 413 | sn_db_transaction_commit(); |
414 | - } catch(Exception $e) { |
|
414 | + } catch (Exception $e) { |
|
415 | 415 | sn_db_transaction_rollback(); |
416 | 416 | $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false; |
417 | 417 | } |
@@ -427,19 +427,19 @@ discard block |
||
427 | 427 | */ |
428 | 428 | // OK v4.5 |
429 | 429 | protected function login_cookie() { |
430 | - if($this->account_login_status != LOGIN_UNDEFINED) { |
|
430 | + if ($this->account_login_status != LOGIN_UNDEFINED) { |
|
431 | 431 | return $this->account_login_status; |
432 | 432 | } |
433 | 433 | |
434 | 434 | // Пытаемся войти по куке |
435 | - if(!empty($_COOKIE[$this->cookie_name])) { |
|
436 | - if(count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
435 | + if (!empty($_COOKIE[$this->cookie_name])) { |
|
436 | + if (count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
437 | 437 | list($account_id_unsafe, $cookie_password_hash_salted, $user_remember_me) = explode(AUTH_COOKIE_DELIMETER, $_COOKIE[$this->cookie_name]); |
438 | 438 | } else { |
439 | 439 | list($account_id_unsafe, $user_name, $cookie_password_hash_salted, $user_remember_me) = explode("/%/", $_COOKIE[$this->cookie_name]); |
440 | 440 | } |
441 | 441 | |
442 | - if( |
|
442 | + if ( |
|
443 | 443 | $this->account->db_get_by_id($account_id_unsafe) |
444 | 444 | && ($this->password_encode_for_cookie($this->account->account_password) == $cookie_password_hash_salted) |
445 | 445 | ) { |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
451 | - if($this->account_login_status != LOGIN_SUCCESS) { |
|
451 | + if ($this->account_login_status != LOGIN_SUCCESS) { |
|
452 | 452 | // Невалидная кука - чистим |
453 | 453 | $this->cookie_clear(); |
454 | 454 | } |
@@ -466,29 +466,29 @@ discard block |
||
466 | 466 | protected function login_username() { |
467 | 467 | // TODO - Логин по старым именам |
468 | 468 | try { |
469 | - if(!$this->is_login) { |
|
469 | + if (!$this->is_login) { |
|
470 | 470 | $this->flog('Логин: не выставлен флаг входа в игру - это не логин'); |
471 | 471 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
472 | 472 | } |
473 | 473 | |
474 | 474 | // TODO Пустое имя аккаунта |
475 | - if(!$this->input_login_unsafe) { |
|
475 | + if (!$this->input_login_unsafe) { |
|
476 | 476 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
477 | 477 | } |
478 | 478 | |
479 | 479 | $this->login_validate_input(); |
480 | 480 | |
481 | - if(!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) { |
|
481 | + if (!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) { |
|
482 | 482 | throw new Exception(LOGIN_ERROR_USERNAME, ERR_ERROR); |
483 | 483 | } |
484 | 484 | |
485 | - if(!$this->account->password_check($this->input_login_password_raw)) { |
|
485 | + if (!$this->account->password_check($this->input_login_password_raw)) { |
|
486 | 486 | throw new Exception(LOGIN_ERROR_PASSWORD, ERR_ERROR); |
487 | 487 | } |
488 | 488 | |
489 | 489 | $this->cookie_set(); |
490 | 490 | $this->account_login_status = LOGIN_SUCCESS; |
491 | - } catch(Exception $e) { |
|
491 | + } catch (Exception $e) { |
|
492 | 492 | $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false; |
493 | 493 | } |
494 | 494 | |
@@ -510,18 +510,18 @@ discard block |
||
510 | 510 | protected function cookie_set($account_to_impersonate = null) { |
511 | 511 | $this_account = is_object($account_to_impersonate) ? $account_to_impersonate : $this->account; |
512 | 512 | |
513 | - if(!is_object($this_account) || !$this_account->is_exists) { |
|
513 | + if (!is_object($this_account) || !$this_account->is_exists) { |
|
514 | 514 | throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR); |
515 | 515 | } |
516 | 516 | |
517 | - if(is_object($account_to_impersonate) && $account_to_impersonate->is_exists) { |
|
517 | + if (is_object($account_to_impersonate) && $account_to_impersonate->is_exists) { |
|
518 | 518 | sn_setcookie($this->cookie_name_impersonate, $_COOKIE[$this->cookie_name], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $this->domain); |
519 | 519 | } |
520 | 520 | |
521 | 521 | $expire_time = $this->remember_me ? SN_TIME_NOW + PERIOD_YEAR : 0; |
522 | 522 | |
523 | 523 | $password_encoded = $this->password_encode_for_cookie($this_account->account_password); |
524 | - $cookie = $this_account->account_id . AUTH_COOKIE_DELIMETER . $password_encoded . AUTH_COOKIE_DELIMETER . $this->remember_me; |
|
524 | + $cookie = $this_account->account_id.AUTH_COOKIE_DELIMETER.$password_encoded.AUTH_COOKIE_DELIMETER.$this->remember_me; |
|
525 | 525 | $this->flog("cookie_set() - Устанавливаем куку {$cookie}"); |
526 | 526 | return sn_setcookie($this->cookie_name, $cookie, $expire_time, $this->sn_root_path, $this->domain); |
527 | 527 | } |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | // OK v4.1 |
533 | 533 | protected function cookie_clear() { |
534 | 534 | // Автоматически вообще-то - если установлена кука имперсонатора - то чистим обычную, а куку имперсонатора - копируем в неё |
535 | - if(!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
535 | + if (!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
536 | 536 | sn_setcookie($this->cookie_name, $_COOKIE[$this->cookie_name_impersonate], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $this->domain); |
537 | 537 | sn_setcookie($this->cookie_name_impersonate, '', SN_TIME_NOW - PERIOD_WEEK, $this->sn_root_path, $this->domain); |
538 | 538 | } else { |
@@ -551,10 +551,10 @@ discard block |
||
551 | 551 | protected function login_validate_input() { |
552 | 552 | // Проверяем, что бы в начале и конце не было пустых символов |
553 | 553 | // TODO - при копировании Эксель -> Опера - в конце образуются пустые места. Это не должно быть проблемой! Вынести проверку пароля в регистрацию! |
554 | - if($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
554 | + if ($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
555 | 555 | throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR); |
556 | 556 | } |
557 | - if(!$this->input_login_password_raw) { |
|
557 | + if (!$this->input_login_password_raw) { |
|
558 | 558 | throw new Exception(LOGIN_ERROR_PASSWORD_EMPTY, ERR_ERROR); |
559 | 559 | } |
560 | 560 | } |
@@ -570,37 +570,37 @@ discard block |
||
570 | 570 | $this->login_validate_input(); |
571 | 571 | |
572 | 572 | // Если нет имени пользователя - NO GO! |
573 | - if(!$this->input_login_unsafe) { |
|
573 | + if (!$this->input_login_unsafe) { |
|
574 | 574 | throw new Exception(LOGIN_ERROR_USERNAME_EMPTY, ERR_ERROR); |
575 | 575 | } |
576 | 576 | // Если логин имеет запрещенные символы - NO GO! |
577 | - if(strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
577 | + if (strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
578 | 578 | throw new Exception(LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS, ERR_ERROR); |
579 | 579 | } |
580 | 580 | // Если логин меньше минимальной длины - NO GO! |
581 | - if(strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) { |
|
581 | + if (strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) { |
|
582 | 582 | throw new Exception(REGISTER_ERROR_USERNAME_SHORT, ERR_ERROR); |
583 | 583 | } |
584 | 584 | // Если пароль меньше минимальной длины - NO GO! |
585 | - if(strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) { |
|
585 | + if (strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) { |
|
586 | 586 | throw new Exception(REGISTER_ERROR_PASSWORD_INSECURE, ERR_ERROR); |
587 | 587 | } |
588 | 588 | // Если пароль имеет пробельные символы в начале или конце - NO GO! |
589 | - if($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
589 | + if ($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
590 | 590 | throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR); |
591 | 591 | } |
592 | 592 | // Если пароль не совпадает с подтверждением - NO GO! То, что у пароля нет пробельных символов в начале/конце - мы уже проверили выше |
593 | 593 | //Если они есть у повтора - значит пароль и повтор не совпадут |
594 | - if($this->input_login_password_raw <> $this->input_login_password_raw_repeat) { |
|
594 | + if ($this->input_login_password_raw <> $this->input_login_password_raw_repeat) { |
|
595 | 595 | throw new Exception(REGISTER_ERROR_PASSWORD_DIFFERENT, ERR_ERROR); |
596 | 596 | } |
597 | 597 | // Если нет емейла - NO GO! |
598 | 598 | // TODO - регистрация без емейла |
599 | - if(!$this->input_email_unsafe) { |
|
599 | + if (!$this->input_email_unsafe) { |
|
600 | 600 | throw new Exception(REGISTER_ERROR_EMAIL_EMPTY, ERR_ERROR); |
601 | 601 | } |
602 | 602 | // Если емейл не является емейлом - NO GO! |
603 | - if(!is_email($this->input_email_unsafe)) { |
|
603 | + if (!is_email($this->input_email_unsafe)) { |
|
604 | 604 | throw new Exception(REGISTER_ERROR_EMAIL_WRONG, ERR_ERROR); |
605 | 605 | } |
606 | 606 | } |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | |
610 | 610 | // OK v4 |
611 | 611 | protected function password_encode_for_cookie($password) { |
612 | - return md5("{$password}--" . $this->secret_word); |
|
612 | + return md5("{$password}--".$this->secret_word); |
|
613 | 613 | } |
614 | 614 | // OK v4 |
615 | 615 | protected function password_encode($password, $salt) { |
@@ -629,22 +629,22 @@ discard block |
||
629 | 629 | return core_auth::make_random_password(); |
630 | 630 | } |
631 | 631 | protected function flog($message, $die = false) { |
632 | - if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
632 | + if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
633 | 633 | return; |
634 | 634 | } |
635 | 635 | list($called, $caller) = debug_backtrace(false); |
636 | 636 | |
637 | 637 | $caller_name = |
638 | - ((get_called_class()) ? get_called_class() : (!empty($caller['class']) ? $caller['class'] : '')) . |
|
639 | - (!empty($caller['type']) ? $caller['type'] : '') . |
|
640 | - (!empty($caller['function']) ? $caller['function'] : '') . |
|
641 | - (!empty($called['line']) ? ':' . $called['line'] : ''); |
|
638 | + ((get_called_class()) ? get_called_class() : (!empty($caller['class']) ? $caller['class'] : '')). |
|
639 | + (!empty($caller['type']) ? $caller['type'] : ''). |
|
640 | + (!empty($caller['function']) ? $caller['function'] : ''). |
|
641 | + (!empty($called['line']) ? ':'.$called['line'] : ''); |
|
642 | 642 | |
643 | 643 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
644 | 644 | |
645 | 645 | classSupernova::log_file("$message - $caller_name"); |
646 | - if($die) { |
|
647 | - $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
|
646 | + if ($die) { |
|
647 | + $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в ".get_called_class()." (располагается в ".get_class()."). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
|
648 | 648 | } |
649 | 649 | } |
650 | 650 |