@@ -1,18 +1,18 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
| 3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
| 4 | 4 | classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | $template = gettemplate('ali_search', true); |
| 8 | 8 | |
| 9 | 9 | $ali_search_text = sys_get_param_str('searchtext'); |
| 10 | -if($ali_search_text) { |
|
| 10 | +if ($ali_search_text) { |
|
| 11 | 11 | $template->assign_var('SEARCH_TEXT', $ali_search_text); |
| 12 | 12 | |
| 13 | 13 | $search = DBStaticAlly::db_ally_search_by_name_or_tag($ali_search_text); |
| 14 | - if(classSupernova::$db->db_num_rows($search)) { |
|
| 15 | - while($ally_row = db_fetch($search)) { |
|
| 14 | + if (classSupernova::$db->db_num_rows($search)) { |
|
| 15 | + while ($ally_row = db_fetch($search)) { |
|
| 16 | 16 | $template->assign_block_vars('alliances', array( |
| 17 | 17 | 'ID' => $ally_row['id'], |
| 18 | 18 | 'TAG' => $ally_row['ally_tag'], |
@@ -169,6 +169,11 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | // OK v4 |
| 171 | 171 | // TODO - вынести в отдельный класс |
| 172 | +/** |
|
| 173 | + * @param string $db_id_field_name |
|
| 174 | + * @param string $db_table_name |
|
| 175 | + * @param string $db_value_field_name |
|
| 176 | + */ |
|
| 172 | 177 | function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) { |
| 173 | 178 | $current_value_safe = db_escape($current_value_unsafe); |
| 174 | 179 | $value_id = classSupernova::$db->doSelectFetch("SELECT `{$db_id_field_name}` FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE"); |
@@ -487,8 +492,8 @@ discard block |
||
| 487 | 492 | |
| 488 | 493 | |
| 489 | 494 | /** |
| 490 | - * @param $user_id |
|
| 491 | - * @param $change_type |
|
| 495 | + * @param integer $user_id |
|
| 496 | + * @param integer $change_type |
|
| 492 | 497 | * @param $dark_matter |
| 493 | 498 | * @param $comment_unsafe |
| 494 | 499 | * @param $rowUserNameUnsafe |
@@ -509,7 +514,7 @@ discard block |
||
| 509 | 514 | /** |
| 510 | 515 | * @param $user_id_safe |
| 511 | 516 | * |
| 512 | - * @return array|bool|mysqli_result|null |
|
| 517 | + * @return integer |
|
| 513 | 518 | */ |
| 514 | 519 | function db_referral_get_by_id($user_id_safe) { |
| 515 | 520 | $old_referral = classSupernova::$db->doSelectFetch("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;"); |
@@ -540,9 +545,9 @@ discard block |
||
| 540 | 545 | |
| 541 | 546 | // Quests *********************************************************************************************************** |
| 542 | 547 | /** |
| 543 | - * @param $query_add_select |
|
| 548 | + * @param string $query_add_select |
|
| 544 | 549 | * @param $query_add_from |
| 545 | - * @param $query_add_where |
|
| 550 | + * @param string $query_add_where |
|
| 546 | 551 | * |
| 547 | 552 | * @return array|bool|mysqli_result|null |
| 548 | 553 | */ |
@@ -586,11 +591,11 @@ discard block |
||
| 586 | 591 | } |
| 587 | 592 | |
| 588 | 593 | /** |
| 589 | - * @param $quest_name_unsafe |
|
| 590 | - * @param $quest_type |
|
| 591 | - * @param $quest_description_unsafe |
|
| 594 | + * @param string $quest_name_unsafe |
|
| 595 | + * @param integer $quest_type |
|
| 596 | + * @param string $quest_description_unsafe |
|
| 592 | 597 | * @param $quest_conditions |
| 593 | - * @param $quest_rewards |
|
| 598 | + * @param string $quest_rewards |
|
| 594 | 599 | * @param $quest_id |
| 595 | 600 | */ |
| 596 | 601 | function db_quest_update($quest_name_unsafe, $quest_type, $quest_description_unsafe, $quest_conditions, $quest_rewards, $quest_id) { |
@@ -674,7 +679,7 @@ discard block |
||
| 674 | 679 | |
| 675 | 680 | /** |
| 676 | 681 | * @param $payment_id |
| 677 | - * @param $payment_status |
|
| 682 | + * @param integer $payment_status |
|
| 678 | 683 | * @param $comment_unsafe |
| 679 | 684 | */ |
| 680 | 685 | function db_payment_update($payment_id, $payment_status, $comment_unsafe) { |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | |
| 146 | 146 | function db_stat_list_update_ally_stats() { |
| 147 | - return ; |
|
| 147 | + return; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | function db_stat_list_delete_ally_player() { |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | // Log Online ************************************************************************************************************* |
| 424 | 424 | function db_log_online_insert() { |
| 425 | 425 | classSupernova::$db->doInsertSet(TABLE_LOG_USERS_ONLINE, array( |
| 426 | - 'online_count' => (int)classSupernova::$config->var_online_user_count, |
|
| 426 | + 'online_count' => (int) classSupernova::$config->var_online_user_count, |
|
| 427 | 427 | ), array(), DB_INSERT_IGNORE); |
| 428 | 428 | } |
| 429 | 429 | |
@@ -519,10 +519,10 @@ discard block |
||
| 519 | 519 | function db_log_dark_matter_insert($user_id, $change_type, $dark_matter, $comment_unsafe, $rowUserNameUnsafe, $page_url_unsafe) { |
| 520 | 520 | return classSupernova::$db->doInsertSet(TABLE_LOG_DARK_MATTER, array( |
| 521 | 521 | 'log_dark_matter_username' => $rowUserNameUnsafe, |
| 522 | - 'log_dark_matter_reason' => (int)$change_type, |
|
| 523 | - 'log_dark_matter_amount' => (float)$dark_matter, |
|
| 524 | - 'log_dark_matter_comment' => (string)$comment_unsafe, |
|
| 525 | - 'log_dark_matter_page' => (string)$page_url_unsafe, |
|
| 522 | + 'log_dark_matter_reason' => (int) $change_type, |
|
| 523 | + 'log_dark_matter_amount' => (float) $dark_matter, |
|
| 524 | + 'log_dark_matter_comment' => (string) $comment_unsafe, |
|
| 525 | + 'log_dark_matter_page' => (string) $page_url_unsafe, |
|
| 526 | 526 | 'log_dark_matter_sender' => $user_id, |
| 527 | 527 | ), array()); |
| 528 | 528 | } |
@@ -16,7 +16,6 @@ discard block |
||
| 16 | 16 | * @param $user |
| 17 | 17 | * @param $planet |
| 18 | 18 | * @param array $unit_list |
| 19 | - * @param null $query |
|
| 20 | 19 | */ |
| 21 | 20 | function db_change_resources(&$user, &$planet, $unit_list) { |
| 22 | 21 | $group = sn_get_groups('resources_loot'); |
@@ -56,6 +55,9 @@ discard block |
||
| 56 | 55 | |
| 57 | 56 | } |
| 58 | 57 | |
| 58 | +/** |
|
| 59 | + * @param boolean $transaction_should_be_started |
|
| 60 | + */ |
|
| 59 | 61 | function sn_db_transaction_check($transaction_should_be_started = null) { |
| 60 | 62 | return classSupernova::$gc->db->getTransaction()->check($transaction_should_be_started); |
| 61 | 63 | } |
@@ -24,22 +24,22 @@ |
||
| 24 | 24 | $locationType = sys_get_unit_location($user, $planet, key($unit_list)); |
| 25 | 25 | |
| 26 | 26 | $resourcesChange = array(); |
| 27 | - foreach($unit_list as $unit_id => $unit_amount) { |
|
| 28 | - if(!in_array($unit_id, $group)) { |
|
| 27 | + foreach ($unit_list as $unit_id => $unit_amount) { |
|
| 28 | + if (!in_array($unit_id, $group)) { |
|
| 29 | 29 | // TODO - remove later |
| 30 | 30 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: db_change_resources() вызван для не-ресурсов!</h1>'); |
| 31 | 31 | pdump(debug_backtrace()); |
| 32 | 32 | die('db_change_resources() вызван для не-ресурсов!'); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if(empty($unit_amount)) { |
|
| 35 | + if (empty($unit_amount)) { |
|
| 36 | 36 | continue; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | $resourcesChange[pname_resource_name($unit_id)] += $unit_amount; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - if($locationType == LOC_USER) { |
|
| 42 | + if ($locationType == LOC_USER) { |
|
| 43 | 43 | $locationId = $user['id']; |
| 44 | 44 | } else { |
| 45 | 45 | $locationId = $planet['id']; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
| 3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
| 4 | 4 | classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
| 5 | 5 | } |
| 6 | 6 | |
@@ -8,13 +8,13 @@ discard block |
||
| 8 | 8 | message(classLocale::$lang['Denied_access'], classLocale::$lang['requests_admin']); |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | -if($d = sys_get_param_id('d')) { |
|
| 11 | +if ($d = sys_get_param_id('d')) { |
|
| 12 | 12 | DBStaticAlly::db_ally_request_deny($d); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | $id_user = sys_get_param_id('id_user'); |
| 16 | 16 | |
| 17 | -if($id_user) { |
|
| 17 | +if ($id_user) { |
|
| 18 | 18 | DBStaticUser::db_user_set_by_id( |
| 19 | 19 | $id_user, |
| 20 | 20 | array( |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $user_auth_level = isset($user['authlevel']) ? $user['authlevel'] : AUTH_LEVEL_ANONYMOUS; |
| 37 | 37 | |
| 38 | 38 | $mode = sys_get_param_int('mode'); |
| 39 | - switch($mode) { |
|
| 39 | + switch ($mode) { |
|
| 40 | 40 | case CHAT_MODE_ALLY: |
| 41 | 41 | $template_result['ALLY'] = intval($user['ally_id']); |
| 42 | 42 | $page_title = classLocale::$lang['chat_ally']; |
@@ -49,12 +49,12 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | $template_result['.']['smiles'] = array(); |
| 52 | - foreach(classSupernova::$design['smiles'] as $auth_level => $replaces) { |
|
| 53 | - if($auth_level > $user_auth_level) { |
|
| 52 | + foreach (classSupernova::$design['smiles'] as $auth_level => $replaces) { |
|
| 53 | + if ($auth_level > $user_auth_level) { |
|
| 54 | 54 | continue; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - foreach($replaces as $bbcode => $filename) { |
|
| 57 | + foreach ($replaces as $bbcode => $filename) { |
|
| 58 | 58 | $template_result['.']['smiles'][] = array( |
| 59 | 59 | 'BBCODE' => $bbcode, |
| 60 | 60 | 'FILENAME' => $filename, |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | define('IN_AJAX', true); |
| 78 | 78 | $skip_fleet_update = true; |
| 79 | 79 | |
| 80 | - if( |
|
| 80 | + if ( |
|
| 81 | 81 | classSupernova::$config->getMode() != CACHER_NO_CACHE |
| 82 | 82 | && |
| 83 | 83 | classSupernova::$config->chat_timeout |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | die(); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if(($message = sys_get_param_str('message')) && $user['username']) { |
|
| 90 | + if (($message = sys_get_param_str('message')) && $user['username']) { |
|
| 91 | 91 | $ally_id = sys_get_param('ally') && $user['ally_id'] ? $user['ally_id'] : 0; |
| 92 | 92 | $nickUnsafe = player_nick_compact(player_nick_render_current_to_array($user, array('color' => true, 'icons' => true, 'ally' => !$ally_id))); |
| 93 | 93 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | $skip_fleet_update = true; |
| 110 | 110 | |
| 111 | 111 | $history = sys_get_param_str('history'); |
| 112 | - if(!$history) { |
|
| 112 | + if (!$history) { |
|
| 113 | 113 | classSupernova::$config->array_set('users', $user['id'], 'chat_last_refresh', SN_TIME_MICRO); |
| 114 | 114 | } |
| 115 | 115 | |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $last_message = ''; |
| 118 | 118 | $alliance = 0; |
| 119 | 119 | $template_result['.']['chat'] = array(); |
| 120 | - if( |
|
| 120 | + if ( |
|
| 121 | 121 | !$history |
| 122 | 122 | && |
| 123 | 123 | classSupernova::$config->getMode() != CACHER_NO_CACHE |
@@ -138,11 +138,11 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | $where_add = ''; |
| 140 | 140 | $last_message = 0; |
| 141 | - if($history) { |
|
| 141 | + if ($history) { |
|
| 142 | 142 | $rows = DBStaticChat::db_chat_message_count_by_ally($alliance); |
| 143 | 143 | $page_count = ceil($rows['CNT'] / $page_limit); |
| 144 | 144 | |
| 145 | - for($i = 0; $i < $page_count; $i++) { |
|
| 145 | + for ($i = 0; $i < $page_count; $i++) { |
|
| 146 | 146 | $template_result['.']['page'][] = array( |
| 147 | 147 | 'NUMBER' => $i |
| 148 | 148 | ); |
@@ -156,12 +156,12 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | $start_row = $page * $page_limit; |
| 158 | 158 | $query = DBStaticChat::db_chat_message_get_page($alliance, $where_add, $start_row, $page_limit); |
| 159 | - while($chat_row = db_fetch($query)) { |
|
| 159 | + while ($chat_row = db_fetch($query)) { |
|
| 160 | 160 | // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick |
| 161 | 161 | $chat_row['user'] = player_nick_render_to_html($chat_row['user']); |
| 162 | 162 | $nick_stripped = htmlentities(strip_tags($chat_row['user']), ENT_QUOTES, 'utf-8'); |
| 163 | 163 | $nick = str_replace(strip_tags($chat_row['user']), $nick_stripped, $chat_row['user']); |
| 164 | - if(!$history) { |
|
| 164 | + if (!$history) { |
|
| 165 | 165 | $nick = "<span style=\"cursor: pointer;\" onclick=\"addSmiley('({$nick_stripped})');\">{$nick}</span>"; |
| 166 | 166 | } |
| 167 | 167 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | $template = gettemplate('chat_messages', $template); |
| 187 | 187 | $template->assign_recursive($template_result); |
| 188 | 188 | |
| 189 | - if($history) { |
|
| 189 | + if ($history) { |
|
| 190 | 190 | display($template, "{$classLocale['chat_history']} - {$classLocale[$alliance ? 'chat_ally' : 'chat_common']}", true, '', false, true); |
| 191 | 191 | } else { |
| 192 | 192 | $result['last_message'] = $last_message; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | require_once('general_pname.php'); |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * @param $func_name |
|
| 14 | + * @param string $func_name |
|
| 15 | 15 | * @param array $func_arg |
| 16 | 16 | * |
| 17 | 17 | * @return mixed |
@@ -62,6 +62,9 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // ---------------------------------------------------------------------------------------------------------------- |
| 65 | +/** |
|
| 66 | + * @param string $filename |
|
| 67 | + */ |
|
| 65 | 68 | function sys_file_read($filename) { |
| 66 | 69 | return @file_get_contents($filename); |
| 67 | 70 | } |
@@ -104,7 +107,7 @@ discard block |
||
| 104 | 107 | /** |
| 105 | 108 | * Получение курса обмены валюты в серверную валюту |
| 106 | 109 | * |
| 107 | - * @param $currency_symbol |
|
| 110 | + * @param string $currency_symbol |
|
| 108 | 111 | * |
| 109 | 112 | * @return float |
| 110 | 113 | */ |
@@ -130,7 +133,7 @@ discard block |
||
| 130 | 133 | * - true - colors number to green if positive or zero; red if negative |
| 131 | 134 | * - 0 |
| 132 | 135 | * - numeric - colors number to green if less then $color; red if greater |
| 133 | - * @param int|bool $limit - generally converts "15000" to "15k", "2000000" to "2kk" etc |
|
| 136 | + * @param boolean $limit - generally converts "15000" to "15k", "2000000" to "2kk" etc |
|
| 134 | 137 | * - 0/false - proceed with $floor |
| 135 | 138 | * - numeric - divides number to segments by power of $limit and adds 'k' for each segment |
| 136 | 139 | * - makes sense for 1000, but works with any number |
@@ -229,6 +232,9 @@ discard block |
||
| 229 | 232 | return preg_replace($ListCensure, '*', $String); |
| 230 | 233 | } |
| 231 | 234 | |
| 235 | +/** |
|
| 236 | + * @param string $email |
|
| 237 | + */ |
|
| 232 | 238 | function is_email($email) { |
| 233 | 239 | return (preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $email)); |
| 234 | 240 | } |
@@ -266,6 +272,9 @@ discard block |
||
| 266 | 272 | return floatval(sys_get_param($param_name, $default)); |
| 267 | 273 | } |
| 268 | 274 | |
| 275 | +/** |
|
| 276 | + * @param string $param_name |
|
| 277 | + */ |
|
| 269 | 278 | function sys_get_param_escaped($param_name, $default = '') { |
| 270 | 279 | return db_escape(sys_get_param($param_name, $default)); |
| 271 | 280 | } |
@@ -434,6 +443,9 @@ discard block |
||
| 434 | 443 | } |
| 435 | 444 | |
| 436 | 445 | // Generates random string of $length symbols from $allowed_chars charset |
| 446 | +/** |
|
| 447 | + * @param string $allowed_chars |
|
| 448 | + */ |
|
| 437 | 449 | function sys_random_string($length = 16, $allowed_chars = SN_SYS_SEC_CHARS_ALLOWED) { |
| 438 | 450 | $allowed_length = strlen($allowed_chars); |
| 439 | 451 | |
@@ -538,6 +550,10 @@ discard block |
||
| 538 | 550 | return implode(';', $fleet_string); |
| 539 | 551 | } |
| 540 | 552 | |
| 553 | +/** |
|
| 554 | + * @param string $title |
|
| 555 | + * @param string $body |
|
| 556 | + */ |
|
| 541 | 557 | function mymail($email_unsafe, $title, $body, $from = '', $html = false) { |
| 542 | 558 | $from = trim($from ? $from : classSupernova::$config->game_adminEmail); |
| 543 | 559 | |
@@ -803,6 +819,9 @@ discard block |
||
| 803 | 819 | return serialize($nick_array); |
| 804 | 820 | } |
| 805 | 821 | |
| 822 | +/** |
|
| 823 | + * @param string $nick_string |
|
| 824 | + */ |
|
| 806 | 825 | function player_nick_uncompact($nick_string) { |
| 807 | 826 | try { |
| 808 | 827 | $result = unserialize($nick_string); |
@@ -990,6 +1009,9 @@ discard block |
||
| 990 | 1009 | return $result; |
| 991 | 1010 | } |
| 992 | 1011 | |
| 1012 | +/** |
|
| 1013 | + * @param string $groups |
|
| 1014 | + */ |
|
| 993 | 1015 | function isInGroup($groups, $unitId) { |
| 994 | 1016 | $group = sn_get_groups($groups); |
| 995 | 1017 | |
@@ -1058,6 +1080,9 @@ discard block |
||
| 1058 | 1080 | return $ranks; |
| 1059 | 1081 | } |
| 1060 | 1082 | |
| 1083 | +/** |
|
| 1084 | + * @param boolean $planet_id |
|
| 1085 | + */ |
|
| 1061 | 1086 | function sys_player_new_adjust($user_id, $planet_id) { return sn_function_call(__FUNCTION__, array($user_id, $planet_id, &$result)); } |
| 1062 | 1087 | |
| 1063 | 1088 | function sn_sys_player_new_adjust($user_id, $planet_id, &$result) { |
@@ -1216,6 +1241,9 @@ discard block |
||
| 1216 | 1241 | return $rates; |
| 1217 | 1242 | } |
| 1218 | 1243 | |
| 1244 | +/** |
|
| 1245 | + * @param integer $in_resource |
|
| 1246 | + */ |
|
| 1219 | 1247 | function get_unit_cost_in(&$cost, $in_resource = RES_METAL) { |
| 1220 | 1248 | static $rates; |
| 1221 | 1249 | |
@@ -1382,6 +1410,9 @@ discard block |
||
| 1382 | 1410 | return version_compare(sn_version_compare_extra($ver1), sn_version_compare_extra($ver2)); |
| 1383 | 1411 | } |
| 1384 | 1412 | |
| 1413 | +/** |
|
| 1414 | + * @param string $name |
|
| 1415 | + */ |
|
| 1385 | 1416 | function sn_setcookie($name, $value = null, $expire = null, $path = SN_ROOT_RELATIVE, $domain = null, $secure = null, $httponly = null) { |
| 1386 | 1417 | $_COOKIE[$name] = $value; |
| 1387 | 1418 | |
@@ -685,10 +685,10 @@ discard block |
||
| 685 | 685 | $rexep = "#" . strtr(preg_quote($format), $masks) . "#"; |
| 686 | 686 | if (preg_match($rexep, $date, $out)) { |
| 687 | 687 | $ret = array( |
| 688 | - "tm_sec" => (int)$out['S'], |
|
| 689 | - "tm_min" => (int)$out['M'], |
|
| 690 | - "tm_hour" => (int)$out['H'], |
|
| 691 | - "tm_mday" => (int)$out['d'], |
|
| 688 | + "tm_sec" => (int) $out['S'], |
|
| 689 | + "tm_min" => (int) $out['M'], |
|
| 690 | + "tm_hour" => (int) $out['H'], |
|
| 691 | + "tm_mday" => (int) $out['d'], |
|
| 692 | 692 | "tm_mon" => $out['m'] ? $out['m'] - 1 : 0, |
| 693 | 693 | "tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0, |
| 694 | 694 | ); |
@@ -1339,7 +1339,7 @@ discard block |
||
| 1339 | 1339 | $time_left = min(floor($time_left / PERIOD_DAY), $term_original); |
| 1340 | 1340 | $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0; |
| 1341 | 1341 | |
| 1342 | - array_walk_recursive($result, function (&$value) use ($cost_left) { |
|
| 1342 | + array_walk_recursive($result, function(&$value) use ($cost_left) { |
|
| 1343 | 1343 | $value -= $cost_left; |
| 1344 | 1344 | }); |
| 1345 | 1345 | } |
@@ -1500,7 +1500,7 @@ discard block |
||
| 1500 | 1500 | break; |
| 1501 | 1501 | } |
| 1502 | 1502 | $sort_option_inverse_closure = $sort_option_inverse ? -1 : 1; |
| 1503 | - usort($ListToSort, function ($a, $b) use ($sort_option_field, $sort_option_inverse_closure) { |
|
| 1503 | + usort($ListToSort, function($a, $b) use ($sort_option_field, $sort_option_inverse_closure) { |
|
| 1504 | 1504 | return $a[$sort_option_field] < $b[$sort_option_field] ? -1 * $sort_option_inverse_closure : ( |
| 1505 | 1505 | $a[$sort_option_field] > $b[$sort_option_field] ? 1 * $sort_option_inverse_closure : 0 |
| 1506 | 1506 | ); |
@@ -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; |
@@ -81,6 +81,10 @@ discard block |
||
| 81 | 81 | // ------------------------------------------------------------------------- |
| 82 | 82 | // Here comes low-level functions - those that directly works with cacher engines |
| 83 | 83 | // ------------------------------------------------------------------------- |
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @param string $name |
|
| 87 | + */ |
|
| 84 | 88 | public function __set($name, $value) { |
| 85 | 89 | switch ($name) { |
| 86 | 90 | case '_MODE': |
@@ -132,6 +136,9 @@ discard block |
||
| 132 | 136 | return null; |
| 133 | 137 | } |
| 134 | 138 | |
| 139 | + /** |
|
| 140 | + * @param string $name |
|
| 141 | + */ |
|
| 135 | 142 | public function __isset($name) { |
| 136 | 143 | switch (self::$mode) { |
| 137 | 144 | case CACHER_NO_CACHE: |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | public function unset_by_prefix($prefix_unset = '') { |
| 149 | 149 | static $array_clear; |
| 150 | - !$array_clear ? $array_clear = function (&$v, $k, $p) { |
|
| 150 | + !$array_clear ? $array_clear = function(&$v, $k, $p) { |
|
| 151 | 151 | strpos($k, $p) === 0 ? $v = null : false; |
| 152 | 152 | } : false; |
| 153 | 153 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | if ($this->$name[0] === null) { |
| 203 | 203 | for ($i = count($name) - 1; $i > 0; $i--) { |
| 204 | 204 | $cName = "{$name[$i]}_COUNT"; |
| 205 | - $cName1 = "{$name[$i-1]}_COUNT"; |
|
| 205 | + $cName1 = "{$name[$i - 1]}_COUNT"; |
|
| 206 | 206 | if ($this->$cName1 == null || $i == 1) { |
| 207 | 207 | $this->$cName++; |
| 208 | 208 | } |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | |
| 248 | 248 | for ($i = 1; $i < count($name); $i++) { |
| 249 | 249 | $cName = "{$name[$i]}_COUNT"; |
| 250 | - $cName1 = "{$name[$i-1]}_COUNT"; |
|
| 250 | + $cName1 = "{$name[$i - 1]}_COUNT"; |
|
| 251 | 251 | |
| 252 | 252 | if ($i == 1 || $this->$cName1 === null) { |
| 253 | 253 | $this->$cName--; |