@@ -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 | } |
@@ -95,12 +95,12 @@ discard block |
||
| 95 | 95 | $this->prepare(); |
| 96 | 96 | |
| 97 | 97 | $this->manifest['active'] = false; |
| 98 | - if(!empty($this->config) && is_array($this->config['db'])) { |
|
| 98 | + if (!empty($this->config) && is_array($this->config['db'])) { |
|
| 99 | 99 | // БД, отличная от стандартной |
| 100 | 100 | $this->db = classSupernova::$gc->db; |
| 101 | 101 | |
| 102 | 102 | $this->db->sn_db_connect($this->config['db']); |
| 103 | - if($this->manifest['active'] = $this->db->connected) { |
|
| 103 | + if ($this->manifest['active'] = $this->db->connected) { |
|
| 104 | 104 | $this->provider_id = ACCOUNT_PROVIDER_CENTRAL; |
| 105 | 105 | |
| 106 | 106 | $this->domain = $this->config['domain']; |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | // Fallback to local DB |
| 117 | - if(!$this->manifest['active']) { |
|
| 117 | + if (!$this->manifest['active']) { |
|
| 118 | 118 | $this->db = classSupernova::$db; |
| 119 | 119 | |
| 120 | 120 | $this->provider_id = ACCOUNT_PROVIDER_LOCAL; |
@@ -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 | |
@@ -243,7 +243,7 @@ discard block |
||
| 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,7 +305,7 @@ 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); |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | mymail($confirmation['email'], $message_header, htmlspecialchars($message)); |
| 314 | 314 | |
| 315 | 315 | $users_translated = PlayerToAccountTranslate::db_translate_get_users_from_account_list($this->provider_id, $this->account->account_id); // OK 4.5 |
| 316 | - if(!empty($users_translated)) { |
|
| 316 | + if (!empty($users_translated)) { |
|
| 317 | 317 | // Отправляем в лички письмо о сбросе пароля |
| 318 | 318 | |
| 319 | 319 | // ПО ОПРЕДЕЛЕНИЮ в $users_translated только |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | $message = sprintf(classLocale::$lang['sys_password_reset_message_body'], $new_password_unsafe); |
| 325 | 325 | $message = sys_bbcodeParse($message) . '<br><br>'; |
| 326 | 326 | |
| 327 | - foreach($users_translated as $user_id => $providers_list) { |
|
| 327 | + foreach ($users_translated as $user_id => $providers_list) { |
|
| 328 | 328 | DBStaticMessages::msgSendFromAdmin($user_id, classLocale::$lang['sys_login_register_message_title'], $message); |
| 329 | 329 | } |
| 330 | 330 | } else { |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | $this->flog('Регистрация: начинаем. Провайдер ' . $this->provider_id); |
| 378 | 378 | |
| 379 | 379 | try { |
| 380 | - if(!$this->is_register) { |
|
| 380 | + if (!$this->is_register) { |
|
| 381 | 381 | $this->flog('Регистрация: не выставлен флаг регистрации - пропускаем'); |
| 382 | 382 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
| 383 | 383 | } |
@@ -387,8 +387,8 @@ discard block |
||
| 387 | 387 | sn_db_transaction_start(); |
| 388 | 388 | |
| 389 | 389 | $this->account->db_get_by_name_or_email($this->input_login_unsafe, $this->input_email_unsafe); |
| 390 | - if($this->account->is_exists) { |
|
| 391 | - if($this->account->account_email == $this->input_email_unsafe) { |
|
| 390 | + if ($this->account->is_exists) { |
|
| 391 | + if ($this->account->account_email == $this->input_email_unsafe) { |
|
| 392 | 392 | throw new Exception(REGISTER_ERROR_EMAIL_EXISTS, ERR_ERROR); |
| 393 | 393 | } else { |
| 394 | 394 | throw new Exception(REGISTER_ERROR_ACCOUNT_NAME_EXISTS, ERR_ERROR); |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | // А вот это пока не нужно. Трансляцией аккаунтов в юзеров и созданием новых юзеров для новозашедших аккаунтов занимается Auth |
| 411 | 411 | // $this->register_account(); |
| 412 | 412 | sn_db_transaction_commit(); |
| 413 | - } catch(Exception $e) { |
|
| 413 | + } catch (Exception $e) { |
|
| 414 | 414 | sn_db_transaction_rollback(); |
| 415 | 415 | $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false; |
| 416 | 416 | } |
@@ -424,19 +424,19 @@ discard block |
||
| 424 | 424 | * @return int Результат попытки |
| 425 | 425 | */ |
| 426 | 426 | protected function login_cookie() { |
| 427 | - if($this->account_login_status != LOGIN_UNDEFINED) { |
|
| 427 | + if ($this->account_login_status != LOGIN_UNDEFINED) { |
|
| 428 | 428 | return $this->account_login_status; |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | // Пытаемся войти по куке |
| 432 | - if(!empty($_COOKIE[$this->cookie_name])) { |
|
| 433 | - if(count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
| 432 | + if (!empty($_COOKIE[$this->cookie_name])) { |
|
| 433 | + if (count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
| 434 | 434 | list($account_id_unsafe, $cookie_password_hash_salted, $user_remember_me) = explode(AUTH_COOKIE_DELIMETER, $_COOKIE[$this->cookie_name]); |
| 435 | 435 | } else { |
| 436 | 436 | list($account_id_unsafe, $user_name, $cookie_password_hash_salted, $user_remember_me) = explode("/%/", $_COOKIE[$this->cookie_name]); |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | - if( |
|
| 439 | + if ( |
|
| 440 | 440 | $this->account->db_get_by_id($account_id_unsafe) |
| 441 | 441 | && ($this->password_encode_for_cookie($this->account->account_password) == $cookie_password_hash_salted) |
| 442 | 442 | ) { |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | } |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - if($this->account_login_status != LOGIN_SUCCESS) { |
|
| 448 | + if ($this->account_login_status != LOGIN_SUCCESS) { |
|
| 449 | 449 | // Невалидная кука - чистим |
| 450 | 450 | $this->cookie_clear(); |
| 451 | 451 | } |
@@ -462,29 +462,29 @@ discard block |
||
| 462 | 462 | protected function login_username() { |
| 463 | 463 | // TODO - Логин по старым именам |
| 464 | 464 | try { |
| 465 | - if(!$this->is_login) { |
|
| 465 | + if (!$this->is_login) { |
|
| 466 | 466 | $this->flog('Логин: не выставлен флаг входа в игру - это не логин'); |
| 467 | 467 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | // TODO Пустое имя аккаунта |
| 471 | - if(!$this->input_login_unsafe) { |
|
| 471 | + if (!$this->input_login_unsafe) { |
|
| 472 | 472 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | $this->login_validate_input(); |
| 476 | 476 | |
| 477 | - if(!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) { |
|
| 477 | + if (!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) { |
|
| 478 | 478 | throw new Exception(LOGIN_ERROR_USERNAME, ERR_ERROR); |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - if(!$this->account->password_check($this->input_login_password_raw)) { |
|
| 481 | + if (!$this->account->password_check($this->input_login_password_raw)) { |
|
| 482 | 482 | throw new Exception(LOGIN_ERROR_PASSWORD, ERR_ERROR); |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | $this->cookie_set(); |
| 486 | 486 | $this->account_login_status = LOGIN_SUCCESS; |
| 487 | - } catch(Exception $e) { |
|
| 487 | + } catch (Exception $e) { |
|
| 488 | 488 | $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false; |
| 489 | 489 | } |
| 490 | 490 | |
@@ -506,11 +506,11 @@ discard block |
||
| 506 | 506 | protected function cookie_set($account_to_impersonate = null) { |
| 507 | 507 | $this_account = is_object($account_to_impersonate) ? $account_to_impersonate : $this->account; |
| 508 | 508 | |
| 509 | - if(!is_object($this_account) || !$this_account->is_exists) { |
|
| 509 | + if (!is_object($this_account) || !$this_account->is_exists) { |
|
| 510 | 510 | throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR); |
| 511 | 511 | } |
| 512 | 512 | |
| 513 | - if(is_object($account_to_impersonate) && $account_to_impersonate->is_exists) { |
|
| 513 | + if (is_object($account_to_impersonate) && $account_to_impersonate->is_exists) { |
|
| 514 | 514 | sn_setcookie($this->cookie_name_impersonate, $_COOKIE[$this->cookie_name], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $this->domain); |
| 515 | 515 | } |
| 516 | 516 | |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | // OK v4.1 |
| 529 | 529 | protected function cookie_clear() { |
| 530 | 530 | // Автоматически вообще-то - если установлена кука имперсонатора - то чистим обычную, а куку имперсонатора - копируем в неё |
| 531 | - if(!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
| 531 | + if (!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
| 532 | 532 | sn_setcookie($this->cookie_name, $_COOKIE[$this->cookie_name_impersonate], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $this->domain); |
| 533 | 533 | sn_setcookie($this->cookie_name_impersonate, '', SN_TIME_NOW - PERIOD_WEEK, $this->sn_root_path, $this->domain); |
| 534 | 534 | } else { |
@@ -547,10 +547,10 @@ discard block |
||
| 547 | 547 | protected function login_validate_input() { |
| 548 | 548 | // Проверяем, что бы в начале и конце не было пустых символов |
| 549 | 549 | // TODO - при копировании Эксель -> Опера - в конце образуются пустые места. Это не должно быть проблемой! Вынести проверку пароля в регистрацию! |
| 550 | - if($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
| 550 | + if ($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
| 551 | 551 | throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR); |
| 552 | 552 | } |
| 553 | - if(!$this->input_login_password_raw) { |
|
| 553 | + if (!$this->input_login_password_raw) { |
|
| 554 | 554 | throw new Exception(LOGIN_ERROR_PASSWORD_EMPTY, ERR_ERROR); |
| 555 | 555 | } |
| 556 | 556 | } |
@@ -566,37 +566,37 @@ discard block |
||
| 566 | 566 | $this->login_validate_input(); |
| 567 | 567 | |
| 568 | 568 | // Если нет имени пользователя - NO GO! |
| 569 | - if(!$this->input_login_unsafe) { |
|
| 569 | + if (!$this->input_login_unsafe) { |
|
| 570 | 570 | throw new Exception(LOGIN_ERROR_USERNAME_EMPTY, ERR_ERROR); |
| 571 | 571 | } |
| 572 | 572 | // Если логин имеет запрещенные символы - NO GO! |
| 573 | - if(strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
| 573 | + if (strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
| 574 | 574 | throw new Exception(LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS, ERR_ERROR); |
| 575 | 575 | } |
| 576 | 576 | // Если логин меньше минимальной длины - NO GO! |
| 577 | - if(strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) { |
|
| 577 | + if (strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) { |
|
| 578 | 578 | throw new Exception(REGISTER_ERROR_USERNAME_SHORT, ERR_ERROR); |
| 579 | 579 | } |
| 580 | 580 | // Если пароль меньше минимальной длины - NO GO! |
| 581 | - if(strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) { |
|
| 581 | + if (strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) { |
|
| 582 | 582 | throw new Exception(REGISTER_ERROR_PASSWORD_INSECURE, ERR_ERROR); |
| 583 | 583 | } |
| 584 | 584 | // Если пароль имеет пробельные символы в начале или конце - NO GO! |
| 585 | - if($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
| 585 | + if ($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
| 586 | 586 | throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR); |
| 587 | 587 | } |
| 588 | 588 | // Если пароль не совпадает с подтверждением - NO GO! То, что у пароля нет пробельных символов в начале/конце - мы уже проверили выше |
| 589 | 589 | //Если они есть у повтора - значит пароль и повтор не совпадут |
| 590 | - if($this->input_login_password_raw <> $this->input_login_password_raw_repeat) { |
|
| 590 | + if ($this->input_login_password_raw <> $this->input_login_password_raw_repeat) { |
|
| 591 | 591 | throw new Exception(REGISTER_ERROR_PASSWORD_DIFFERENT, ERR_ERROR); |
| 592 | 592 | } |
| 593 | 593 | // Если нет емейла - NO GO! |
| 594 | 594 | // TODO - регистрация без емейла |
| 595 | - if(!$this->input_email_unsafe) { |
|
| 595 | + if (!$this->input_email_unsafe) { |
|
| 596 | 596 | throw new Exception(REGISTER_ERROR_EMAIL_EMPTY, ERR_ERROR); |
| 597 | 597 | } |
| 598 | 598 | // Если емейл не является емейлом - NO GO! |
| 599 | - if(!is_email($this->input_email_unsafe)) { |
|
| 599 | + if (!is_email($this->input_email_unsafe)) { |
|
| 600 | 600 | throw new Exception(REGISTER_ERROR_EMAIL_WRONG, ERR_ERROR); |
| 601 | 601 | } |
| 602 | 602 | } |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | return core_auth::make_random_password(); |
| 626 | 626 | } |
| 627 | 627 | protected function flog($message, $die = false) { |
| 628 | - if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
| 628 | + if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
| 629 | 629 | return; |
| 630 | 630 | } |
| 631 | 631 | list($called, $caller) = debug_backtrace(false); |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
| 640 | 640 | |
| 641 | 641 | classSupernova::log_file("$message - $caller_name"); |
| 642 | - if($die) { |
|
| 642 | + if ($die) { |
|
| 643 | 643 | $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
| 644 | 644 | } |
| 645 | 645 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | /** |
| 25 | 25 | * Добавляет юнит к списку бонусов |
| 26 | 26 | * |
| 27 | - * @param $unit_id |
|
| 27 | + * @param integer $unit_id |
|
| 28 | 28 | * @param $unit_level |
| 29 | 29 | */ |
| 30 | 30 | public function add_unit_by_snid($unit_id, $unit_level) { |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * Выдает финальный бонус в виде множителя |
| 69 | 69 | * |
| 70 | - * @param string|int $param - ИД бонуса |
|
| 70 | + * @param string $param - ИД бонуса |
|
| 71 | 71 | * |
| 72 | 72 | * @return float |
| 73 | 73 | */ |
@@ -28,12 +28,12 @@ discard block |
||
| 28 | 28 | * @param $unit_level |
| 29 | 29 | */ |
| 30 | 30 | public function add_unit_by_snid($unit_id, $unit_level) { |
| 31 | - if(!$unit_level) { |
|
| 31 | + if (!$unit_level) { |
|
| 32 | 32 | return; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - foreach(static::$_bonus_group as $param_name => $unit_list) { |
|
| 36 | - if(!empty($unit_list[$unit_id])) { |
|
| 35 | + foreach (static::$_bonus_group as $param_name => $unit_list) { |
|
| 36 | + if (!empty($unit_list[$unit_id])) { |
|
| 37 | 37 | // Простейший вариант - мультипликатор по базе |
| 38 | 38 | // Общий мультипликатор добавляется в конец |
| 39 | 39 | $this->grants[$param_name][$unit_id] = $unit_level; |
@@ -82,16 +82,16 @@ discard block |
||
| 82 | 82 | // $this->grants[$param_name][$unit_id] = $unit_level * get_unit_param($unit_id, P_BONUS_VALUE) / 100;; |
| 83 | 83 | $value_add = floatval($base_value); |
| 84 | 84 | $cumulative = 1.0; // Для случая BONUS_PERCENT |
| 85 | - if(!empty($this->grants[$param]) && is_array($this->grants[$param])) { |
|
| 86 | - foreach($this->grants[$param] as $unit_id => $unit_level) { |
|
| 85 | + if (!empty($this->grants[$param]) && is_array($this->grants[$param])) { |
|
| 86 | + foreach ($this->grants[$param] as $unit_id => $unit_level) { |
|
| 87 | 87 | $unit_bonus = 0; |
| 88 | - if($unit_id < 0) { |
|
| 88 | + if ($unit_id < 0) { |
|
| 89 | 89 | // Meta-unit - leave as is |
| 90 | 90 | } else { |
| 91 | 91 | // TODO - Подумать, что будет при смешивании разных бонусов и как этого избежать |
| 92 | 92 | $bonus_value = get_unit_param($unit_id, P_BONUS_VALUE); |
| 93 | 93 | $bonus_type = get_unit_param($unit_id, P_BONUS_TYPE); |
| 94 | - switch($bonus_type) { |
|
| 94 | + switch ($bonus_type) { |
|
| 95 | 95 | case BONUS_PERCENT: |
| 96 | 96 | $unit_bonus = $unit_level * $bonus_value / 100; |
| 97 | 97 | $cumulative += $unit_bonus; |
@@ -1,5 +1,4 @@ |
||
| 1 | 1 | <?php |
| 2 | -use DBStatic\DBStaticUser; |
|
| 3 | 2 | |
| 4 | 3 | /** |
| 5 | 4 | * |
@@ -190,9 +190,9 @@ discard block |
||
| 190 | 190 | 'advGoogleLeftMenuCode' => '(Place here code for banner)', |
| 191 | 191 | |
| 192 | 192 | // Alliance bonus calculations |
| 193 | - 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
| 193 | + 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
| 194 | 194 | 'ali_bonus_brackets' => 10, // Brackets count for ALI_BONUS_BY_RANK |
| 195 | - 'ali_bonus_brackets_divisor' => 10,// Bonus divisor for ALI_BONUS_BY_RANK |
|
| 195 | + 'ali_bonus_brackets_divisor' => 10, // Bonus divisor for ALI_BONUS_BY_RANK |
|
| 196 | 196 | 'ali_bonus_divisor' => 10000000, // Rank divisor for ALI_BONUS_BY_POINTS |
| 197 | 197 | 'ali_bonus_members' => 10, // Minumum alliace size to start using bonus |
| 198 | 198 | |
@@ -223,25 +223,25 @@ discard block |
||
| 223 | 223 | 'deuterium_basic_income' => 0, |
| 224 | 224 | 'eco_scale_storage' => 1, |
| 225 | 225 | 'eco_stockman_fleet' => '', // Black Market - Starting amount of s/h ship merchant to sell |
| 226 | - 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
| 226 | + 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
| 227 | 227 | 'empire_mercenary_base_period' => PERIOD_MONTH, // Base |
| 228 | 228 | 'empire_mercenary_temporary' => 0, // Temporary empire-wide mercenaries |
| 229 | 229 | 'energy_basic_income' => 0, |
| 230 | 230 | |
| 231 | 231 | // Bashing protection settings |
| 232 | - 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
| 233 | - 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
| 234 | - 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
| 235 | - 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
| 236 | - 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
| 232 | + 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
| 233 | + 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
| 234 | + 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
| 235 | + 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
| 236 | + 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
| 237 | 237 | |
| 238 | 238 | 'Fleet_Cdr' => 30, |
| 239 | 239 | 'fleet_speed' => 1, |
| 240 | 240 | |
| 241 | 241 | 'fleet_update_interval' => 4, |
| 242 | 242 | |
| 243 | - 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
| 244 | - 'game_counter' => 0, // Does built-in page hit counter is on? |
|
| 243 | + 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
| 244 | + 'game_counter' => 0, // Does built-in page hit counter is on? |
|
| 245 | 245 | // Defaults |
| 246 | 246 | 'game_default_language' => 'ru', |
| 247 | 247 | 'game_default_skin' => 'skins/EpicBlue/', |
@@ -255,13 +255,13 @@ discard block |
||
| 255 | 255 | 'game_maxSystem' => 199, |
| 256 | 256 | 'game_maxPlanet' => 15, |
| 257 | 257 | // Game global settings |
| 258 | - 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
| 258 | + 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
| 259 | 259 | 'game_name' => 'SuperNova', // Server name (would be on banners and on top of left menu) |
| 260 | 260 | |
| 261 | 261 | 'game_news_actual' => 259200, // How long announcement would be marked as "New". In seconds. Default - 3 days |
| 262 | - 'game_news_overview' => 3, // How much last news to show in Overview page |
|
| 262 | + 'game_news_overview' => 3, // How much last news to show in Overview page |
|
| 263 | 263 | // Noob protection |
| 264 | - 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
| 264 | + 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
| 265 | 265 | 'game_noob_points' => 5000, // Below this point user threated as noob. 0 to disable |
| 266 | 266 | |
| 267 | 267 | 'game_multiaccount_enabled' => 0, // 1 - allow interactions for players with same IP (multiaccounts) |
@@ -311,8 +311,8 @@ discard block |
||
| 311 | 311 | 'payment_currency_exchange_wmu' => 30, |
| 312 | 312 | 'payment_currency_exchange_wmz' => 1, |
| 313 | 313 | |
| 314 | - 'payment_lot_price' => 1, // Lot price in default currency |
|
| 315 | - 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
| 314 | + 'payment_lot_price' => 1, // Lot price in default currency |
|
| 315 | + 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
| 316 | 316 | |
| 317 | 317 | 'planet_teleport_cost' => 50000, // |
| 318 | 318 | 'planet_teleport_timeout' => 86400, // |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | 'resource_multiplier' => 1, |
| 331 | 331 | |
| 332 | 332 | //Roleplay system |
| 333 | - 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
| 333 | + 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
| 334 | 334 | 'rpg_bonus_minimum' => 10000, // Minimum DM ammount for starting paying bonuses to affiliate |
| 335 | 335 | |
| 336 | 336 | // Black Market - General |
@@ -173,6 +173,9 @@ |
||
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | |
| 176 | + /** |
|
| 177 | + * @param string $path |
|
| 178 | + */ |
|
| 176 | 179 | protected function lng_try_filepath($path, $file_path_relative) { |
| 177 | 180 | $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative; |
| 178 | 181 | return file_exists($file_path) ? $file_path : false; |
@@ -35,13 +35,13 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | $this->container = array(); |
| 37 | 37 | |
| 38 | - if(classSupernova::$cache->getMode() != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) { |
|
| 38 | + if (classSupernova::$cache->getMode() != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) { |
|
| 39 | 39 | $this->cache = classSupernova::$cache; |
| 40 | 40 | classSupernova::log_file('locale.__constructor: Cache is present'); |
| 41 | 41 | //$this->cache->unset_by_prefix($this->cache_prefix); // TODO - remove? 'cause debug! |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - if($enable_stat_usage && empty($this->stat_usage)) { |
|
| 44 | + if ($enable_stat_usage && empty($this->stat_usage)) { |
|
| 45 | 45 | $this->enable_stat_usage = $enable_stat_usage; |
| 46 | 46 | $this->usage_stat_load(); |
| 47 | 47 | // TODO shutdown function |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | unset($fallback[$this->active]); |
| 68 | 68 | |
| 69 | 69 | // Проходим по оставшимся локалям |
| 70 | - foreach($fallback as $try_language) { |
|
| 70 | + foreach ($fallback as $try_language) { |
|
| 71 | 71 | // Если нет такой строки - пытаемся вытащить из кэша |
| 72 | - if(!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
| 72 | + if (!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
| 73 | 73 | $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix . $try_language . '_' . $offset); |
| 74 | 74 | // Записываем результат работы кэша |
| 75 | 75 | $locale_cache_statistic['queries']++; |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // Если мы как-то где-то нашли строку... |
| 81 | - if(isset($this->container[$try_language][$offset])) { |
|
| 81 | + if (isset($this->container[$try_language][$offset])) { |
|
| 82 | 82 | // ...значит она получена в результате фоллбэка и записываем её в кэш и контейнер |
| 83 | 83 | $this[$offset] = $this->container[$try_language][$offset]; |
| 84 | 84 | $locale_cache_statistic['fallbacks']++; |
@@ -94,16 +94,16 @@ discard block |
||
| 94 | 94 | $this->container[$this->active][] = $value; |
| 95 | 95 | } else { |
| 96 | 96 | $this->container[$this->active][$offset] = $value; |
| 97 | - if($this->cache) { |
|
| 97 | + if ($this->cache) { |
|
| 98 | 98 | $this->cache->__set($this->cache_prefix_lang . $offset, $value); |
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | public function offsetExists($offset) { |
| 103 | 103 | // Шорткат если у нас уже есть строка в памяти PHP |
| 104 | - if(!isset($this->container[$this->active][$offset])) { |
|
| 104 | + if (!isset($this->container[$this->active][$offset])) { |
|
| 105 | 105 | // pdump($this->cache_prefix_lang . $offset); |
| 106 | - if(!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) { |
|
| 106 | + if (!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) { |
|
| 107 | 107 | // pdump($this->cache_prefix_lang . $offset); |
| 108 | 108 | // Если нету такой строки - делаем фоллбэк |
| 109 | 109 | $this->locale_string_fallback($offset); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | } |
| 120 | 120 | public function offsetGet($offset) { |
| 121 | 121 | $value = $this->offsetExists($offset) ? $this->container[$this->active][$offset] : null; |
| 122 | - if($this->enable_stat_usage) { |
|
| 122 | + if ($this->enable_stat_usage) { |
|
| 123 | 123 | $this->usage_stat_log($offset, $value); |
| 124 | 124 | } |
| 125 | 125 | return $value; |
@@ -134,16 +134,16 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | |
| 136 | 136 | public function usage_stat_load() { |
| 137 | - $this->stat_usage = classSupernova::$cache->lng_stat_usage = array(); |
|
| 138 | - if(empty($this->stat_usage)) { |
|
| 137 | + $this->stat_usage = classSupernova::$cache->lng_stat_usage = array(); |
|
| 138 | + if (empty($this->stat_usage)) { |
|
| 139 | 139 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{lng_usage_stat}}`"); |
| 140 | - while($row = db_fetch($query)) { |
|
| 140 | + while ($row = db_fetch($query)) { |
|
| 141 | 141 | $this->stat_usage[$row['lang_code'] . ':' . $row['string_id'] . ':' . $row['file'] . ':' . $row['line']] = $row['is_empty']; |
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | 145 | public function usage_stat_save() { |
| 146 | - if(!empty($this->stat_usage_new)) { |
|
| 146 | + if (!empty($this->stat_usage_new)) { |
|
| 147 | 147 | classSupernova::$cache->lng_stat_usage = $this->stat_usage; |
| 148 | 148 | classSupernova::$db->doSelect("SELECT 1 FROM `{{lng_usage_stat}}` LIMIT 1"); |
| 149 | 149 | // foreach($this->stat_usage_new as &$value) { |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | $file = str_replace('\\', '/', substr($trace[1]['file'], strlen(SN_ROOT_PHYSICAL) - 1)); |
| 173 | 173 | |
| 174 | 174 | $string_id = $this->active . ':' . $offset . ':' . $file . ':' . $trace[1]['line']; |
| 175 | - if(!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) { |
|
| 175 | + if (!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) { |
|
| 176 | 176 | $this->stat_usage[$string_id] = empty($value); |
| 177 | 177 | $this->stat_usage_new[] = array( |
| 178 | 178 | 'lang_code' => $this->active, |
@@ -212,11 +212,11 @@ discard block |
||
| 212 | 212 | $cache_file_key = $this->cache_prefix_lang . '__' . $filename; |
| 213 | 213 | |
| 214 | 214 | // Подключен ли внешний кэш? |
| 215 | - if($this->cache) { |
|
| 215 | + if ($this->cache) { |
|
| 216 | 216 | // Загружен ли уже данный файл? |
| 217 | 217 | $cache_file_status = $this->cache->__get($cache_file_key); |
| 218 | 218 | classSupernova::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); |
| 219 | - if($cache_file_status) { |
|
| 219 | + if ($cache_file_status) { |
|
| 220 | 220 | // Если да - повторять загрузку нет смысла |
| 221 | 221 | return null; |
| 222 | 222 | } |
@@ -230,36 +230,36 @@ discard block |
||
| 230 | 230 | $this->make_fallback($language); |
| 231 | 231 | |
| 232 | 232 | $file_path = ''; |
| 233 | - foreach($this->fallback as $lang_try) { |
|
| 234 | - if(!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
| 233 | + foreach ($this->fallback as $lang_try) { |
|
| 234 | + if (!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
| 235 | 235 | continue; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - if($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
| 238 | + if ($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
| 239 | 239 | break; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - if($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
| 242 | + if ($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
| 243 | 243 | break; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | $file_path = ''; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - if($file_path) { |
|
| 249 | + if ($file_path) { |
|
| 250 | 250 | $a_lang_array = array(); |
| 251 | 251 | include($file_path); |
| 252 | 252 | |
| 253 | - if(!empty($a_lang_array)) { |
|
| 253 | + if (!empty($a_lang_array)) { |
|
| 254 | 254 | $this->merge($a_lang_array); |
| 255 | 255 | |
| 256 | 256 | // Загрузка данных из файла в кэш |
| 257 | - if($this->cache) { |
|
| 257 | + if ($this->cache) { |
|
| 258 | 258 | classSupernova::log_file("Locale: loading '{$filename}' into cache"); |
| 259 | - foreach($a_lang_array as $key => $value) { |
|
| 259 | + foreach ($a_lang_array as $key => $value) { |
|
| 260 | 260 | $value_cache_key = $this->cache_prefix_lang . $key; |
| 261 | - if($this->cache->__isset($value_cache_key)) { |
|
| 262 | - if(is_array($value)) { |
|
| 261 | + if ($this->cache->__isset($value_cache_key)) { |
|
| 262 | + if (is_array($value)) { |
|
| 263 | 263 | $alt_value = $this->cache->__get($value_cache_key); |
| 264 | 264 | $value = array_replace_recursive($alt_value, $value); |
| 265 | 265 | // pdump($alt_value, $alt_value); |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | } |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - if($this->cache) { |
|
| 273 | + if ($this->cache) { |
|
| 274 | 274 | $this->cache->__set($cache_file_key, true); |
| 275 | 275 | } |
| 276 | 276 | |
@@ -283,14 +283,14 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | public function lng_load_i18n($i18n) { |
| 286 | - if(!isset($i18n)) { |
|
| 286 | + if (!isset($i18n)) { |
|
| 287 | 287 | return; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - foreach($i18n as $i18n_data) { |
|
| 291 | - if(is_string($i18n_data)) { |
|
| 290 | + foreach ($i18n as $i18n_data) { |
|
| 291 | + if (is_string($i18n_data)) { |
|
| 292 | 292 | $this->lng_include($i18n_data); |
| 293 | - } elseif(is_array($i18n_data)) { |
|
| 293 | + } elseif (is_array($i18n_data)) { |
|
| 294 | 294 | $this->lng_include($i18n_data['file'], $i18n_data['path']); |
| 295 | 295 | } |
| 296 | 296 | } |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | classSupernova::log_file("locale.switch: Trying to switch language to '{$language_new}'"); |
| 310 | 310 | |
| 311 | - if($language_new == $this->active) { |
|
| 311 | + if ($language_new == $this->active) { |
|
| 312 | 312 | classSupernova::log_file("locale.switch: New language '{$language_new}' is equal to current language '{$this->active}' - EXIT", -1); |
| 313 | 313 | return false; |
| 314 | 314 | } |
@@ -319,10 +319,10 @@ discard block |
||
| 319 | 319 | $this['LANG_INFO'] = $this->lng_get_info($this->active); |
| 320 | 320 | $this->make_fallback($this->active); |
| 321 | 321 | |
| 322 | - if($this->cache) { |
|
| 322 | + if ($this->cache) { |
|
| 323 | 323 | $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang . '__INIT'); |
| 324 | 324 | classSupernova::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); |
| 325 | - if($cache_lang_init_status) { |
|
| 325 | + if ($cache_lang_init_status) { |
|
| 326 | 326 | return false; |
| 327 | 327 | } |
| 328 | 328 | |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | // Loading global language files |
| 339 | 339 | $this->lng_load_i18n(classSupernova::$sn_mvc['i18n']['']); |
| 340 | 340 | |
| 341 | - if($this->cache) { |
|
| 341 | + if ($this->cache) { |
|
| 342 | 342 | classSupernova::log_file("locale.switch: Cache - setting flag " . $this->cache_prefix_lang . '__INIT'); |
| 343 | 343 | $this->cache->__set($this->cache_prefix_lang . '__INIT', true); |
| 344 | 344 | } |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | public function lng_get_info($entry) { |
| 353 | 353 | $file_name = SN_ROOT_PHYSICAL . 'language/' . $entry . '/language.mo.php'; |
| 354 | 354 | $lang_info = array(); |
| 355 | - if(file_exists($file_name)) { |
|
| 355 | + if (file_exists($file_name)) { |
|
| 356 | 356 | include($file_name); |
| 357 | 357 | } |
| 358 | 358 | |
@@ -360,15 +360,15 @@ discard block |
||
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | public function lng_get_list() { |
| 363 | - if(empty($this->lang_list)) { |
|
| 363 | + if (empty($this->lang_list)) { |
|
| 364 | 364 | $this->lang_list = array(); |
| 365 | 365 | |
| 366 | 366 | $path = SN_ROOT_PHYSICAL . 'language/'; |
| 367 | 367 | $dir = dir($path); |
| 368 | - while(false !== ($entry = $dir->read())) { |
|
| 369 | - if(is_dir($path . $entry) && $entry[0] != '.') { |
|
| 368 | + while (false !== ($entry = $dir->read())) { |
|
| 369 | + if (is_dir($path . $entry) && $entry[0] != '.') { |
|
| 370 | 370 | $lang_info = $this->lng_get_info($entry); |
| 371 | - if($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
| 371 | + if ($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
| 372 | 372 | $this->lang_list[$lang_info['LANG_NAME_ISO2']] = $lang_info; |
| 373 | 373 | } |
| 374 | 374 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * @param int $sigma |
| 19 | 19 | * @param bool $strict |
| 20 | 20 | * |
| 21 | - * @return int |
|
| 21 | + * @return double |
|
| 22 | 22 | */ |
| 23 | 23 | public static function sn_rand_gauss($mu = 0, $sigma = 1, $strict = false) { |
| 24 | 24 | // http://ru.wikipedia.org/wiki/Среднеквадратическое_отклонение |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @param float $range_start - Начало диапазона |
| 44 | 44 | * @param float $range_end - Конец диапазона |
| 45 | - * @param bool|int $round - До скольки знаков округлять результат. False - не округлять, True - округлять до целого, 1 - округлять до десятков, 2 - до сотен итд |
|
| 45 | + * @param boolean $round - До скольки знаков округлять результат. False - не округлять, True - округлять до целого, 1 - округлять до десятков, 2 - до сотен итд |
|
| 46 | 46 | * @param int $strict - В сколько сигм надо уложить результат |
| 47 | 47 | * @param bool|false $cut_extreme - надо ли обрезать крайние значения. Например, при $strict = 2 их слишком много |
| 48 | 48 | * |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | * <p>true - транзакция должна быть запущена - для совместимости с $for_update</p> |
| 40 | 40 | * <p>false - всё равно - для совместимости с $for_update</p> |
| 41 | 41 | * |
| 42 | - * @return bool Текущий статус транзакции |
|
| 42 | + * @return null|boolean Текущий статус транзакции |
|
| 43 | 43 | */ |
| 44 | 44 | public function check($status = null) { |
| 45 | 45 | $error_msg = false; |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | - * @param mixed $value |
|
| 29 | + * @param string $value |
|
| 30 | 30 | * |
| 31 | 31 | * @return $this |
| 32 | 32 | */ |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | * @return $this |
| 32 | 32 | */ |
| 33 | 33 | public function literal($value) { |
| 34 | - $this->literal = (string)$value; |
|
| 34 | + $this->literal = (string) $value; |
|
| 35 | 35 | |
| 36 | 36 | return $this; |
| 37 | 37 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * @param $user_id |
| 22 | - * @param $nickUnsafe |
|
| 22 | + * @param string $nickUnsafe |
|
| 23 | 23 | * @param $ally_id |
| 24 | 24 | * @param $message_unsafe |
| 25 | 25 | * @param $chat_message_sender_name_unsafe |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param $alliance |
| 55 | 55 | * @param $where_add |
| 56 | 56 | * @param $start_row |
| 57 | - * @param $page_limit |
|
| 57 | + * @param integer $page_limit |
|
| 58 | 58 | * |
| 59 | 59 | * @return array|bool|mysqli_result|null |
| 60 | 60 | */ |
@@ -157,7 +157,7 @@ |
||
| 157 | 157 | * @return array|bool|mysqli_result|null |
| 158 | 158 | */ |
| 159 | 159 | public static function db_chat_player_get($player_id, $fields) { |
| 160 | - return classSupernova::$db->doSelectFetchArray("SELECT {$fields} FROM {{chat_player}} WHERE `chat_player_player_id` = {$player_id} LIMIT 1"); |
|
| 160 | + return classSupernova::$db->doSelectFetchArray("select {$fields} FROM {{chat_player}} WHERE `chat_player_player_id` = {$player_id} LIMIT 1"); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | |
@@ -467,6 +467,12 @@ |
||
| 467 | 467 | {$StartRec}, 25;"); |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | + /** |
|
| 471 | + * @param integer $message_type |
|
| 472 | + * @param string $from_unsafe |
|
| 473 | + * @param string $subject_unsafe |
|
| 474 | + * @param string $text_unsafe |
|
| 475 | + */ |
|
| 470 | 476 | public static function db_message_insert_all($message_type, $from_unsafe, $subject_unsafe, $text_unsafe) { |
| 471 | 477 | $message_type_safe = intval($message_type); |
| 472 | 478 | $from_safe = db_escape($from_unsafe); |