@@ -96,12 +96,12 @@ discard block |
||
| 96 | 96 | $this->prepare(); |
| 97 | 97 | |
| 98 | 98 | $this->manifest['active'] = false; |
| 99 | - if(!empty($this->config) && is_array($this->config['db'])) { |
|
| 99 | + if (!empty($this->config) && is_array($this->config['db'])) { |
|
| 100 | 100 | // БД, отличная от стандартной |
| 101 | 101 | $this->db = new db_mysql(); |
| 102 | 102 | |
| 103 | 103 | $this->db->sn_db_connect($this->config['db']); |
| 104 | - if($this->manifest['active'] = $this->db->connected) { |
|
| 104 | + if ($this->manifest['active'] = $this->db->connected) { |
|
| 105 | 105 | $this->provider_id = ACCOUNT_PROVIDER_CENTRAL; |
| 106 | 106 | |
| 107 | 107 | $this->domain = $this->config['domain']; |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | // Fallback to local DB |
| 118 | - if(!$this->manifest['active']) { |
|
| 118 | + if (!$this->manifest['active']) { |
|
| 119 | 119 | $this->db = SN::$db; |
| 120 | 120 | |
| 121 | 121 | $this->provider_id = ACCOUNT_PROVIDER_LOCAL; |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) { |
| 171 | 171 | $result = parent::password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe); |
| 172 | - if($result) { |
|
| 172 | + if ($result) { |
|
| 173 | 173 | $this->cookie_set(); |
| 174 | 174 | } |
| 175 | 175 | |
@@ -198,12 +198,12 @@ discard block |
||
| 198 | 198 | protected function password_reset_send_code() { |
| 199 | 199 | global $lang, $config; |
| 200 | 200 | |
| 201 | - if(!$this->is_password_reset) { |
|
| 201 | + if (!$this->is_password_reset) { |
|
| 202 | 202 | return $this->account_login_status; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | // Проверяем поддержку сброса пароля |
| 206 | - if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
| 206 | + if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
| 207 | 207 | return $this->account_login_status; |
| 208 | 208 | } |
| 209 | 209 | |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | unset($this->account); |
| 214 | 214 | $this->account = new Account($this->db); |
| 215 | 215 | |
| 216 | - if(!$this->account->db_get_by_email($email_unsafe)) { |
|
| 216 | + if (!$this->account->db_get_by_email($email_unsafe)) { |
|
| 217 | 217 | throw new Exception(PASSWORD_RESTORE_ERROR_EMAIL_NOT_EXISTS, ERR_ERROR); |
| 218 | 218 | // return $this->account_login_status; |
| 219 | 219 | } |
@@ -223,14 +223,14 @@ discard block |
||
| 223 | 223 | |
| 224 | 224 | // TODO - Проверять уровень доступа аккаунта! |
| 225 | 225 | // Аккаунты с АУТЛЕВЕЛ больше 0 - НЕ СБРАСЫВАЮТ ПАРОЛИ! |
| 226 | - foreach($user_list as $user_id => $user_data) { |
|
| 227 | - if($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) { |
|
| 226 | + foreach ($user_list as $user_id => $user_data) { |
|
| 227 | + if ($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) { |
|
| 228 | 228 | throw new Exception(PASSWORD_RESTORE_ERROR_ADMIN_ACCOUNT, ERR_ERROR); |
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | $confirmation = $this->confirmation->db_confirmation_get_latest_by_type_and_email(CONFIRM_PASSWORD_RESET, $email_unsafe); // OK 4.5 |
| 233 | - if(isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) { |
|
| 233 | + if (isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) { |
|
| 234 | 234 | throw new Exception(PASSWORD_RESTORE_ERROR_TOO_OFTEN, ERR_ERROR); |
| 235 | 235 | } |
| 236 | 236 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | $confirm_code_unsafe = $this->confirmation->db_confirmation_get_unique_code_by_type_and_email(CONFIRM_PASSWORD_RESET, $email_unsafe); // OK 4.5 |
| 242 | 242 | sn_db_transaction_commit(); |
| 243 | 243 | |
| 244 | - if(!is_email($email_unsafe)) { |
|
| 244 | + if (!is_email($email_unsafe)) { |
|
| 245 | 245 | SN::$debug->error("Email is invalid: '{$email_unsafe}'", 'Invalid email for password restoration'); |
| 246 | 246 | } |
| 247 | 247 | |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | ); |
| 252 | 252 | |
| 253 | 253 | $result = $result ? PASSWORD_RESTORE_SUCCESS_CODE_SENT : PASSWORD_RESTORE_ERROR_SENDING; |
| 254 | - } catch(Exception $e) { |
|
| 254 | + } catch (Exception $e) { |
|
| 255 | 255 | sn_db_transaction_rollback(); |
| 256 | 256 | $result = $e->getMessage(); |
| 257 | 257 | } |
@@ -266,46 +266,46 @@ discard block |
||
| 266 | 266 | protected function password_reset_confirm() { |
| 267 | 267 | global $lang, $config; |
| 268 | 268 | |
| 269 | - if(!$this->is_password_reset_confirm) { |
|
| 269 | + if (!$this->is_password_reset_confirm) { |
|
| 270 | 270 | return $this->account_login_status; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - if($this->account_login_status != LOGIN_UNDEFINED) { |
|
| 273 | + if ($this->account_login_status != LOGIN_UNDEFINED) { |
|
| 274 | 274 | return $this->account_login_status; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | // Проверяем поддержку сброса пароля |
| 278 | - if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
| 278 | + if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
| 279 | 279 | return $this->account_login_status; |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | try { |
| 283 | 283 | $code_unsafe = sys_get_param_str_unsafe('password_reset_code'); |
| 284 | - if(empty($code_unsafe)) { |
|
| 284 | + if (empty($code_unsafe)) { |
|
| 285 | 285 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_EMPTY, ERR_ERROR); |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | sn_db_transaction_start(); |
| 289 | 289 | $confirmation = $this->confirmation->db_confirmation_get_by_type_and_code(CONFIRM_PASSWORD_RESET, $code_unsafe); // OK 4.5 |
| 290 | 290 | |
| 291 | - if(empty($confirmation)) { |
|
| 291 | + if (empty($confirmation)) { |
|
| 292 | 292 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_WRONG, ERR_ERROR); |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - if(SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) { |
|
| 295 | + if (SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) { |
|
| 296 | 296 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_TOO_OLD, ERR_ERROR); |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | unset($this->account); |
| 300 | 300 | $this->account = new Account($this->db); |
| 301 | 301 | |
| 302 | - if(!$this->account->db_get_by_email($confirmation['email'])) { |
|
| 302 | + if (!$this->account->db_get_by_email($confirmation['email'])) { |
|
| 303 | 303 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_OK_BUT_NO_ACCOUNT_FOR_EMAIL, ERR_ERROR); |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | $new_password_unsafe = $this->make_random_password(); |
| 307 | 307 | $salt_unsafe = $this->password_salt_generate(); |
| 308 | - if(!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) { |
|
| 308 | + if (!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) { |
|
| 309 | 309 | // Ошибка смены пароля |
| 310 | 310 | throw new Exception(AUTH_ERROR_INTERNAL_PASSWORD_CHANGE_ON_RESTORE, ERR_ERROR); |
| 311 | 311 | } |
@@ -315,14 +315,14 @@ discard block |
||
| 315 | 315 | $this->cookie_set(); |
| 316 | 316 | $this->login_cookie(); |
| 317 | 317 | |
| 318 | - if($this->account_login_status == LOGIN_SUCCESS) { |
|
| 318 | + if ($this->account_login_status == LOGIN_SUCCESS) { |
|
| 319 | 319 | // TODO - НЕ ОБЯЗАТЕЛЬНО ОТПРАВЛЯТЬ ЧЕРЕЗ ЕМЕЙЛ! ЕСЛИ ЭТО ФЕЙСБУЧЕК ИЛИ ВКШЕЧКА - МОЖНО ЧЕРЕЗ ЛС ПИСАТЬ!! |
| 320 | 320 | $message_header = sprintf($lang['log_lost_email_title'], $config->game_name); |
| 321 | 321 | $message = sprintf($lang['log_lost_email_pass'], $config->game_name, $this->account->account_name, $new_password_unsafe); |
| 322 | 322 | @$operation_result = mymail($confirmation['email'], $message_header, htmlspecialchars($message)); |
| 323 | 323 | |
| 324 | 324 | $users_translated = PlayerToAccountTranslate::db_translate_get_users_from_account_list($this->provider_id, $this->account->account_id); // OK 4.5 |
| 325 | - if(!empty($users_translated)) { |
|
| 325 | + if (!empty($users_translated)) { |
|
| 326 | 326 | // Отправляем в лички письмо о сбросе пароля |
| 327 | 327 | |
| 328 | 328 | // ПО ОПРЕДЕЛЕНИЮ в $users_translated только |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | $message = HelperString::nl2br($message) . '<br><br>'; |
| 335 | 335 | // msg_send_simple_message($found_provider->data[F_USER_ID], 0, SN_TIME_NOW, MSG_TYPE_ADMIN, $lang['sys_administration'], $lang['sys_login_register_message_title'], $message); |
| 336 | 336 | |
| 337 | - foreach($users_translated as $user_id => $providers_list) { |
|
| 337 | + foreach ($users_translated as $user_id => $providers_list) { |
|
| 338 | 338 | msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN, $lang['sys_administration'], $lang['sys_login_register_message_title'], $message); |
| 339 | 339 | } |
| 340 | 340 | } else { |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | $this->flog('Регистрация: начинаем. Провайдер ' . $this->provider_id); |
| 388 | 388 | |
| 389 | 389 | try { |
| 390 | - if(!$this->is_register) { |
|
| 390 | + if (!$this->is_register) { |
|
| 391 | 391 | $this->flog('Регистрация: не выставлен флаг регистрации - пропускаем'); |
| 392 | 392 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
| 393 | 393 | } |
@@ -399,8 +399,8 @@ discard block |
||
| 399 | 399 | // $this->account_check_duplicate_name_or_email($this->input_login_unsafe, $this->input_email_unsafe); |
| 400 | 400 | |
| 401 | 401 | $this->account->db_get_by_name_or_email($this->input_login_unsafe, $this->input_email_unsafe); |
| 402 | - if($this->account->is_exists) { |
|
| 403 | - if($this->account->account_email == $this->input_email_unsafe) { |
|
| 402 | + if ($this->account->is_exists) { |
|
| 403 | + if ($this->account->account_email == $this->input_email_unsafe) { |
|
| 404 | 404 | throw new Exception(REGISTER_ERROR_EMAIL_EXISTS, ERR_ERROR); |
| 405 | 405 | } else { |
| 406 | 406 | throw new Exception(REGISTER_ERROR_ACCOUNT_NAME_EXISTS, ERR_ERROR); |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | // А вот это пока не нужно. Трансляцией аккаунтов в юзеров и созданием новых юзеров для новозашедших аккаунтов занимается Auth |
| 440 | 440 | // $this->register_account(); |
| 441 | 441 | sn_db_transaction_commit(); |
| 442 | - } catch(Exception $e) { |
|
| 442 | + } catch (Exception $e) { |
|
| 443 | 443 | sn_db_transaction_rollback(); |
| 444 | 444 | $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false; |
| 445 | 445 | } |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | * @return int Результат попытки |
| 455 | 455 | */ |
| 456 | 456 | protected function login_cookie() { |
| 457 | - if($this->account_login_status != LOGIN_UNDEFINED) { |
|
| 457 | + if ($this->account_login_status != LOGIN_UNDEFINED) { |
|
| 458 | 458 | return $this->account_login_status; |
| 459 | 459 | } |
| 460 | 460 | |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | // $this->cookie_clear(); |
| 481 | 481 | // } |
| 482 | 482 | |
| 483 | - if($this->account->cookieLogin($rememberMe)) { |
|
| 483 | + if ($this->account->cookieLogin($rememberMe)) { |
|
| 484 | 484 | $this->account_login_status = LOGIN_SUCCESS; |
| 485 | 485 | $this->remember_me = intval($rememberMe); |
| 486 | 486 | } |
@@ -497,13 +497,13 @@ discard block |
||
| 497 | 497 | protected function login_username() { |
| 498 | 498 | // TODO - Логин по старым именам |
| 499 | 499 | try { |
| 500 | - if(!$this->is_login) { |
|
| 500 | + if (!$this->is_login) { |
|
| 501 | 501 | $this->flog('Логин: не выставлен флаг входа в игру - это не логин'); |
| 502 | 502 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | // TODO Пустое имя аккаунта |
| 506 | - if(!$this->input_login_unsafe) { |
|
| 506 | + if (!$this->input_login_unsafe) { |
|
| 507 | 507 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
| 508 | 508 | } |
| 509 | 509 | |
@@ -513,11 +513,11 @@ discard block |
||
| 513 | 513 | // if(empty($account)) { |
| 514 | 514 | // throw new Exception(LOGIN_ERROR_USERNAME, ERR_ERROR); |
| 515 | 515 | // } |
| 516 | - if(!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) { |
|
| 516 | + if (!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) { |
|
| 517 | 517 | throw new Exception(LOGIN_ERROR_USERNAME, ERR_ERROR); |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - if(!$this->account->password_check($this->input_login_password_raw)) { |
|
| 520 | + if (!$this->account->password_check($this->input_login_password_raw)) { |
|
| 521 | 521 | throw new Exception(LOGIN_ERROR_PASSWORD, ERR_ERROR); |
| 522 | 522 | } |
| 523 | 523 | |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | |
| 526 | 526 | $this->cookie_set(); |
| 527 | 527 | $this->account_login_status = LOGIN_SUCCESS; |
| 528 | - } catch(Exception $e) { |
|
| 528 | + } catch (Exception $e) { |
|
| 529 | 529 | $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false; |
| 530 | 530 | } |
| 531 | 531 | |
@@ -546,11 +546,11 @@ discard block |
||
| 546 | 546 | protected function cookie_set($account_to_impersonate = null) { |
| 547 | 547 | $this_account = is_object($account_to_impersonate) ? $account_to_impersonate : $this->account; |
| 548 | 548 | |
| 549 | - if(!is_object($this_account) || !$this_account->is_exists) { |
|
| 549 | + if (!is_object($this_account) || !$this_account->is_exists) { |
|
| 550 | 550 | throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR); |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | - if(is_object($account_to_impersonate) && $account_to_impersonate->is_exists) { |
|
| 553 | + if (is_object($account_to_impersonate) && $account_to_impersonate->is_exists) { |
|
| 554 | 554 | sn_setcookie($this->cookie_name_impersonate, $_COOKIE[$this->cookie_name], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $this->domain); |
| 555 | 555 | } |
| 556 | 556 | |
@@ -587,10 +587,10 @@ discard block |
||
| 587 | 587 | protected function login_validate_input() { |
| 588 | 588 | // Проверяем, что бы в начале и конце не было пустых символов |
| 589 | 589 | // TODO - при копировании Эксель -> Опера - в конце образуются пустые места. Это не должно быть проблемой! Вынести проверку пароля в регистрацию! |
| 590 | - if($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
| 590 | + if ($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
| 591 | 591 | throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR); |
| 592 | 592 | } |
| 593 | - if(!$this->input_login_password_raw) { |
|
| 593 | + if (!$this->input_login_password_raw) { |
|
| 594 | 594 | throw new Exception(LOGIN_ERROR_PASSWORD_EMPTY, ERR_ERROR); |
| 595 | 595 | } |
| 596 | 596 | } |
@@ -605,37 +605,37 @@ discard block |
||
| 605 | 605 | $this->login_validate_input(); |
| 606 | 606 | |
| 607 | 607 | // Если нет имени пользователя - NO GO! |
| 608 | - if(!$this->input_login_unsafe) { |
|
| 608 | + if (!$this->input_login_unsafe) { |
|
| 609 | 609 | throw new Exception(LOGIN_ERROR_USERNAME_EMPTY, ERR_ERROR); |
| 610 | 610 | } |
| 611 | 611 | // Если логин имеет запрещенные символы - NO GO! |
| 612 | - if(strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
| 612 | + if (strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
| 613 | 613 | throw new Exception(LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS, ERR_ERROR); |
| 614 | 614 | } |
| 615 | 615 | // Если логин меньше минимальной длины - NO GO! |
| 616 | - if(strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) { |
|
| 616 | + if (strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) { |
|
| 617 | 617 | throw new Exception(REGISTER_ERROR_USERNAME_SHORT, ERR_ERROR); |
| 618 | 618 | } |
| 619 | 619 | // Если пароль меньше минимальной длины - NO GO! |
| 620 | - if(strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) { |
|
| 620 | + if (strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) { |
|
| 621 | 621 | throw new Exception(REGISTER_ERROR_PASSWORD_INSECURE, ERR_ERROR); |
| 622 | 622 | } |
| 623 | 623 | // Если пароль имеет пробельные символы в начале или конце - NO GO! |
| 624 | - if($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
| 624 | + if ($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
| 625 | 625 | throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR); |
| 626 | 626 | } |
| 627 | 627 | // Если пароль не совпадает с подтверждением - NO GO! То, что у пароля нет пробельных символов в начале/конце - мы уже проверили выше |
| 628 | 628 | //Если они есть у повтора - значит пароль и повтор не совпадут |
| 629 | - if($this->input_login_password_raw <> $this->input_login_password_raw_repeat) { |
|
| 629 | + if ($this->input_login_password_raw <> $this->input_login_password_raw_repeat) { |
|
| 630 | 630 | throw new Exception(REGISTER_ERROR_PASSWORD_DIFFERENT, ERR_ERROR); |
| 631 | 631 | } |
| 632 | 632 | // Если нет емейла - NO GO! |
| 633 | 633 | // TODO - регистрация без емейла |
| 634 | - if(!$this->input_email_unsafe) { |
|
| 634 | + if (!$this->input_email_unsafe) { |
|
| 635 | 635 | throw new Exception(REGISTER_ERROR_EMAIL_EMPTY, ERR_ERROR); |
| 636 | 636 | } |
| 637 | 637 | // Если емейл не является емейлом - NO GO! |
| 638 | - if(!is_email($this->input_email_unsafe)) { |
|
| 638 | + if (!is_email($this->input_email_unsafe)) { |
|
| 639 | 639 | throw new Exception(REGISTER_ERROR_EMAIL_WRONG, ERR_ERROR); |
| 640 | 640 | } |
| 641 | 641 | } |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | return core_auth::make_random_password(); |
| 667 | 667 | } |
| 668 | 668 | protected function flog($message, $die = false) { |
| 669 | - if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
| 669 | + if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
| 670 | 670 | return; |
| 671 | 671 | } |
| 672 | 672 | list($called, $caller) = debug_backtrace(false); |
@@ -680,7 +680,7 @@ discard block |
||
| 680 | 680 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
| 681 | 681 | |
| 682 | 682 | SN::log_file("$message - $caller_name"); |
| 683 | - if($die) { |
|
| 683 | + if ($die) { |
|
| 684 | 684 | $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
| 685 | 685 | } |
| 686 | 686 | } |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | $this->secret_word = SN::$sn_secret_word; |
| 90 | 90 | |
| 91 | 91 | $snTableNames = $this->db->schema()->getSnTables(); |
| 92 | - foreach($this->table_check as $table_name) { |
|
| 93 | - if(empty($snTableNames[$table_name])) { |
|
| 92 | + foreach ($this->table_check as $table_name) { |
|
| 93 | + if (empty($snTableNames[$table_name])) { |
|
| 94 | 94 | die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br /> |
| 95 | 95 | В противном случае - сообщите Администрации сервера об ошибке.<br/> |
| 96 | 96 | Не хватает таблицы для работы системы авторизации: ' . $table_name); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | // OK v4.6 |
| 116 | 116 | public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) { |
| 117 | - if(!$this->password_check($old_password_unsafe)) { |
|
| 117 | + if (!$this->password_check($old_password_unsafe)) { |
|
| 118 | 118 | return false; |
| 119 | 119 | } |
| 120 | 120 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | // OK v4.5 |
| 136 | 136 | public function assign_from_db_row($row) { |
| 137 | 137 | $this->reset(); |
| 138 | - if(empty($row) || !is_array($row)) { |
|
| 138 | + if (empty($row) || !is_array($row)) { |
|
| 139 | 139 | return false; |
| 140 | 140 | } |
| 141 | 141 | $this->account_id = $row['account_id']; |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | $this->reset(); |
| 201 | 201 | |
| 202 | 202 | $email_safe = $this->db->db_escape($email_unsafe); |
| 203 | - if($email_safe) { |
|
| 203 | + if ($email_safe) { |
|
| 204 | 204 | $account_row = $this->db->doquery("SELECT * FROM {{account}} WHERE LOWER(`account_email`) = LOWER('{$email_safe}') FOR UPDATE;", true); |
| 205 | 205 | |
| 206 | 206 | return $this->assign_from_db_row($account_row); |
@@ -273,11 +273,11 @@ discard block |
||
| 273 | 273 | `account_email` = LOWER('{$email_safe}'), |
| 274 | 274 | `account_language` = '{$language_safe}'" |
| 275 | 275 | ); |
| 276 | - if(!$result) { |
|
| 276 | + if (!$result) { |
|
| 277 | 277 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - if(!($account_id = $this->db->db_insert_id())) { |
|
| 280 | + if (!($account_id = $this->db->db_insert_id())) { |
|
| 281 | 281 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
| 282 | 282 | } |
| 283 | 283 | |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | WHERE `account_id` = '{$account_id_safe}'" |
| 308 | 308 | ) ? true : false; |
| 309 | 309 | |
| 310 | - if($result) { |
|
| 310 | + if ($result) { |
|
| 311 | 311 | $result = $this->db_get_by_id($this->account_id); |
| 312 | 312 | } |
| 313 | 313 | |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | public function metamatter_change($change_type, $metamatter, $comment = false, $already_changed = false) { |
| 397 | 397 | global $debug, $mm_change_legit, $config, $sn_module; |
| 398 | 398 | |
| 399 | - if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
| 399 | + if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
| 400 | 400 | $debug->error('Ошибка при попытке манипуляции с ММ'); |
| 401 | 401 | return false; |
| 402 | 402 | } |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | |
| 406 | 406 | $mm_change_legit = true; |
| 407 | 407 | // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER); |
| 408 | - if($already_changed) { |
|
| 408 | + if ($already_changed) { |
|
| 409 | 409 | $metamatter_total_delta = 0; |
| 410 | 410 | $result = -1; |
| 411 | 411 | } else { |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$config->player_metamatter_immortal} AND `account_immortal` IS NULL, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '') . |
| 419 | 419 | " WHERE `account_id` = {$account_id_safe}" |
| 420 | 420 | ); |
| 421 | - if(!$result) { |
|
| 421 | + if (!$result) { |
|
| 422 | 422 | $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
| 423 | 423 | } |
| 424 | 424 | $result = SN::$db->db_affected_rows(); |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | $this->awardImmortal($metamatter, $config, $sn_module); |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - if(empty(core_auth::$user['id'])) { |
|
| 429 | + if (empty(core_auth::$user['id'])) { |
|
| 430 | 430 | $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id); |
| 431 | 431 | reset($user_list); |
| 432 | 432 | $user_id_unsafe = key($user_list); |
@@ -435,30 +435,30 @@ discard block |
||
| 435 | 435 | } |
| 436 | 436 | $user_id_safe = $this->db->db_escape($user_id_unsafe); |
| 437 | 437 | |
| 438 | - if(!$result) { |
|
| 438 | + if (!$result) { |
|
| 439 | 439 | $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - if(!$already_changed) { |
|
| 442 | + if (!$already_changed) { |
|
| 443 | 443 | $this->account_metamatter += $metamatter; |
| 444 | 444 | $this->account_metamatter_total += $metamatter_total_delta; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - if(is_array($comment)) { |
|
| 447 | + if (is_array($comment)) { |
|
| 448 | 448 | $comment = call_user_func_array('sprintf', $comment); |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe); |
| 452 | 452 | |
| 453 | - if($metamatter > 0 && !empty($user_id_safe)) { |
|
| 453 | + if ($metamatter > 0 && !empty($user_id_safe)) { |
|
| 454 | 454 | $old_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;", '', true); |
| 455 | - if($old_referral['id']) { |
|
| 455 | + if ($old_referral['id']) { |
|
| 456 | 456 | $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM; |
| 457 | 457 | doquery("UPDATE {{referrals}} SET dark_matter = dark_matter + '{$dark_matter_from_metamatter}' WHERE `id` = {$user_id_safe} LIMIT 1;"); |
| 458 | 458 | $new_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1;", '', true); |
| 459 | 459 | |
| 460 | 460 | $partner_bonus = floor($new_referral['dark_matter'] / $config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= $config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / $config->rpg_bonus_divisor) : 0); |
| 461 | - if($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) { |
|
| 461 | + if ($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) { |
|
| 462 | 462 | rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}"); |
| 463 | 463 | } |
| 464 | 464 | } |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | * @throws Exception |
| 475 | 475 | */ |
| 476 | 476 | public function cookieSet($rememberMe = false, $domain = null) { |
| 477 | - if(!$this->is_exists) { |
|
| 477 | + if (!$this->is_exists) { |
|
| 478 | 478 | throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR); |
| 479 | 479 | } |
| 480 | 480 | |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | // OK v4.1 |
| 494 | 494 | public function cookieClear($domain = null) { |
| 495 | 495 | // Автоматически вообще-то - если установлена кука имперсонатора - то чистим обычную, а куку имперсонатора - копируем в неё |
| 496 | - if(!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
| 496 | + if (!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
| 497 | 497 | sn_setcookie($this->cookie_name, $_COOKIE[$this->cookie_name_impersonate], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $domain); |
| 498 | 498 | sn_setcookie($this->cookie_name_impersonate, '', SN_TIME_NOW - PERIOD_WEEK, $this->sn_root_path, $domain); |
| 499 | 499 | } else { |
@@ -503,14 +503,14 @@ discard block |
||
| 503 | 503 | |
| 504 | 504 | public function cookieLogin(&$rememberMe = false) { |
| 505 | 505 | // Пытаемся войти по куке |
| 506 | - if(!empty($_COOKIE[$this->cookie_name])) { |
|
| 507 | - if(count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
| 506 | + if (!empty($_COOKIE[$this->cookie_name])) { |
|
| 507 | + if (count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
| 508 | 508 | list($account_id_unsafe, $cookie_password_hash_salted, $user_remember_me) = explode(AUTH_COOKIE_DELIMETER, $_COOKIE[$this->cookie_name]); |
| 509 | 509 | } else { |
| 510 | 510 | list($account_id_unsafe, $user_name, $cookie_password_hash_salted, $user_remember_me) = explode("/%/", $_COOKIE[$this->cookie_name]); |
| 511 | 511 | } |
| 512 | 512 | |
| 513 | - if( |
|
| 513 | + if ( |
|
| 514 | 514 | $this->db_get_by_id($account_id_unsafe) |
| 515 | 515 | && ($this->password_encode_for_cookie($this->account_password) == $cookie_password_hash_salted) |
| 516 | 516 | ) { |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | protected static $is_init = false; |
| 20 | 20 | |
| 21 | 21 | protected static function init() { |
| 22 | - if(!empty(static::$db)) { |
|
| 22 | + if (!empty(static::$db)) { |
|
| 23 | 23 | return; |
| 24 | 24 | } |
| 25 | 25 | static::$db = SN::$db; |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | $provider_id_safe = intval($provider_id_unsafe); |
| 67 | 67 | !is_array($account_list) ? $account_list = array($account_list) : false; |
| 68 | 68 | |
| 69 | - foreach($account_list as $provider_account_id_unsafe) { |
|
| 69 | + foreach ($account_list as $provider_account_id_unsafe) { |
|
| 70 | 70 | $provider_account_id_safe = intval($provider_account_id_unsafe); |
| 71 | 71 | |
| 72 | 72 | // TODO - Здесь могут отсутствовать аккаунты - проверять провайдером |
| 73 | 73 | $query = static::$db->doquery("SELECT `user_id` FROM {{account_translate}} WHERE `provider_id` = {$provider_id_safe} AND `provider_account_id` = {$provider_account_id_safe} FOR UPDATE"); |
| 74 | - while($row = static::$db->db_fetch($query)) { |
|
| 74 | + while ($row = static::$db->db_fetch($query)) { |
|
| 75 | 75 | $account_translation[$row['user_id']][$provider_id_unsafe][$provider_account_id_unsafe] = true; |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | "SELECT * FROM {{account_translate}} WHERE `user_id` = {$user_id_safe} " . |
| 98 | 98 | ($provider_id_unsafe ? "AND `provider_id` = {$provider_id_safe} " : '') . |
| 99 | 99 | "ORDER BY `timestamp` FOR UPDATE"); |
| 100 | - while($row = static::$db->db_fetch($query)) { |
|
| 100 | + while ($row = static::$db->db_fetch($query)) { |
|
| 101 | 101 | $account_translation[$row['user_id']][$row['provider_id']][$row['provider_account_id']] = $row; |
| 102 | 102 | } |
| 103 | 103 | |
@@ -193,18 +193,18 @@ discard block |
||
| 193 | 193 | // TODO Хотя тут может получится вечный цикл - ПОДУМАТЬ |
| 194 | 194 | // TODO Тут же можно пробовать провести попытку слияния аккаунтов - хотя это и очень небезопасно |
| 195 | 195 | |
| 196 | - if(sys_get_param('login_player_register_logout')) { |
|
| 196 | + if (sys_get_param('login_player_register_logout')) { |
|
| 197 | 197 | $this->logout(); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | $original_suggest = ''; |
| 201 | 201 | // Смотрим - есть ли у нас данные от пользователя |
| 202 | - if(($player_name_submitted = sys_get_param('submit_player_name'))) { |
|
| 202 | + if (($player_name_submitted = sys_get_param('submit_player_name'))) { |
|
| 203 | 203 | // Попытка регистрации нового игрока из данных, введенных пользователем |
| 204 | 204 | $this->player_suggested_name = sys_get_param_str_unsafe('player_suggested_name'); |
| 205 | 205 | } else { |
| 206 | - foreach($this->providers_authorised as $provider) { |
|
| 207 | - if($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5 |
|
| 206 | + foreach ($this->providers_authorised as $provider) { |
|
| 207 | + if ($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5 |
|
| 208 | 208 | $original_suggest = $provider->player_name_suggest(); |
| 209 | 209 | break; |
| 210 | 210 | } |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | // Если у нас провайдеры не дают имени и пользователь не дал свой вариант - это у нас первый логин в игру |
| 215 | - if(!$this->player_suggested_name) { |
|
| 215 | + if (!$this->player_suggested_name) { |
|
| 216 | 216 | $max_user_id = db_player_get_max_id(); // 4.5 |
| 217 | 217 | // TODO - предлагать имя игрока по локали |
| 218 | 218 | |
@@ -221,15 +221,15 @@ discard block |
||
| 221 | 221 | sn_db_transaction_rollback(); |
| 222 | 222 | $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000); |
| 223 | 223 | sn_db_transaction_start(); |
| 224 | - } while(db_player_name_exists($this->player_suggested_name)); |
|
| 224 | + } while (db_player_name_exists($this->player_suggested_name)); |
|
| 225 | 225 | |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - if($player_name_submitted) { |
|
| 228 | + if ($player_name_submitted) { |
|
| 229 | 229 | $this->register_player_db_create($this->player_suggested_name); // OK 4.5 |
| 230 | - if($this->register_status == LOGIN_SUCCESS) { |
|
| 230 | + if ($this->register_status == LOGIN_SUCCESS) { |
|
| 231 | 231 | sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
| 232 | - } elseif($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
|
| 232 | + } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
|
| 233 | 233 | // self::$player_suggested_name .= ' ' . $this->account->account_id; |
| 234 | 234 | } |
| 235 | 235 | // if(self::$login_status != LOGIN_SUCCESS) { |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | : false |
| 254 | 254 | ); |
| 255 | 255 | |
| 256 | - if($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
| 256 | + if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
| 257 | 257 | $prohibited_characters = array_map(function($value) { |
| 258 | 258 | return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
| 259 | 259 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
@@ -285,27 +285,27 @@ discard block |
||
| 285 | 285 | global $sn_module_list, $lang; |
| 286 | 286 | |
| 287 | 287 | // !self::$is_init ? self::init() : false; |
| 288 | - if(empty($sn_module_list['auth'])) { |
|
| 288 | + if (empty($sn_module_list['auth'])) { |
|
| 289 | 289 | die('{Не обнаружено ни одного провайдера авторизации в core_auth::login()!}'); |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | !empty($_POST) ? self::flog(dump($_POST, '$_POST')) : false; |
| 293 | 293 | !empty($_GET) ? self::flog(dump($_GET, '$_GET')) : false; |
| 294 | - !empty($_COOKIE) ? self::flog(dump($_COOKIE,'$_COOKIE')) : false; |
|
| 294 | + !empty($_COOKIE) ? self::flog(dump($_COOKIE, '$_COOKIE')) : false; |
|
| 295 | 295 | |
| 296 | 296 | $this->auth_reset(); // OK v4.5 |
| 297 | 297 | |
| 298 | 298 | $this->providers = array(); |
| 299 | - foreach($sn_module_list['auth'] as $module_name => $module) { |
|
| 299 | + foreach ($sn_module_list['auth'] as $module_name => $module) { |
|
| 300 | 300 | $this->providers[$module->provider_id] = $module; |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | // $this->providers = array_reverse($this->providers, true); // НИНАДА! СН-аккаунт должен всегда авторизироваться первым! |
| 304 | 304 | //pdump($this->providers); |
| 305 | - foreach($this->providers as $provider_id => $provider) { |
|
| 305 | + foreach ($this->providers as $provider_id => $provider) { |
|
| 306 | 306 | $login_status = $provider->login(); // OK v4.5 |
| 307 | 307 | self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? $lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); |
| 308 | - if($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
|
| 308 | + if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
|
| 309 | 309 | $this->providers_authorised[$provider_id] = &$this->providers[$provider_id]; |
| 310 | 310 | |
| 311 | 311 | $this->user_id_to_provider = array_replace_recursive( |
@@ -313,20 +313,20 @@ discard block |
||
| 313 | 313 | // static::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5 |
| 314 | 314 | PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5 |
| 315 | 315 | ); |
| 316 | - } elseif($login_status != LOGIN_UNDEFINED) { |
|
| 316 | + } elseif ($login_status != LOGIN_UNDEFINED) { |
|
| 317 | 317 | $this->provider_error_list[$provider_id] = $login_status; |
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - if(empty($this->providers_authorised)) { |
|
| 321 | + if (empty($this->providers_authorised)) { |
|
| 322 | 322 | // Ни один аккаунт не авторизирован |
| 323 | 323 | // Проверяем - есть ли у нас ошибки в аккаунтах? |
| 324 | - if(!empty($this->provider_error_list)) { |
|
| 324 | + if (!empty($this->provider_error_list)) { |
|
| 325 | 325 | // Если есть - выводим их |
| 326 | 326 | self::$login_status = reset($this->provider_error_list); |
| 327 | 327 | $providerError = $this->providers[key($this->provider_error_list)]->account_login_message; |
| 328 | 328 | |
| 329 | - if(!empty($providerError)) { |
|
| 329 | + if (!empty($providerError)) { |
|
| 330 | 330 | self::$login_message = $providerError; |
| 331 | 331 | } |
| 332 | 332 | } |
@@ -341,12 +341,12 @@ discard block |
||
| 341 | 341 | // В self::$accessible_user_row_list - список доступных игроков для данных аккаунтов с соответствующими записями из таблицы `users` |
| 342 | 342 | |
| 343 | 343 | // Остались ли у нас в списке доступные игроки? |
| 344 | - if(empty($this->accessible_user_row_list)) { |
|
| 344 | + if (empty($this->accessible_user_row_list)) { |
|
| 345 | 345 | // Нет ни одного игрока ни на одном авторизированном аккаунте |
| 346 | 346 | // Надо регать нового игрока |
| 347 | 347 | |
| 348 | 348 | // Сейчас происходит процесс регистрации игрока? |
| 349 | - if(!$this->is_player_register) { |
|
| 349 | + if (!$this->is_player_register) { |
|
| 350 | 350 | // Нет - отправляем на процесс регистрации |
| 351 | 351 | $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id')); |
| 352 | 352 | sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : '')); |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | // Да, есть доступные игроки, которые так же прописаны в базе |
| 356 | 356 | $this->get_active_user(); // 4.5 |
| 357 | 357 | |
| 358 | - if($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) { |
|
| 358 | + if ($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) { |
|
| 359 | 359 | $a_user = db_user_by_id($this->is_impersonating); |
| 360 | 360 | $this->impersonator_username = $a_user['username']; |
| 361 | 361 | } |
@@ -363,9 +363,9 @@ discard block |
||
| 363 | 363 | |
| 364 | 364 | //Прописываем текущего игрока на все авторизированные аккаунты |
| 365 | 365 | // TODO - ИЛИ ВСЕХ ИГРОКОВ?? |
| 366 | - if(empty($this->is_impersonating)) { |
|
| 367 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
| 368 | - if(empty($this->user_id_to_provider[self::$user['id']][$provider_id])) { |
|
| 366 | + if (empty($this->is_impersonating)) { |
|
| 367 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
| 368 | + if (empty($this->user_id_to_provider[self::$user['id']][$provider_id])) { |
|
| 369 | 369 | // self::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']); |
| 370 | 370 | PlayerToAccountTranslate::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']); |
| 371 | 371 | $this->user_id_to_provider[self::$user['id']][$provider_id][$provider->account->account_id] = true; |
@@ -375,9 +375,9 @@ discard block |
||
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - if(empty(self::$user['id'])) { |
|
| 378 | + if (empty(self::$user['id'])) { |
|
| 379 | 379 | self::cookie_set(''); // OK 4.5 |
| 380 | - } elseif(self::$user['id'] != $_COOKIE[SN_COOKIE_U]) { |
|
| 380 | + } elseif (self::$user['id'] != $_COOKIE[SN_COOKIE_U]) { |
|
| 381 | 381 | self::cookie_set(self::$user['id']); // OK 4.5 |
| 382 | 382 | } |
| 383 | 383 | |
@@ -396,21 +396,21 @@ discard block |
||
| 396 | 396 | */ |
| 397 | 397 | // OK v4.7 |
| 398 | 398 | public function logout($redirect = true) { |
| 399 | - if(!empty($_COOKIE[SN_COOKIE_U_I])) { |
|
| 399 | + if (!empty($_COOKIE[SN_COOKIE_U_I])) { |
|
| 400 | 400 | self::cookie_set($_COOKIE[SN_COOKIE_U_I]); |
| 401 | 401 | self::cookie_set(0, true); |
| 402 | 402 | self::$main_provider->logout(); |
| 403 | 403 | } else { |
| 404 | - foreach($this->providers as $provider_name => $provider) { |
|
| 404 | + foreach ($this->providers as $provider_name => $provider) { |
|
| 405 | 405 | $provider->logout(); |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | self::cookie_set(0); |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - if($redirect === true) { |
|
| 411 | + if ($redirect === true) { |
|
| 412 | 412 | sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); |
| 413 | - } elseif($redirect !== false) { |
|
| 413 | + } elseif ($redirect !== false) { |
|
| 414 | 414 | sys_redirect($redirect); |
| 415 | 415 | } |
| 416 | 416 | } |
@@ -421,15 +421,15 @@ discard block |
||
| 421 | 421 | * @param $user_selected |
| 422 | 422 | */ |
| 423 | 423 | public function impersonate($user_selected) { |
| 424 | - if($_COOKIE[SN_COOKIE_U_I]) { |
|
| 424 | + if ($_COOKIE[SN_COOKIE_U_I]) { |
|
| 425 | 425 | die('You already impersonating someone. Go back to living other\'s life! Or clear your cookies and try again'); // TODO: Log it |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - if($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) { |
|
| 428 | + if ($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) { |
|
| 429 | 429 | die('You can\'t impersonate - too low level'); // TODO: Log it |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - if($this->auth_level_max_local <= $user_selected['authlevel']) { |
|
| 432 | + if ($this->auth_level_max_local <= $user_selected['authlevel']) { |
|
| 433 | 433 | die('You can\'t impersonate this account - level is greater or equal to yours'); // TODO: Log it |
| 434 | 434 | } |
| 435 | 435 | |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | $account_translate = reset($account_translate[$user_selected['id']][self::$main_provider->provider_id]); |
| 438 | 438 | $account_to_impersonate = new Account(self::$main_provider->db); |
| 439 | 439 | $account_to_impersonate->db_get_by_id($account_translate['provider_account_id']); |
| 440 | - if(!$account_to_impersonate->is_exists) { |
|
| 440 | + if (!$account_to_impersonate->is_exists) { |
|
| 441 | 441 | die('Какая-то ошибка - не могу найти аккаунт для имперсонации'); // TODO: Log it |
| 442 | 442 | } |
| 443 | 443 | self::$main_provider->impersonate($account_to_impersonate); |
@@ -463,12 +463,12 @@ discard block |
||
| 463 | 463 | public function password_check($password_unsafe) { |
| 464 | 464 | $result = false; |
| 465 | 465 | |
| 466 | - if(empty($this->providers_authorised)) { |
|
| 466 | + if (empty($this->providers_authorised)) { |
|
| 467 | 467 | // TODO - такого быть не может! |
| 468 | 468 | self::flog("password_check: Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true); |
| 469 | 469 | } else { |
| 470 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
| 471 | - if($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) { |
|
| 470 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
| 471 | + if ($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) { |
|
| 472 | 472 | $result = $result || $provider->password_check($password_unsafe); |
| 473 | 473 | } |
| 474 | 474 | } |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | public function password_change($old_password_unsafe, $new_password_unsafe) { |
| 490 | 490 | global $lang; |
| 491 | 491 | |
| 492 | - if(empty($this->providers_authorised)) { |
|
| 492 | + if (empty($this->providers_authorised)) { |
|
| 493 | 493 | // TODO - такого быть не может! |
| 494 | 494 | self::flog("Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true); |
| 495 | 495 | return false; |
@@ -502,8 +502,8 @@ discard block |
||
| 502 | 502 | $salt_unsafe = self::password_salt_generate(); |
| 503 | 503 | |
| 504 | 504 | $providers_changed_password = array(); |
| 505 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
| 506 | - if( |
|
| 505 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
| 506 | + if ( |
|
| 507 | 507 | !$provider->is_feature_supported(AUTH_FEATURE_PASSWORD_CHANGE) |
| 508 | 508 | || !$provider->password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe) |
| 509 | 509 | ) { |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id); |
| 516 | 516 | |
| 517 | 517 | // Рассылаем уведомления о смене пароля в ЛС |
| 518 | - foreach($account_translation as $user_id => $provider_info) { |
|
| 518 | + foreach ($account_translation as $user_id => $provider_info) { |
|
| 519 | 519 | // TODO - УКазывать тип аккаунта, на котором сменён пароль |
| 520 | 520 | msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN, |
| 521 | 521 | $lang['sys_administration'], $lang['sys_login_register_message_title'], |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | sn_db_transaction_start(); |
| 563 | 563 | // Проверить наличие такого имени в истории имён |
| 564 | 564 | |
| 565 | - if(db_player_name_exists($player_name_unsafe)) { |
|
| 565 | + if (db_player_name_exists($player_name_unsafe)) { |
|
| 566 | 566 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_EXISTS, ERR_ERROR); |
| 567 | 567 | } |
| 568 | 568 | |
@@ -570,11 +570,11 @@ discard block |
||
| 570 | 570 | $player_language = ''; |
| 571 | 571 | $player_email = ''; |
| 572 | 572 | // TODO - порнография - работа должна происходить над списком аккаунтов, а не только на одном аккаунте... |
| 573 | - foreach($this->providers_authorised as $provider) { |
|
| 574 | - if(!$player_language && $provider->account->account_language) { |
|
| 573 | + foreach ($this->providers_authorised as $provider) { |
|
| 574 | + if (!$player_language && $provider->account->account_language) { |
|
| 575 | 575 | $player_language = $provider->account->account_language; |
| 576 | 576 | } |
| 577 | - if(!$player_email && $provider->account->account_email) { |
|
| 577 | + if (!$player_email && $provider->account->account_email) { |
|
| 578 | 578 | $player_email = $provider->account->account_email; |
| 579 | 579 | } |
| 580 | 580 | } |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | )); |
| 591 | 591 | // Зарегестрировать на него аккаунты из self::$accounts_authorised |
| 592 | 592 | $a_user = self::$user; |
| 593 | - foreach($this->providers_authorised as $provider) { |
|
| 593 | + foreach ($this->providers_authorised as $provider) { |
|
| 594 | 594 | // TODO - порнография. Должен быть отдельный класс трансляторов - в т.ч. и кэширующий транслятор |
| 595 | 595 | // TODO - ну и работа должна происходить над списком аккаунтов, а не только на одном аккаунте... |
| 596 | 596 | // self::db_translate_register_user($provider->provider_id, $provider->account->account_id, $a_user['id']); |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | |
| 603 | 603 | sn_db_transaction_commit(); |
| 604 | 604 | $this->register_status = LOGIN_SUCCESS; |
| 605 | - } catch(Exception $e) { |
|
| 605 | + } catch (Exception $e) { |
|
| 606 | 606 | sn_db_transaction_rollback(); |
| 607 | 607 | |
| 608 | 608 | // Если старое имя занято |
@@ -621,10 +621,10 @@ discard block |
||
| 621 | 621 | // Пробиваем все ИД игроков по базе - есть ли вообще такие записи |
| 622 | 622 | // Вообще-то это не особо нужно - у нас по определению стоят констраинты |
| 623 | 623 | // Зато так мы узнаем максимальный authlevel, проверим права имперсонейта и вытащим все записи юзеров |
| 624 | - foreach($this->user_id_to_provider as $user_id => $cork) { |
|
| 624 | + foreach ($this->user_id_to_provider as $user_id => $cork) { |
|
| 625 | 625 | $user = db_user_by_id($user_id); |
| 626 | 626 | // Если записи игрока в БД не существует? |
| 627 | - if(empty($user['id'])) { |
|
| 627 | + if (empty($user['id'])) { |
|
| 628 | 628 | // Удаляем этого и переходим к следующему |
| 629 | 629 | unset($this->user_id_to_provider[$user_id]); |
| 630 | 630 | // Де-регистрируем игрока из таблицы трансляции игроков |
@@ -645,7 +645,7 @@ discard block |
||
| 645 | 645 | // OK v4.5 |
| 646 | 646 | protected function get_active_user() { |
| 647 | 647 | // Проверяем куку "текущего игрока" из браузера |
| 648 | - if( |
|
| 648 | + if ( |
|
| 649 | 649 | // Кука не пустая |
| 650 | 650 | ($_COOKIE[SN_COOKIE_U] = trim($_COOKIE[SN_COOKIE_U])) && !empty($_COOKIE[SN_COOKIE_U]) |
| 651 | 651 | // И в куке находится ID |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | // В куке нет валидного ИД записи игрока, доступной с текущих аккаунтов |
| 673 | - if(empty(self::$user['id'])) { |
|
| 673 | + if (empty(self::$user['id'])) { |
|
| 674 | 674 | // Берем первого из доступных |
| 675 | 675 | // TODO - default_user |
| 676 | 676 | self::$user = reset($this->accessible_user_row_list); |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | |
| 695 | 695 | $result = array(); |
| 696 | 696 | |
| 697 | - if($user_id && empty($this->is_impersonating)) { |
|
| 697 | + if ($user_id && empty($this->is_impersonating)) { |
|
| 698 | 698 | // self::db_counter_insert(); |
| 699 | 699 | self::$device->db_counter_insert($user_id); |
| 700 | 700 | |
@@ -702,12 +702,12 @@ discard block |
||
| 702 | 702 | |
| 703 | 703 | sys_user_options_unpack($user); |
| 704 | 704 | |
| 705 | - if($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) { |
|
| 705 | + if ($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) { |
|
| 706 | 706 | $user['banaday'] = 0; |
| 707 | 707 | $user['vacation'] = SN_TIME_NOW; |
| 708 | 708 | } |
| 709 | 709 | |
| 710 | - $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip']; |
|
| 710 | + $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip']; |
|
| 711 | 711 | $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain']; |
| 712 | 712 | |
| 713 | 713 | $result[F_BANNED_STATUS] = $user['banaday']; |
@@ -721,13 +721,13 @@ discard block |
||
| 721 | 721 | ); |
| 722 | 722 | } |
| 723 | 723 | |
| 724 | - if($extra = $config->security_ban_extra) { |
|
| 724 | + if ($extra = $config->security_ban_extra) { |
|
| 725 | 725 | $extra = explode(',', $extra); |
| 726 | - array_walk($extra,'trim'); |
|
| 726 | + array_walk($extra, 'trim'); |
|
| 727 | 727 | in_array(self::$device->device_id, $extra) and die(); |
| 728 | 728 | } |
| 729 | 729 | |
| 730 | - if(self::$login_message) { |
|
| 730 | + if (self::$login_message) { |
|
| 731 | 731 | $result[F_LOGIN_MESSAGE] = self::$login_message; |
| 732 | 732 | } |
| 733 | 733 | |
@@ -763,21 +763,21 @@ discard block |
||
| 763 | 763 | protected function register_player_name_validate($player_name_unsafe) { |
| 764 | 764 | // TODO - переделать под RAW-строки |
| 765 | 765 | // Если имя игрока пустое - NO GO! |
| 766 | - if(trim($player_name_unsafe) == '') { |
|
| 766 | + if (trim($player_name_unsafe) == '') { |
|
| 767 | 767 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_EMPTY, ERR_ERROR); |
| 768 | 768 | } |
| 769 | 769 | // Проверяем, что бы в начале и конце не было пустых символов |
| 770 | - if($player_name_unsafe != trim($player_name_unsafe)) { |
|
| 770 | + if ($player_name_unsafe != trim($player_name_unsafe)) { |
|
| 771 | 771 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_TRIMMED, ERR_ERROR); |
| 772 | 772 | } |
| 773 | 773 | // Если логин имеет запрещенные символы - NO GO! |
| 774 | - if(strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
| 774 | + if (strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
| 775 | 775 | // TODO - выдавать в сообщение об ошибке список запрещенных символов |
| 776 | 776 | // TODO - заранее извещать игрока, какие символы являются запрещенными |
| 777 | 777 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_RESTRICTED_CHARACTERS, ERR_ERROR); |
| 778 | 778 | } |
| 779 | 779 | // Если логин меньше минимальной длины - NO GO! |
| 780 | - if(strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) { |
|
| 780 | + if (strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) { |
|
| 781 | 781 | // TODO - выдавать в сообщение об ошибке минимальную длину имени игрока |
| 782 | 782 | // TODO - заранее извещать игрока, какая минимальная и максимальная длина имени |
| 783 | 783 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_SHORT, ERR_ERROR); |
@@ -835,7 +835,7 @@ discard block |
||
| 835 | 835 | } |
| 836 | 836 | |
| 837 | 837 | protected static function flog($message, $die = false) { |
| 838 | - if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
| 838 | + if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
| 839 | 839 | return; |
| 840 | 840 | } |
| 841 | 841 | list($called, $caller) = debug_backtrace(false); |
@@ -848,7 +848,7 @@ discard block |
||
| 848 | 848 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
| 849 | 849 | |
| 850 | 850 | SN::log_file("$message - $caller_name"); |
| 851 | - if($die) { |
|
| 851 | + if ($die) { |
|
| 852 | 852 | $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
| 853 | 853 | } |
| 854 | 854 | } |
@@ -25,14 +25,14 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public static function db_changeset_prepare_unit($unit_id, $unit_value, $user, $planet_id = null) |
| 27 | 27 | { |
| 28 | - if(!is_array($user)) |
|
| 28 | + if (!is_array($user)) |
|
| 29 | 29 | { |
| 30 | 30 | // TODO - remove later |
| 31 | 31 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: OldDbChangeSet::db_changeset_prepare_unit() - USER is not ARRAY</h1>'); |
| 32 | 32 | pdump(debug_backtrace()); |
| 33 | 33 | die('USER is not ARRAY'); |
| 34 | 34 | } |
| 35 | - if(!isset($user['id']) || !$user['id']) |
|
| 35 | + if (!isset($user['id']) || !$user['id']) |
|
| 36 | 36 | { |
| 37 | 37 | // TODO - remove later |
| 38 | 38 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: OldDbChangeSet::db_changeset_prepare_unit() - USER[id] пустой</h1>'); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $location_id = $location_id ? $location_id : 'NULL'; |
| 48 | 48 | |
| 49 | 49 | $temp = DBStaticUnit::db_unit_by_location($user['id'], $unit_location, $location_id, $unit_id); |
| 50 | - if(!empty($temp['unit_id'])) |
|
| 50 | + if (!empty($temp['unit_id'])) |
|
| 51 | 51 | { |
| 52 | 52 | $db_changeset = array( |
| 53 | 53 | 'action' => SQL_OP_UPDATE, |
@@ -93,9 +93,9 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | public static function db_changeset_condition_compile(&$conditions, &$table_name = '') { |
| 96 | - if(!$conditions[P_LOCATION] || $conditions[P_LOCATION] == LOC_NONE) { |
|
| 96 | + if (!$conditions[P_LOCATION] || $conditions[P_LOCATION] == LOC_NONE) { |
|
| 97 | 97 | $conditions[P_LOCATION] = LOC_NONE; |
| 98 | - switch($table_name) { |
|
| 98 | + switch ($table_name) { |
|
| 99 | 99 | case 'users': |
| 100 | 100 | case LOC_USER: |
| 101 | 101 | $conditions[P_TABLE_NAME] = $table_name = 'users'; |
@@ -117,18 +117,18 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | $conditions[P_FIELDS_STR] = ''; |
| 120 | - if($conditions['fields']) { |
|
| 120 | + if ($conditions['fields']) { |
|
| 121 | 121 | $fields = array(); |
| 122 | - foreach($conditions['fields'] as $field_name => $field_data) { |
|
| 122 | + foreach ($conditions['fields'] as $field_name => $field_data) { |
|
| 123 | 123 | $condition = "`{$field_name}` = "; |
| 124 | 124 | $value = ''; |
| 125 | - if($field_data['delta']) { |
|
| 125 | + if ($field_data['delta']) { |
|
| 126 | 126 | $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; |
| 127 | - } elseif($field_data['set']) { |
|
| 128 | - $value = (is_string($field_data['set']) ? "'{$field_data['set']}'": $field_data['set']); |
|
| 127 | + } elseif ($field_data['set']) { |
|
| 128 | + $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if($value) { |
|
| 131 | + if ($value) { |
|
| 132 | 132 | $fields[] = $condition . $value; |
| 133 | 133 | } |
| 134 | 134 | } |
@@ -136,16 +136,14 @@ discard block |
||
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | $conditions[P_WHERE_STR] = ''; |
| 139 | - if(!empty($conditions['where'])) { |
|
| 140 | - if($conditions[P_VERSION] == 1) { |
|
| 139 | + if (!empty($conditions['where'])) { |
|
| 140 | + if ($conditions[P_VERSION] == 1) { |
|
| 141 | 141 | $the_conditions = array(); |
| 142 | - foreach($conditions['where'] as $field_id => $field_value) { |
|
| 142 | + foreach ($conditions['where'] as $field_id => $field_value) { |
|
| 143 | 143 | // Простое условие - $field_id = $field_value |
| 144 | - if(is_string($field_id)) { |
|
| 144 | + if (is_string($field_id)) { |
|
| 145 | 145 | $field_value = |
| 146 | - $field_value === null ? 'NULL' : |
|
| 147 | - (is_string($field_value) ? "'" . db_escape($field_value) . "'" : |
|
| 148 | - (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
| 146 | + $field_value === null ? 'NULL' : (is_string($field_value) ? "'" . db_escape($field_value) . "'" : (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
| 149 | 147 | $the_conditions[] = "`{$field_id}` = {$field_value}"; |
| 150 | 148 | } else { |
| 151 | 149 | die('Неподдерживаемый тип условия'); |
@@ -157,7 +155,7 @@ discard block |
||
| 157 | 155 | $conditions[P_WHERE_STR] = implode(' AND ', $the_conditions); |
| 158 | 156 | } |
| 159 | 157 | |
| 160 | - switch($conditions['action']) { |
|
| 158 | + switch ($conditions['action']) { |
|
| 161 | 159 | case SQL_OP_DELETE: $conditions[P_ACTION_STR] = ("DELETE FROM {{{$table_name}}}"); break; |
| 162 | 160 | case SQL_OP_UPDATE: $conditions[P_ACTION_STR] = ("UPDATE {{{$table_name}}} SET"); break; |
| 163 | 161 | case SQL_OP_INSERT: $conditions[P_ACTION_STR] = ("INSERT INTO {{{$table_name}}} SET"); break; |
@@ -176,17 +174,17 @@ discard block |
||
| 176 | 174 | */ |
| 177 | 175 | public static function db_changeset_apply($db_changeset) { |
| 178 | 176 | $result = true; |
| 179 | - if(!is_array($db_changeset) || empty($db_changeset)) return $result; |
|
| 177 | + if (!is_array($db_changeset) || empty($db_changeset)) return $result; |
|
| 180 | 178 | |
| 181 | - foreach($db_changeset as $table_name => &$table_data) { |
|
| 182 | - foreach($table_data as $record_id => &$conditions) { |
|
| 179 | + foreach ($db_changeset as $table_name => &$table_data) { |
|
| 180 | + foreach ($table_data as $record_id => &$conditions) { |
|
| 183 | 181 | OldDbChangeSet::db_changeset_condition_compile($conditions, $table_name); |
| 184 | 182 | |
| 185 | - if($conditions['action'] != SQL_OP_DELETE && !$conditions[P_FIELDS_STR]) continue; |
|
| 186 | - if($conditions['action'] == SQL_OP_DELETE && !$conditions[P_WHERE_STR]) continue; // Защита от случайного удаления всех данных в таблице |
|
| 183 | + if ($conditions['action'] != SQL_OP_DELETE && !$conditions[P_FIELDS_STR]) continue; |
|
| 184 | + if ($conditions['action'] == SQL_OP_DELETE && !$conditions[P_WHERE_STR]) continue; // Защита от случайного удаления всех данных в таблице |
|
| 187 | 185 | |
| 188 | - if($conditions[P_LOCATION] != LOC_NONE) { |
|
| 189 | - switch($conditions['action']) |
|
| 186 | + if ($conditions[P_LOCATION] != LOC_NONE) { |
|
| 187 | + switch ($conditions['action']) |
|
| 190 | 188 | { |
| 191 | 189 | case SQL_OP_DELETE: $result = SN::db_del_record_list($conditions[P_LOCATION], $conditions[P_WHERE_STR]) && $result; break; |
| 192 | 190 | case SQL_OP_UPDATE: $result = SN::db_upd_record_list($conditions[P_LOCATION], $conditions[P_WHERE_STR], $conditions[P_FIELDS_STR]) && $result; break; |
@@ -28,13 +28,13 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | $this->container = array(); |
| 30 | 30 | |
| 31 | - if(SN::$cache->getMode() != classCache::CACHER_NO_CACHE && !SN::$config->locale_cache_disable) { |
|
| 31 | + if (SN::$cache->getMode() != classCache::CACHER_NO_CACHE && !SN::$config->locale_cache_disable) { |
|
| 32 | 32 | $this->cache = SN::$cache; |
| 33 | 33 | SN::log_file('locale.__constructor: Cache is present'); |
| 34 | 34 | //$this->cache->unset_by_prefix($this->cache_prefix); // TODO - remove? 'cause debug! |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if($enable_stat_usage && empty($this->stat_usage)) { |
|
| 37 | + if ($enable_stat_usage && empty($this->stat_usage)) { |
|
| 38 | 38 | $this->enable_stat_usage = $enable_stat_usage; |
| 39 | 39 | $this->usage_stat_load(); |
| 40 | 40 | // TODO shutdown function |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | unset($fallback[$this->active]); |
| 61 | 61 | |
| 62 | 62 | // Проходим по оставшимся локалям |
| 63 | - foreach($fallback as $try_language) { |
|
| 63 | + foreach ($fallback as $try_language) { |
|
| 64 | 64 | // Если нет такой строки - пытаемся вытащить из кэша |
| 65 | - if(!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
| 65 | + if (!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
| 66 | 66 | $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix . $try_language . '_' . $offset); |
| 67 | 67 | // Записываем результат работы кэша |
| 68 | 68 | $locale_cache_statistic['queries']++; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // Если мы как-то где-то нашли строку... |
| 74 | - if(isset($this->container[$try_language][$offset])) { |
|
| 74 | + if (isset($this->container[$try_language][$offset])) { |
|
| 75 | 75 | // ...значит она получена в результате фоллбэка и записываем её в кэш и контейнер |
| 76 | 76 | $this[$offset] = $this->container[$try_language][$offset]; |
| 77 | 77 | $locale_cache_statistic['fallbacks']++; |
@@ -85,15 +85,15 @@ discard block |
||
| 85 | 85 | $this->container[$this->active][] = $value; |
| 86 | 86 | } else { |
| 87 | 87 | $this->container[$this->active][$offset] = $value; |
| 88 | - if($this->cache) { |
|
| 88 | + if ($this->cache) { |
|
| 89 | 89 | $this->cache->__set($this->cache_prefix_lang . $offset, $value); |
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | public function offsetExists($offset) { |
| 94 | 94 | // Шорткат если у нас уже есть строка в памяти PHP |
| 95 | - if(!isset($this->container[$this->active][$offset])) { |
|
| 96 | - if(!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) { |
|
| 95 | + if (!isset($this->container[$this->active][$offset])) { |
|
| 96 | + if (!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) { |
|
| 97 | 97 | // Если нету такой строки - делаем фоллбэк |
| 98 | 98 | $this->locale_string_fallback($offset); |
| 99 | 99 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | public function offsetGet($offset) { |
| 109 | 109 | $value = $this->offsetExists($offset) ? $this->container[$this->active][$offset] : null; |
| 110 | - if($this->enable_stat_usage) { |
|
| 110 | + if ($this->enable_stat_usage) { |
|
| 111 | 111 | $this->usage_stat_log($offset, $value); |
| 112 | 112 | } |
| 113 | 113 | return $value; |
@@ -124,24 +124,24 @@ discard block |
||
| 124 | 124 | public function usage_stat_load() { |
| 125 | 125 | global $sn_cache; |
| 126 | 126 | |
| 127 | - $this->stat_usage = $sn_cache->lng_stat_usage = array(); // TODO for debug |
|
| 128 | - if(empty($this->stat_usage)) { |
|
| 127 | + $this->stat_usage = $sn_cache->lng_stat_usage = array(); // TODO for debug |
|
| 128 | + if (empty($this->stat_usage)) { |
|
| 129 | 129 | $query = doquery("SELECT * FROM {{lng_usage_stat}}"); |
| 130 | - while($row = db_fetch($query)) { |
|
| 130 | + while ($row = db_fetch($query)) { |
|
| 131 | 131 | $this->stat_usage[$row['lang_code'] . ':' . $row['string_id'] . ':' . $row['file'] . ':' . $row['line']] = $row['is_empty']; |
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | public function usage_stat_save() { |
| 136 | - if(!empty($this->stat_usage_new)) { |
|
| 136 | + if (!empty($this->stat_usage_new)) { |
|
| 137 | 137 | global $sn_cache; |
| 138 | 138 | $sn_cache->lng_stat_usage = $this->stat_usage; |
| 139 | 139 | doquery("SELECT 1 FROM {{lng_usage_stat}} LIMIT 1"); |
| 140 | - foreach($this->stat_usage_new as &$value) { |
|
| 141 | - foreach($value as &$value2) { |
|
| 140 | + foreach ($this->stat_usage_new as &$value) { |
|
| 141 | + foreach ($value as &$value2) { |
|
| 142 | 142 | $value2 = '"' . db_escape($value2) . '"'; |
| 143 | 143 | } |
| 144 | - $value = '(' . implode(',', $value) .')'; |
|
| 144 | + $value = '(' . implode(',', $value) . ')'; |
|
| 145 | 145 | } |
| 146 | 146 | doquery("REPLACE INTO {{lng_usage_stat}} (lang_code,string_id,`file`,line,is_empty,locale) VALUES " . implode(',', $this->stat_usage_new)); |
| 147 | 147 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | $file = str_replace('\\', '/', substr($trace[1]['file'], strlen(SN_ROOT_PHYSICAL) - 1)); |
| 155 | 155 | |
| 156 | 156 | $string_id = $this->active . ':' . $offset . ':' . $file . ':' . $trace[1]['line']; |
| 157 | - if(!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != $empty) { |
|
| 157 | + if (!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != $empty) { |
|
| 158 | 158 | $this->stat_usage[$string_id] = empty($value); |
| 159 | 159 | $this->stat_usage_new[] = array( |
| 160 | 160 | 'lang_code' => $this->active, |
@@ -194,11 +194,11 @@ discard block |
||
| 194 | 194 | $cache_file_key = $this->cache_prefix_lang . '__' . $filename; |
| 195 | 195 | |
| 196 | 196 | // Подключен ли внешний кэш? |
| 197 | - if($this->cache) { |
|
| 197 | + if ($this->cache) { |
|
| 198 | 198 | // Загружен ли уже данный файл? |
| 199 | 199 | $cache_file_status = $this->cache->__get($cache_file_key); |
| 200 | 200 | SN::log_file("locale.include: Cache - '{$filename}' has key '{$cache_file_key}' and is " . ($cache_file_status ? 'already loaded - EXIT' : 'EMPTY'), $cache_file_status ? -1 : 0); |
| 201 | - if($cache_file_status) { |
|
| 201 | + if ($cache_file_status) { |
|
| 202 | 202 | // Если да - повторять загрузку нет смысла |
| 203 | 203 | return null; |
| 204 | 204 | } |
@@ -212,35 +212,35 @@ discard block |
||
| 212 | 212 | $this->make_fallback($language); |
| 213 | 213 | |
| 214 | 214 | $file_path = ''; |
| 215 | - foreach($this->fallback as $lang_try) { |
|
| 216 | - if(!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
| 215 | + foreach ($this->fallback as $lang_try) { |
|
| 216 | + if (!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
| 217 | 217 | continue; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - if($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
| 220 | + if ($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
| 221 | 221 | break; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - if($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
| 224 | + if ($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
| 225 | 225 | break; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | $file_path = ''; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - if($file_path) { |
|
| 231 | + if ($file_path) { |
|
| 232 | 232 | include($file_path); |
| 233 | 233 | |
| 234 | - if(!empty($a_lang_array)) { |
|
| 234 | + if (!empty($a_lang_array)) { |
|
| 235 | 235 | $this->merge($a_lang_array); |
| 236 | 236 | |
| 237 | 237 | // Загрузка данных из файла в кэш |
| 238 | - if($this->cache) { |
|
| 238 | + if ($this->cache) { |
|
| 239 | 239 | SN::log_file("Locale: loading '{$filename}' into cache"); |
| 240 | - foreach($a_lang_array as $key => $value) { |
|
| 240 | + foreach ($a_lang_array as $key => $value) { |
|
| 241 | 241 | $value_cache_key = $this->cache_prefix_lang . $key; |
| 242 | - if($this->cache->__isset($value_cache_key)) { |
|
| 243 | - if(is_array($value)) { |
|
| 242 | + if ($this->cache->__isset($value_cache_key)) { |
|
| 243 | + if (is_array($value)) { |
|
| 244 | 244 | $alt_value = $this->cache->__get($value_cache_key); |
| 245 | 245 | $value = array_replace_recursive($alt_value, $value); |
| 246 | 246 | } |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - if($this->cache) { |
|
| 253 | + if ($this->cache) { |
|
| 254 | 254 | $this->cache->__set($cache_file_key, true); |
| 255 | 255 | } |
| 256 | 256 | |
@@ -263,14 +263,14 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | public function lng_load_i18n($i18n) { |
| 266 | - if(!isset($i18n)) { |
|
| 266 | + if (!isset($i18n)) { |
|
| 267 | 267 | return; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - foreach($i18n as $i18n_data) { |
|
| 271 | - if(is_string($i18n_data)) { |
|
| 270 | + foreach ($i18n as $i18n_data) { |
|
| 271 | + if (is_string($i18n_data)) { |
|
| 272 | 272 | $this->lng_include($i18n_data); |
| 273 | - } elseif(is_array($i18n_data)) { |
|
| 273 | + } elseif (is_array($i18n_data)) { |
|
| 274 | 274 | $this->lng_include($i18n_data['file'], $i18n_data['path']); |
| 275 | 275 | } |
| 276 | 276 | } |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | |
| 289 | 289 | SN::log_file("locale.switch: Trying to switch language to '{$language_new}'"); |
| 290 | 290 | |
| 291 | - if($language_new == $this->active) { |
|
| 291 | + if ($language_new == $this->active) { |
|
| 292 | 292 | SN::log_file("locale.switch: New language '{$language_new}' is equal to current language '{$this->active}' - EXIT", -1); |
| 293 | 293 | return false; |
| 294 | 294 | } |
@@ -299,10 +299,10 @@ discard block |
||
| 299 | 299 | $this['LANG_INFO'] = $this->lng_get_info($this->active); |
| 300 | 300 | $this->make_fallback($this->active); |
| 301 | 301 | |
| 302 | - if($this->cache) { |
|
| 302 | + if ($this->cache) { |
|
| 303 | 303 | $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang . '__INIT'); |
| 304 | 304 | SN::log_file("locale.switch: Cache for '{$this->active}' prefixed '{$this->cache_prefix_lang}' is " . ($cache_lang_init_status ? 'already loaded. Doing nothing - EXIT' : 'EMPTY'), $cache_lang_init_status ? -1 : 0); |
| 305 | - if($cache_lang_init_status) { |
|
| 305 | + if ($cache_lang_init_status) { |
|
| 306 | 306 | return false; |
| 307 | 307 | } |
| 308 | 308 | |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | // Loading global language files |
| 319 | 319 | $this->lng_load_i18n($sn_mvc['i18n']['']); |
| 320 | 320 | |
| 321 | - if($this->cache) { |
|
| 321 | + if ($this->cache) { |
|
| 322 | 322 | SN::log_file("locale.switch: Cache - setting flag " . $this->cache_prefix_lang . '__INIT'); |
| 323 | 323 | $this->cache->__set($this->cache_prefix_lang . '__INIT', true); |
| 324 | 324 | } |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | public function lng_get_info($entry) { |
| 333 | 333 | $file_name = SN_ROOT_PHYSICAL . 'language/' . $entry . '/language.mo.php'; |
| 334 | 334 | $lang_info = array(); |
| 335 | - if(file_exists($file_name)) { |
|
| 335 | + if (file_exists($file_name)) { |
|
| 336 | 336 | include($file_name); |
| 337 | 337 | } |
| 338 | 338 | |
@@ -340,15 +340,15 @@ discard block |
||
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | public function lng_get_list() { |
| 343 | - if(empty($this->lang_list)) { |
|
| 343 | + if (empty($this->lang_list)) { |
|
| 344 | 344 | $this->lang_list = array(); |
| 345 | 345 | |
| 346 | 346 | $path = SN_ROOT_PHYSICAL . 'language/'; |
| 347 | 347 | $dir = dir($path); |
| 348 | - while(false !== ($entry = $dir->read())) { |
|
| 349 | - if(is_dir($path . $entry) && $entry[0] != '.') { |
|
| 348 | + while (false !== ($entry = $dir->read())) { |
|
| 349 | + if (is_dir($path . $entry) && $entry[0] != '.') { |
|
| 350 | 350 | $lang_info = $this->lng_get_info($entry); |
| 351 | - if($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
| 351 | + if ($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
| 352 | 352 | $this->lang_list[$lang_info['LANG_NAME_ISO2']] = $lang_info; |
| 353 | 353 | } |
| 354 | 354 | } |
@@ -12,24 +12,24 @@ discard block |
||
| 12 | 12 | global $debug, $template_result, $user, $lang, $planetrow; |
| 13 | 13 | |
| 14 | 14 | // Напоминание для Администрации, что игра отключена |
| 15 | -if($template_result[F_GAME_DISABLE]) { |
|
| 15 | +if ($template_result[F_GAME_DISABLE]) { |
|
| 16 | 16 | echo '<div class="global_admin_warning">', $template_result[F_GAME_DISABLE_REASON], '</div>'; |
| 17 | 17 | } |
| 18 | 18 | unset($disable_reason); |
| 19 | 19 | |
| 20 | 20 | |
| 21 | -if(defined('IN_ADMIN') && IN_ADMIN === true) { |
|
| 21 | +if (defined('IN_ADMIN') && IN_ADMIN === true) { |
|
| 22 | 22 | lng_include('admin'); |
| 23 | -} elseif($sys_user_logged_in) { |
|
| 23 | +} elseif ($sys_user_logged_in) { |
|
| 24 | 24 | sys_user_vacation($user); |
| 25 | 25 | |
| 26 | 26 | $planet_id = SetSelectedPlanet($user); |
| 27 | 27 | |
| 28 | 28 | // TODO НЕ НУЖНО АЛЬЯНС КАЖДЫЙ РАЗ ОБНОВЛЯТЬ!!! |
| 29 | - if($user['ally_id']) { |
|
| 29 | + if ($user['ally_id']) { |
|
| 30 | 30 | sn_db_transaction_start(); |
| 31 | 31 | \Alliance\Alliance::sn_ali_fill_user_ally($user); |
| 32 | - if(!$user['ally']['player']['id']) { |
|
| 32 | + if (!$user['ally']['player']['id']) { |
|
| 33 | 33 | // sn_sys_logout(false, true); |
| 34 | 34 | // core_auth::logout(false); |
| 35 | 35 | SN::$auth->logout(false); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | sn_db_transaction_commit(); |
| 49 | 49 | |
| 50 | 50 | $planetrow = $global_data['planet']; |
| 51 | - if(!($planetrow && isset($planetrow['id']) && $planetrow['id'])) { |
|
| 51 | + if (!($planetrow && isset($planetrow['id']) && $planetrow['id'])) { |
|
| 52 | 52 | // sn_sys_logout(false, true); |
| 53 | 53 | // core_auth::logout(false); |
| 54 | 54 | SN::$auth->logout(false); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | sys_user_options_unpack($user); |
| 64 | 64 | |
| 65 | 65 | global $sn_page_name, $sn_mvc; |
| 66 | -if(!empty($sn_mvc['pages'][INITIAL_PAGE][PAGE_OPTION_EARLY_HEADER])) { |
|
| 66 | +if (!empty($sn_mvc['pages'][INITIAL_PAGE][PAGE_OPTION_EARLY_HEADER])) { |
|
| 67 | 67 | $title = !empty($sn_mvc['pages'][INITIAL_PAGE][PAGE_OPTION_TITLE]) ? $sn_mvc['pages'][INITIAL_PAGE][PAGE_OPTION_TITLE] : ''; |
| 68 | 68 | renderHeader($page, $title, $template_result, false, $user, SN::$config, $lang, $planetrow); |
| 69 | 69 | } |
@@ -21,8 +21,8 @@ |
||
| 21 | 21 | $mode = sys_get_param_escaped('mode'); |
| 22 | 22 | $mode = (!$mode || $mode == 'buildings') ? QUE_STRUCTURES : ($mode == 'fleet' ? SUBQUE_FLEET : ($mode == 'defense' ? SUBQUE_DEFENSE : ($mode == 'research' ? QUE_RESEARCH : $mode))); |
| 23 | 23 | |
| 24 | -if($building_sort = sys_get_param_id('sort_elements')) { |
|
| 25 | - if(!empty($lang['player_option_building_sort'][$building_sort])) { |
|
| 24 | +if ($building_sort = sys_get_param_id('sort_elements')) { |
|
| 25 | + if (!empty($lang['player_option_building_sort'][$building_sort])) { |
|
| 26 | 26 | SN::$user_options[array(PLAYER_OPTION_BUILDING_SORT, $mode)] = $building_sort; |
| 27 | 27 | SN::$user_options[array(PLAYER_OPTION_BUILDING_SORT_INVERSE, $mode)] = sys_get_param_id('sort_elements_inverse', 0); |
| 28 | 28 | } |
@@ -15,34 +15,34 @@ discard block |
||
| 15 | 15 | $template = gettemplate('notes', true); |
| 16 | 16 | |
| 17 | 17 | $result = array(); |
| 18 | -if(($result_message = sys_get_param_str('MESSAGE')) && isset($lang[$result_message])) { |
|
| 18 | +if (($result_message = sys_get_param_str('MESSAGE')) && isset($lang[$result_message])) { |
|
| 19 | 19 | $result[] = array('STATUS' => sys_get_param_int('STATUS'), 'MESSAGE' => $lang[$result_message]); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | $note_id_edit = sys_get_param_id('note_id_edit'); |
| 23 | -if(sys_get_param('note_delete')) { |
|
| 23 | +if (sys_get_param('note_delete')) { |
|
| 24 | 24 | try { |
| 25 | 25 | $not = ''; |
| 26 | 26 | $query_where = ''; |
| 27 | - switch(sys_get_param_str('note_delete_range')) { |
|
| 27 | + switch (sys_get_param_str('note_delete_range')) { |
|
| 28 | 28 | case 'all': |
| 29 | 29 | break; |
| 30 | 30 | |
| 31 | 31 | case 'marked_not': |
| 32 | 32 | $not = 'NOT'; |
| 33 | 33 | case 'marked': |
| 34 | - if(!is_array($notes_marked = sys_get_param('note'))) { |
|
| 34 | + if (!is_array($notes_marked = sys_get_param('note'))) { |
|
| 35 | 35 | throw new exception('note_err_none_selected', ERR_WARNING); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | $notes_marked_filtered = array(); |
| 39 | - foreach($notes_marked as $note_id => $note_select) { |
|
| 40 | - if($note_select == 'on' && $note_id = idval($note_id)) { |
|
| 39 | + foreach ($notes_marked as $note_id => $note_select) { |
|
| 40 | + if ($note_select == 'on' && $note_id = idval($note_id)) { |
|
| 41 | 41 | $notes_marked_filtered[] = $note_id; |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if(empty($notes_marked_filtered)) { |
|
| 45 | + if (empty($notes_marked_filtered)) { |
|
| 46 | 46 | throw new exception('note_err_none_selected', ERR_WARNING); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | doquery("DELETE FROM {{notes}} WHERE `owner` = {$user['id']} {$query_where};"); |
| 60 | 60 | sn_db_transaction_commit(); |
| 61 | 61 | throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE); |
| 62 | - } catch(exception $e) { |
|
| 62 | + } catch (exception $e) { |
|
| 63 | 63 | $note_id_edit = 0; |
| 64 | 64 | sn_db_transaction_rollback(); |
| 65 | 65 | $result[] = array( |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | 'MESSAGE' => $lang[$e->getMessage()], |
| 68 | 68 | ); |
| 69 | 69 | } |
| 70 | -} elseif(($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) { |
|
| 70 | +} elseif (($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) { |
|
| 71 | 71 | $note_title == db_escape($lang['note_new_title']) ? $note_title = '' : false; |
| 72 | 72 | ($note_text = sys_get_param_str('note_text')) == db_escape($lang['note_new_text']) ? $note_text = '' : false; |
| 73 | 73 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $note_system = max(0, min(sys_get_param_id('note_system'), SN::$config->game_maxSystem)); |
| 77 | 77 | $note_planet = max(0, min(sys_get_param_id('note_planet'), SN::$config->game_maxPlanet + 1)); |
| 78 | 78 | |
| 79 | - if(!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) { |
|
| 79 | + if (!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) { |
|
| 80 | 80 | throw new exception('note_err_note_empty', ERR_WARNING); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -85,15 +85,15 @@ discard block |
||
| 85 | 85 | $note_sticky = intval(sys_get_param_id('note_sticky')) ? 1 : 0; |
| 86 | 86 | |
| 87 | 87 | sn_db_transaction_start(); |
| 88 | - if($note_id_edit) { |
|
| 88 | + if ($note_id_edit) { |
|
| 89 | 89 | $check_note_id = doquery("SELECT `id`, `owner` FROM {{notes}} WHERE `id` = {$note_id_edit} LIMIT 1 FOR UPDATE", true); |
| 90 | - if(!$check_note_id) { |
|
| 90 | + if (!$check_note_id) { |
|
| 91 | 91 | throw new exception('note_err_note_not_found', ERR_ERROR); |
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - if($note_id_edit) { |
|
| 96 | - if($check_note_id['owner'] != $user['id']) { |
|
| 95 | + if ($note_id_edit) { |
|
| 96 | + if ($check_note_id['owner'] != $user['id']) { |
|
| 97 | 97 | throw new exception('note_err_owner_wrong', ERR_ERROR); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | sn_db_transaction_commit(); |
| 109 | 109 | sys_redirect('notes.php?STATUS=' . ERR_NONE . '&MESSAGE=' . ($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added')); |
| 110 | 110 | // throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE); |
| 111 | - } catch(exception $e) { |
|
| 111 | + } catch (exception $e) { |
|
| 112 | 112 | $note_id_edit = 0; |
| 113 | 113 | sn_db_transaction_rollback(); |
| 114 | 114 | $result[] = array( |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | -if(!$note_id_edit) { |
|
| 121 | +if (!$note_id_edit) { |
|
| 122 | 122 | \Note\Note::note_assign($template, array( |
| 123 | 123 | 'id' => 0, |
| 124 | 124 | 'time' => SN_TIME_NOW, |
@@ -131,13 +131,13 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | $note_exist = false; |
| 133 | 133 | $notes_query = doquery("SELECT * FROM {{notes}} WHERE owner={$user['id']} ORDER BY priority DESC, galaxy ASC, system ASC, planet ASC, planet_type ASC, `time` DESC"); |
| 134 | -while($note_row = db_fetch($notes_query)) { |
|
| 134 | +while ($note_row = db_fetch($notes_query)) { |
|
| 135 | 135 | \Note\Note::note_assign($template, $note_row); |
| 136 | 136 | $note_exist = $note_exist || $note_row['id'] == $note_id_edit; |
| 137 | 137 | } |
| 138 | 138 | $note_id_edit = $note_exist ? $note_id_edit : 0; |
| 139 | 139 | |
| 140 | -foreach($note_priority_classes as $note_priority_id => $note_priority_class) { |
|
| 140 | +foreach ($note_priority_classes as $note_priority_id => $note_priority_class) { |
|
| 141 | 141 | $template->assign_block_vars('note_priority', array( |
| 142 | 142 | 'ID' => $note_priority_id, |
| 143 | 143 | 'CLASS' => $note_priority_classes[$note_priority_id], |
@@ -145,14 +145,14 @@ discard block |
||
| 145 | 145 | )); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | -foreach($lang['sys_planet_type'] as $planet_type_id => $planet_type_string) { |
|
| 148 | +foreach ($lang['sys_planet_type'] as $planet_type_id => $planet_type_string) { |
|
| 149 | 149 | $template->assign_block_vars('planet_type', array( |
| 150 | 150 | 'ID' => $planet_type_id, |
| 151 | 151 | 'TEXT' => $planet_type_string, |
| 152 | 152 | )); |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | -foreach($result as $result_data) { |
|
| 155 | +foreach ($result as $result_data) { |
|
| 156 | 156 | $template->assign_block_vars('result', $result_data); |
| 157 | 157 | } |
| 158 | 158 | |