| @@ -4,7 +4,7 @@ discard block | ||
| 4 | 4 | |
| 5 | 5 |  require('../includes/init.' . substr(strrchr(__FILE__, '.'), 1)); | 
| 6 | 6 | |
| 7 | -if($user['authlevel'] < 3) | |
| 7 | +if ($user['authlevel'] < 3) | |
| 8 | 8 |  { | 
| 9 | 9 | SnTemplate::messageBox($lang['sys_noalloaw'], $lang['sys_noaccess']); | 
| 10 | 10 | die(); | 
| @@ -19,9 +19,9 @@ discard block | ||
| 19 | 19 | |
| 20 | 20 | // [#] info_best_battles 1b0 | 
| 21 | 21 | $best_reports = array(); | 
| 22 | -if(defined('MODULE_INFO_BEST_BATTLES_QUERY')) { | |
| 22 | +if (defined('MODULE_INFO_BEST_BATTLES_QUERY')) { | |
| 23 | 23 | $query = doquery(MODULE_INFO_BEST_BATTLES_QUERY); | 
| 24 | -  while($row = db_fetch($query)) { | |
| 24 | +  while ($row = db_fetch($query)) { | |
| 25 | 25 | $best_reports[] = $row['ube_report_id']; | 
| 26 | 26 | } | 
| 27 | 27 | } | 
| @@ -204,16 +204,16 @@ discard block | ||
| 204 | 204 | |
| 205 | 205 |  function sn_maintenance_pack_user_list($user_list) { | 
| 206 | 206 |    $user_list = explode(',', $user_list); | 
| 207 | -  foreach($user_list as $key => $user_id) { | |
| 208 | -    if(!is_numeric($user_id)) { | |
| 207 | +  foreach ($user_list as $key => $user_id) { | |
| 208 | +    if (!is_numeric($user_id)) { | |
| 209 | 209 | unset($user_list[$key]); | 
| 210 | 210 | } | 
| 211 | 211 | } | 
| 212 | 212 | |
| 213 | 213 | $result = array(); | 
| 214 | -  if(!empty($user_list)) { | |
| 214 | +  if (!empty($user_list)) { | |
| 215 | 215 |      $query = doquery("SELECT `id` FROM `{{users}}` WHERE `id` in (" . implode(',', $user_list) . ")"); | 
| 216 | -    while($row = db_fetch($query)) { | |
| 216 | +    while ($row = db_fetch($query)) { | |
| 217 | 217 | $result[] = $row['id']; | 
| 218 | 218 | } | 
| 219 | 219 | } | 
| @@ -228,11 +228,11 @@ discard block | ||
| 228 | 228 | $old_server_status == GAME_DISABLE_NONE ? SN::$config->pass()->game_disable = GAME_DISABLE_MAINTENANCE : false; | 
| 229 | 229 | SN::db_transaction_commit(); | 
| 230 | 230 | |
| 231 | -foreach($ques as $que_transaction) { | |
| 231 | +foreach ($ques as $que_transaction) { | |
| 232 | 232 | SN::db_transaction_start(); | 
| 233 | 233 | |
| 234 | 234 | !is_array($que_transaction) ? $que_transaction = array($que_transaction) : false; | 
| 235 | -  foreach($que_transaction as $que) { | |
| 235 | +  foreach ($que_transaction as $que) { | |
| 236 | 236 | set_time_limit(120); | 
| 237 | 237 | $QryResult = doquery($que); | 
| 238 | 238 | //$msg .= '<hr>' . $que . '<hr>'; | 
| @@ -1,7 +1,7 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -define('INSIDE'  , true); | |
| 4 | -define('INSTALL' , false); | |
| 3 | +define('INSIDE', true); | |
| 4 | +define('INSTALL', false); | |
| 5 | 5 |  define('IN_ADMIN', true); | 
| 6 | 6 | |
| 7 | 7 |  require('../common.' . substr(strrchr(__FILE__, '.'), 1)); | 
| @@ -11,7 +11,7 @@ discard block | ||
| 11 | 11 | SnTemplate::messageBoxAdminAccessDenied(AUTH_LEVEL_ADMINISTRATOR); | 
| 12 | 12 | |
| 13 | 13 |  $planet_active = sys_get_param_int('planet_active'); | 
| 14 | -if(!$planet_active) { | |
| 14 | +if (!$planet_active) { | |
| 15 | 15 |    $planet_type = sys_get_param_int('planet_type', 1); | 
| 16 | 16 | $planet_type = $planet_type == 3 ? 3 : 1; | 
| 17 | 17 |  } else { | 
| @@ -40,8 +40,7 @@ discard block | ||
| 40 | 40 | |
| 41 | 41 | $page_title = | 
| 42 | 42 | $lang['adm_planet_list_title'] . ': ' . | 
| 43 | - ($planet_active ? $lang['adm_planet_active'] : | |
| 44 | - ($planet_type ? ($planet_type == 3 ? $lang['sys_moons'] : $lang['sys_planets']) : '') | |
| 43 | + ($planet_active ? $lang['adm_planet_active'] : ($planet_type ? ($planet_type == 3 ? $lang['sys_moons'] : $lang['sys_planets']) : '') | |
| 45 | 44 | ); | 
| 46 | 45 | $template->assign_vars(array( | 
| 47 | 46 | 'PAGE_TITLE' => $page_title, | 
| @@ -2,7 +2,7 @@ | ||
| 2 | 2 | |
| 3 | 3 |  include_once('common.' . substr(strrchr(__FILE__, '.'), 1)); | 
| 4 | 4 | |
| 5 | -if(SN::$gc->modules->countModulesInGroup('payment') && !SN_GOOGLE) { | |
| 5 | +if (SN::$gc->modules->countModulesInGroup('payment') && !SN_GOOGLE) { | |
| 6 | 6 |    sys_redirect('metamatter.php'); | 
| 7 | 7 | } | 
| 8 | 8 | |
| @@ -35,14 +35,14 @@ discard block | ||
| 35 | 35 |    'planet' => $target_planet = sys_get_param_int('planet'), | 
| 36 | 36 | ); | 
| 37 | 37 | |
| 38 | -if(!uni_coordinates_valid($target_coord)) | |
| 38 | +if (!uni_coordinates_valid($target_coord)) | |
| 39 | 39 |  { | 
| 40 | 40 | die($lang['gs_c02']); | 
| 41 | 41 | } | 
| 42 | 42 | |
| 43 | 43 |  $target_mission = sys_get_param_int('mission'); | 
| 44 | 44 |  $sn_group_missions = sn_get_groups('missions'); | 
| 45 | -if(!isset($sn_group_missions[$target_mission]['AJAX']) || !$sn_group_missions[$target_mission]['AJAX']) | |
| 45 | +if (!isset($sn_group_missions[$target_mission]['AJAX']) || !$sn_group_missions[$target_mission]['AJAX']) | |
| 46 | 46 |  { | 
| 47 | 47 | die($lang['gs_c00']); | 
| 48 | 48 | } | 
| @@ -58,7 +58,7 @@ discard block | ||
| 58 | 58 | $target_coord['planet_type'] = $target_planet_check; | 
| 59 | 59 | $target_row = DBStaticPlanet::db_planet_by_vector($target_coord); | 
| 60 | 60 | |
| 61 | -if(empty($target_row)) | |
| 61 | +if (empty($target_row)) | |
| 62 | 62 |  { | 
| 63 | 63 | $target_row = array( | 
| 64 | 64 | 'galaxy' => $target_coord['galaxy'], | 
| @@ -70,7 +70,7 @@ discard block | ||
| 70 | 70 | } | 
| 71 | 71 | |
| 72 | 72 | $fleet_array = array(); | 
| 73 | -switch($target_mission) | |
| 73 | +switch ($target_mission) | |
| 74 | 74 |  { | 
| 75 | 75 | case MT_SPY: | 
| 76 | 76 | // $fleet_array[SHIP_SPY] = min(mrc_get_level($user, $planetrow, SHIP_SPY), abs($user['spio_anz'])); | 
| @@ -79,9 +79,9 @@ discard block | ||
| 79 | 79 | break; | 
| 80 | 80 | |
| 81 | 81 | case MT_RECYCLE: | 
| 82 | -    foreach(sn_get_groups('flt_recyclers') as $unit_id) | |
| 82 | +    foreach (sn_get_groups('flt_recyclers') as $unit_id) | |
| 83 | 83 |      { | 
| 84 | - if($unit_count = mrc_get_level($user, $planetrow, $unit_id)) | |
| 84 | + if ($unit_count = mrc_get_level($user, $planetrow, $unit_id)) | |
| 85 | 85 |        { | 
| 86 | 86 | $fleet_array[$unit_id] = $unit_count; | 
| 87 | 87 | } | 
| @@ -102,14 +102,14 @@ discard block | ||
| 102 | 102 | $cant_attack = flt_can_attack($planetrow, $target_row, $fleet_array, $target_mission, $options); | 
| 103 | 103 | |
| 104 | 104 | |
| 105 | -if($cant_attack != ATTACK_ALLOWED) | |
| 105 | +if ($cant_attack != ATTACK_ALLOWED) | |
| 106 | 106 |  { | 
| 107 | 107 | die($lang['fl_attack_error'][$cant_attack]); | 
| 108 | 108 | } | 
| 109 | 109 | |
| 110 | -$FleetDBArray = array(); | |
| 110 | +$FleetDBArray = array(); | |
| 111 | 111 | $db_changeset = array(); | 
| 112 | -foreach($fleet_array as $unit_id => $unit_count) | |
| 112 | +foreach ($fleet_array as $unit_id => $unit_count) | |
| 113 | 113 |  { | 
| 114 | 114 |    $FleetDBArray[] = "{$unit_id},{$unit_count}"; | 
| 115 | 115 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, -$unit_count, $user, $planetrow); | 
| @@ -118,7 +118,7 @@ discard block | ||
| 118 | 118 | |
| 119 | 119 | $fleet_ship_count = array_sum($fleet_array); | 
| 120 | 120 | |
| 121 | -if($target_mission == MT_MISSILE) | |
| 121 | +if ($target_mission == MT_MISSILE) | |
| 122 | 122 |  { | 
| 123 | 123 | $distance = abs($target_coord['system'] - $planetrow['system']); | 
| 124 | 124 | $duration = round((30 + (60 * $distance)) / Universe::flt_server_flight_speed_multiplier()); | 
| @@ -136,7 +136,7 @@ discard block | ||
| 136 | 136 |  { | 
| 137 | 137 | $travel_data = flt_travel_data($user, $planetrow, $target_coord, $fleet_array, 10); | 
| 138 | 138 | |
| 139 | - if($planetrow['deuterium'] < $travel_data['consumption']) | |
| 139 | + if ($planetrow['deuterium'] < $travel_data['consumption']) | |
| 140 | 140 |    { | 
| 141 | 141 | die($lang['gs_c13']); | 
| 142 | 142 | } | 
| @@ -174,7 +174,7 @@ discard block | ||
| 174 | 174 | $ships_sent = array(); | 
| 175 | 175 | //$ships_sent_js = array(); | 
| 176 | 176 | $ships_sent_js = 0; | 
| 177 | -foreach($fleet_array as $unit_id => $unit_count) | |
| 177 | +foreach ($fleet_array as $unit_id => $unit_count) | |
| 178 | 178 |  { | 
| 179 | 179 |    $ships_sent[] = "{$unit_count} {$lang['tech'][$unit_id]}"; | 
| 180 | 180 | $ships_sent_js += mrc_get_level($user, $planetrow, $unit_id, false, true); | 
| @@ -183,6 +183,6 @@ discard block | ||
| 183 | 183 |  //$ships_sent_js = implode(',', $ships_sent_js); | 
| 184 | 184 |  $ships_sent_js = "{$unit_group}={$ships_sent_js}"; | 
| 185 | 185 | |
| 186 | -$ResultMessage  = "{$lang['gs_sending']} {$ships_sent} {$lang['gs_to']} {$target_coord['galaxy']}:{$target_coord['system']}:{$target_coord['planet']}|{$ships_sent_js}"; | |
| 186 | +$ResultMessage = "{$lang['gs_sending']} {$ships_sent} {$lang['gs_to']} {$target_coord['galaxy']}:{$target_coord['system']}:{$target_coord['planet']}|{$ships_sent_js}"; | |
| 187 | 187 | |
| 188 | 188 | die($ResultMessage); | 
| @@ -15,8 +15,8 @@ discard block | ||
| 15 | 15 | global $who, $lang; | 
| 16 | 16 | |
| 17 | 17 |    // $sn_group_stat_common = sn_get_groups('STAT_COMMON'); | 
| 18 | -  foreach($array as $key => $value) { | |
| 19 | -    if($array_name == 'type' && $who == 2 && !in_array($key, $sn_group_stat_common)) { | |
| 18 | +  foreach ($array as $key => $value) { | |
| 19 | +    if ($array_name == 'type' && $who == 2 && !in_array($key, $sn_group_stat_common)) { | |
| 20 | 20 | continue; | 
| 21 | 21 | } | 
| 22 | 22 | |
| @@ -48,7 +48,7 @@ discard block | ||
| 48 | 48 | $subject_list = array( | 
| 49 | 49 |    1 => array('header' => $lang['stat_player']), | 
| 50 | 50 | ); | 
| 51 | -if(!$source) { | |
| 51 | +if (!$source) { | |
| 52 | 52 |    $subject_list[2] = array('header' => $lang['stat_allys']); | 
| 53 | 53 | } | 
| 54 | 54 | stat_tpl_assign($template, $who, 'subject', $subject_list, $sn_group_stat_common); | 
| @@ -115,7 +115,7 @@ discard block | ||
| 115 | 115 | |
| 116 | 116 | $page_count = floor($record_count / 100); | 
| 117 | 117 | $pages = array(); | 
| 118 | -for($i = 0; $i <= $page_count; $i++) { | |
| 118 | +for ($i = 0; $i <= $page_count; $i++) { | |
| 119 | 119 | $first_element = $i * 100 + 1; | 
| 120 | 120 | $last_element = $first_element + 99; | 
| 121 | 121 | $pages[$first_element] = array( | 
| @@ -134,7 +134,7 @@ discard block | ||
| 134 | 134 | 'POINTS' => HelperString::numberFloorAndFormat($row['points']), | 
| 135 | 135 | ); | 
| 136 | 136 | |
| 137 | -  if($who == WHO_IS_USER) { | |
| 137 | +  if ($who == WHO_IS_USER) { | |
| 138 | 138 | $row_stat['ALLY_NAME'] = $row['ally_name']; | 
| 139 | 139 | $row_stat['ALLY_ID'] = $row['ally_id']; | 
| 140 | 140 | empty($row['username']) ? $row['username'] = $row['name'] : false; | 
| @@ -18,7 +18,7 @@ discard block | ||
| 18 | 18 | * @return DbMysqliResultIterator|EmptyCountableIterator | 
| 19 | 19 | */ | 
| 20 | 20 |    public static function dbFleetsOnHoldOnPlanetsByIds($planetIds, $time = SN_TIME_NOW) { | 
| 21 | -    if(empty($planetIds) || !is_array($planetIds)) { | |
| 21 | +    if (empty($planetIds) || !is_array($planetIds)) { | |
| 22 | 22 | return new EmptyCountableIterator(); | 
| 23 | 23 | } | 
| 24 | 24 | |
| @@ -41,7 +41,7 @@ discard block | ||
| 41 | 41 | $speeds = array(); | 
| 42 | 42 |      if (!empty($fleet)) { | 
| 43 | 43 |        foreach ($fleet as $ship_id => $amount) { | 
| 44 | -        if ($amount && in_array($ship_id, sn_get_groups(['fleet', 'missile',]))) { | |
| 44 | +        if ($amount && in_array($ship_id, sn_get_groups(['fleet', 'missile', ]))) { | |
| 45 | 45 | $single_ship_data = !empty($shipData[$ship_id]) ? $shipData[$ship_id] : get_ship_data($ship_id, $user); | 
| 46 | 46 | $speeds[] = $single_ship_data['speed']; | 
| 47 | 47 | } | 
| @@ -122,15 +122,15 @@ | ||
| 122 | 122 | SN::db_transaction_commit(); | 
| 123 | 123 | |
| 124 | 124 | $this->user_agent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; | 
| 125 | -    $this->browser_id = db_get_set_unique_id_value('security_browser', 'browser_id', ['browser_user_agent' => $this->user_agent,]); | |
| 125 | +    $this->browser_id = db_get_set_unique_id_value('security_browser', 'browser_id', ['browser_user_agent' => $this->user_agent, ]); | |
| 126 | 126 | |
| 127 | 127 | $this->page_address = substr($_SERVER['PHP_SELF'], strlen(SN_ROOT_RELATIVE)); | 
| 128 | -    $this->page_address_id = db_get_set_unique_id_value('security_url', 'url_id', ['url_string' => $this->page_address,]); | |
| 128 | +    $this->page_address_id = db_get_set_unique_id_value('security_url', 'url_id', ['url_string' => $this->page_address, ]); | |
| 129 | 129 | |
| 130 | 130 | // Not a simulator - because it can have loooooong string | 
| 131 | 131 |      if (strpos($_SERVER['REQUEST_URI'], '/simulator.php') !== 0 && !$skip_log_query) { | 
| 132 | 132 | $this->queryString = !empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''; | 
| 133 | -      $this->queryStringId = db_get_set_unique_id_value('security_query_strings', 'id', ['query_string' => $this->queryString,]); | |
| 133 | +      $this->queryStringId = db_get_set_unique_id_value('security_query_strings', 'id', ['query_string' => $this->queryString, ]); | |
| 134 | 134 | } | 
| 135 | 135 | |
| 136 | 136 | $ip = sec_player_ip(); | 
| @@ -52,7 +52,7 @@ | ||
| 52 | 52 |      //print("<br />CACHE CLEAR {$cache_id} " . ($hard ? 'HARD' : 'SOFT') . "<br />"); | 
| 53 | 53 |      if ($hard && !empty(_SnCacheInternal::$data[$location_type])) { | 
| 54 | 54 | // Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях | 
| 55 | -      array_walk(_SnCacheInternal::$data[$location_type], function (&$item) { $item = null; }); | |
| 55 | +      array_walk(_SnCacheInternal::$data[$location_type], function(&$item) { $item = null; }); | |
| 56 | 56 | } | 
| 57 | 57 | _SnCacheInternal::$locator[$location_type] = []; | 
| 58 | 58 | _SnCacheInternal::cache_repack($location_type); // Перепаковываем внутренние структуры, если нужно | 
| @@ -192,18 +192,18 @@ discard block | ||
| 192 | 192 | // TODO Хотя тут может получится вечный цикл - ПОДУМАТЬ | 
| 193 | 193 | // TODO Тут же можно пробовать провести попытку слияния аккаунтов - хотя это и очень небезопасно | 
| 194 | 194 | |
| 195 | -    if(sys_get_param('login_player_register_logout')) { | |
| 195 | +    if (sys_get_param('login_player_register_logout')) { | |
| 196 | 196 | $this->logout(); | 
| 197 | 197 | } | 
| 198 | 198 | |
| 199 | 199 | $original_suggest = ''; | 
| 200 | 200 | // Смотрим - есть ли у нас данные от пользователя | 
| 201 | -    if(($player_name_submitted = sys_get_param('submit_player_name'))) { | |
| 201 | +    if (($player_name_submitted = sys_get_param('submit_player_name'))) { | |
| 202 | 202 | // Попытка регистрации нового игрока из данных, введенных пользователем | 
| 203 | 203 |        $this->player_suggested_name = sys_get_param_str_unsafe('player_suggested_name'); | 
| 204 | 204 |      } else { | 
| 205 | -      foreach($this->providers_authorised as $provider) { | |
| 206 | -        if($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5 | |
| 205 | +      foreach ($this->providers_authorised as $provider) { | |
| 206 | +        if ($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5 | |
| 207 | 207 | $original_suggest = $provider->player_name_suggest(); | 
| 208 | 208 | break; | 
| 209 | 209 | } | 
| @@ -211,7 +211,7 @@ discard block | ||
| 211 | 211 | } | 
| 212 | 212 | |
| 213 | 213 | // Если у нас провайдеры не дают имени и пользователь не дал свой вариант - это у нас первый логин в игру | 
| 214 | -    if(!$this->player_suggested_name) { | |
| 214 | +    if (!$this->player_suggested_name) { | |
| 215 | 215 | $max_user_id = db_player_get_max_id(); // 4.5 | 
| 216 | 216 | // TODO - предлагать имя игрока по локали | 
| 217 | 217 | |
| @@ -220,15 +220,15 @@ discard block | ||
| 220 | 220 | SN::db_transaction_rollback(); | 
| 221 | 221 | $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000); | 
| 222 | 222 | SN::db_transaction_start(); | 
| 223 | - } while(db_player_name_exists($this->player_suggested_name)); | |
| 223 | + } while (db_player_name_exists($this->player_suggested_name)); | |
| 224 | 224 | |
| 225 | 225 | } | 
| 226 | 226 | |
| 227 | -    if($player_name_submitted) { | |
| 227 | +    if ($player_name_submitted) { | |
| 228 | 228 | $this->register_player_db_create($this->player_suggested_name); // OK 4.5 | 
| 229 | -      if($this->register_status == LOGIN_SUCCESS) { | |
| 229 | +      if ($this->register_status == LOGIN_SUCCESS) { | |
| 230 | 230 | sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); | 
| 231 | -      } elseif($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { | |
| 231 | +      } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { | |
| 232 | 232 | // self::$player_suggested_name .= ' ' . $this->account->account_id; | 
| 233 | 233 | } | 
| 234 | 234 |  //      if(self::$login_status != LOGIN_SUCCESS) { | 
| @@ -252,7 +252,7 @@ discard block | ||
| 252 | 252 | : false | 
| 253 | 253 | ); | 
| 254 | 254 | |
| 255 | -    if($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { | |
| 255 | +    if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { | |
| 256 | 256 |        $prohibited_characters = array_map(function($value) { | 
| 257 | 257 | return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; | 
| 258 | 258 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); | 
| @@ -285,18 +285,18 @@ discard block | ||
| 285 | 285 | |
| 286 | 286 | // !self::$is_init ? self::init() : false; | 
| 287 | 287 | |
| 288 | -    if(!SN::$gc->modules->countModulesInGroup('auth')) { | |
| 288 | +    if (!SN::$gc->modules->countModulesInGroup('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::$gc->modules->getModulesInGroup('auth', true) as $module_name => $module) { | |
| 299 | +    foreach (SN::$gc->modules->getModulesInGroup('auth', true) as $module_name => $module) { | |
| 300 | 300 | /** | 
| 301 | 301 | * @var auth_abstract $module | 
| 302 | 302 | */ | 
| @@ -305,10 +305,10 @@ discard block | ||
| 305 | 305 | |
| 306 | 306 | // $this->providers = array_reverse($this->providers, true); // НИНАДА! СН-аккаунт должен всегда авторизироваться первым! | 
| 307 | 307 | //pdump($this->providers); | 
| 308 | -    foreach($this->providers as $provider_id => $provider) { | |
| 308 | +    foreach ($this->providers as $provider_id => $provider) { | |
| 309 | 309 | $login_status = $provider->login(); // OK v4.5 | 
| 310 | 310 | self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? $lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); | 
| 311 | -      if($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { | |
| 311 | +      if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { | |
| 312 | 312 | $this->providers_authorised[$provider_id] = &$this->providers[$provider_id]; | 
| 313 | 313 | |
| 314 | 314 | $this->user_id_to_provider = array_replace_recursive( | 
| @@ -316,20 +316,20 @@ discard block | ||
| 316 | 316 | // static::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5 | 
| 317 | 317 | PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5 | 
| 318 | 318 | ); | 
| 319 | -      } elseif($login_status != LOGIN_UNDEFINED) { | |
| 319 | +      } elseif ($login_status != LOGIN_UNDEFINED) { | |
| 320 | 320 | $this->provider_error_list[$provider_id] = $login_status; | 
| 321 | 321 | } | 
| 322 | 322 | } | 
| 323 | 323 | |
| 324 | -    if(empty($this->providers_authorised)) { | |
| 324 | +    if (empty($this->providers_authorised)) { | |
| 325 | 325 | // Ни один аккаунт не авторизирован | 
| 326 | 326 | // Проверяем - есть ли у нас ошибки в аккаунтах? | 
| 327 | -      if(!empty($this->provider_error_list)) { | |
| 327 | +      if (!empty($this->provider_error_list)) { | |
| 328 | 328 | // Если есть - выводим их | 
| 329 | 329 | self::$login_status = reset($this->provider_error_list); | 
| 330 | 330 | $providerError = $this->providers[key($this->provider_error_list)]->account_login_message; | 
| 331 | 331 | |
| 332 | -        if(!empty($providerError)) { | |
| 332 | +        if (!empty($providerError)) { | |
| 333 | 333 | self::$login_message = $providerError; | 
| 334 | 334 | } | 
| 335 | 335 | } | 
| @@ -344,12 +344,12 @@ discard block | ||
| 344 | 344 | // В self::$accessible_user_row_list - список доступных игроков для данных аккаунтов с соответствующими записями из таблицы `users` | 
| 345 | 345 | |
| 346 | 346 | // Остались ли у нас в списке доступные игроки? | 
| 347 | -      if(empty($this->accessible_user_row_list)) { | |
| 347 | +      if (empty($this->accessible_user_row_list)) { | |
| 348 | 348 | // Нет ни одного игрока ни на одном авторизированном аккаунте | 
| 349 | 349 | // Надо регать нового игрока | 
| 350 | 350 | |
| 351 | 351 | // Сейчас происходит процесс регистрации игрока? | 
| 352 | -        if(!$this->is_player_register) { | |
| 352 | +        if (!$this->is_player_register) { | |
| 353 | 353 | // Нет - отправляем на процесс регистрации | 
| 354 | 354 |            $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id')); | 
| 355 | 355 | sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : '')); | 
| @@ -358,7 +358,7 @@ discard block | ||
| 358 | 358 | // Да, есть доступные игроки, которые так же прописаны в базе | 
| 359 | 359 | $this->get_active_user(); // 4.5 | 
| 360 | 360 | |
| 361 | -        if($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) { | |
| 361 | +        if ($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) { | |
| 362 | 362 | $a_user = db_user_by_id($this->is_impersonating); | 
| 363 | 363 | $this->impersonator_username = $a_user['username']; | 
| 364 | 364 | } | 
| @@ -366,9 +366,9 @@ discard block | ||
| 366 | 366 | |
| 367 | 367 | //Прописываем текущего игрока на все авторизированные аккаунты | 
| 368 | 368 | // TODO - ИЛИ ВСЕХ ИГРОКОВ?? | 
| 369 | -        if(empty($this->is_impersonating)) { | |
| 370 | -          foreach($this->providers_authorised as $provider_id => $provider) { | |
| 371 | -            if(empty($this->user_id_to_provider[self::$user['id']][$provider_id])) { | |
| 369 | +        if (empty($this->is_impersonating)) { | |
| 370 | +          foreach ($this->providers_authorised as $provider_id => $provider) { | |
| 371 | +            if (empty($this->user_id_to_provider[self::$user['id']][$provider_id])) { | |
| 372 | 372 | // self::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']); | 
| 373 | 373 | PlayerToAccountTranslate::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']); | 
| 374 | 374 | $this->user_id_to_provider[self::$user['id']][$provider_id][$provider->account->account_id] = true; | 
| @@ -378,9 +378,9 @@ discard block | ||
| 378 | 378 | } | 
| 379 | 379 | } | 
| 380 | 380 | |
| 381 | -    if(empty(self::$user['id'])) { | |
| 381 | +    if (empty(self::$user['id'])) { | |
| 382 | 382 |        self::cookie_set(''); // OK 4.5 | 
| 383 | -    } elseif(self::$user['id'] != $_COOKIE[SN_COOKIE_U]) { | |
| 383 | +    } elseif (self::$user['id'] != $_COOKIE[SN_COOKIE_U]) { | |
| 384 | 384 | self::cookie_set(self::$user['id']); // OK 4.5 | 
| 385 | 385 | } | 
| 386 | 386 | |
| @@ -399,21 +399,21 @@ discard block | ||
| 399 | 399 | */ | 
| 400 | 400 | // OK v4.7 | 
| 401 | 401 |    public function logout($redirect = true) { | 
| 402 | -    if(!empty($_COOKIE[SN_COOKIE_U_I])) { | |
| 402 | +    if (!empty($_COOKIE[SN_COOKIE_U_I])) { | |
| 403 | 403 | self::cookie_set($_COOKIE[SN_COOKIE_U_I]); | 
| 404 | 404 | self::cookie_set(0, true); | 
| 405 | 405 | self::$main_provider->logout(); | 
| 406 | 406 |      } else { | 
| 407 | -      foreach($this->providers as $provider_name => $provider) { | |
| 407 | +      foreach ($this->providers as $provider_name => $provider) { | |
| 408 | 408 | $provider->logout(); | 
| 409 | 409 | } | 
| 410 | 410 | |
| 411 | 411 | self::cookie_set(0); | 
| 412 | 412 | } | 
| 413 | 413 | |
| 414 | -    if($redirect === true) { | |
| 414 | +    if ($redirect === true) { | |
| 415 | 415 | sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); | 
| 416 | -    } elseif($redirect !== false) { | |
| 416 | +    } elseif ($redirect !== false) { | |
| 417 | 417 | sys_redirect($redirect); | 
| 418 | 418 | } | 
| 419 | 419 | } | 
| @@ -424,15 +424,15 @@ discard block | ||
| 424 | 424 | * @param $user_selected | 
| 425 | 425 | */ | 
| 426 | 426 |    public function impersonate($user_selected) { | 
| 427 | -    if($_COOKIE[SN_COOKIE_U_I]) { | |
| 427 | +    if ($_COOKIE[SN_COOKIE_U_I]) { | |
| 428 | 428 |        die('You already impersonating someone. Go back to living other\'s life! Or clear your cookies and try again'); // TODO: Log it | 
| 429 | 429 | } | 
| 430 | 430 | |
| 431 | -    if($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) { | |
| 431 | +    if ($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) { | |
| 432 | 432 |        die('You can\'t impersonate - too low level'); // TODO: Log it | 
| 433 | 433 | } | 
| 434 | 434 | |
| 435 | -    if($this->auth_level_max_local <= $user_selected['authlevel']) { | |
| 435 | +    if ($this->auth_level_max_local <= $user_selected['authlevel']) { | |
| 436 | 436 |        die('You can\'t impersonate this account - level is greater or equal to yours'); // TODO: Log it | 
| 437 | 437 | } | 
| 438 | 438 | |
| @@ -440,7 +440,7 @@ discard block | ||
| 440 | 440 | $account_translate = reset($account_translate[$user_selected['id']][self::$main_provider->provider_id]); | 
| 441 | 441 | $account_to_impersonate = new Account(self::$main_provider->db); | 
| 442 | 442 | $account_to_impersonate->db_get_by_id($account_translate['provider_account_id']); | 
| 443 | -    if(!$account_to_impersonate->is_exists) { | |
| 443 | +    if (!$account_to_impersonate->is_exists) { | |
| 444 | 444 |        die('Какая-то ошибка - не могу найти аккаунт для имперсонации'); // TODO: Log it | 
| 445 | 445 | } | 
| 446 | 446 | self::$main_provider->impersonate($account_to_impersonate); | 
| @@ -466,12 +466,12 @@ discard block | ||
| 466 | 466 |    public function password_check($password_unsafe) { | 
| 467 | 467 | $result = false; | 
| 468 | 468 | |
| 469 | -    if(empty($this->providers_authorised)) { | |
| 469 | +    if (empty($this->providers_authorised)) { | |
| 470 | 470 | // TODO - такого быть не может! | 
| 471 | 471 |        self::flog("password_check: Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true); | 
| 472 | 472 |      } else { | 
| 473 | -      foreach($this->providers_authorised as $provider_id => $provider) { | |
| 474 | -        if($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) { | |
| 473 | +      foreach ($this->providers_authorised as $provider_id => $provider) { | |
| 474 | +        if ($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) { | |
| 475 | 475 | $result = $result || $provider->password_check($password_unsafe); | 
| 476 | 476 | } | 
| 477 | 477 | } | 
| @@ -492,7 +492,7 @@ discard block | ||
| 492 | 492 |    public function password_change($old_password_unsafe, $new_password_unsafe) { | 
| 493 | 493 | global $lang; | 
| 494 | 494 | |
| 495 | -    if(empty($this->providers_authorised)) { | |
| 495 | +    if (empty($this->providers_authorised)) { | |
| 496 | 496 | // TODO - такого быть не может! | 
| 497 | 497 |        self::flog("Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true); | 
| 498 | 498 | return false; | 
| @@ -505,8 +505,8 @@ discard block | ||
| 505 | 505 | $salt_unsafe = self::password_salt_generate(); | 
| 506 | 506 | |
| 507 | 507 | $providers_changed_password = array(); | 
| 508 | -    foreach($this->providers_authorised as $provider_id => $provider) { | |
| 509 | - if( | |
| 508 | +    foreach ($this->providers_authorised as $provider_id => $provider) { | |
| 509 | + if ( | |
| 510 | 510 | !$provider->is_feature_supported(AUTH_FEATURE_PASSWORD_CHANGE) | 
| 511 | 511 | || !$provider->password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe) | 
| 512 | 512 |        ) { | 
| @@ -518,7 +518,7 @@ discard block | ||
| 518 | 518 | $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id); | 
| 519 | 519 | |
| 520 | 520 | // Рассылаем уведомления о смене пароля в ЛС | 
| 521 | -      foreach($account_translation as $user_id => $provider_info) { | |
| 521 | +      foreach ($account_translation as $user_id => $provider_info) { | |
| 522 | 522 | // TODO - УКазывать тип аккаунта, на котором сменён пароль | 
| 523 | 523 | msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN, | 
| 524 | 524 | $lang['sys_administration'], $lang['sys_login_register_message_title'], | 
| @@ -565,7 +565,7 @@ discard block | ||
| 565 | 565 | SN::db_transaction_start(); | 
| 566 | 566 | // Проверить наличие такого имени в истории имён | 
| 567 | 567 | |
| 568 | -      if(db_player_name_exists($player_name_unsafe)) { | |
| 568 | +      if (db_player_name_exists($player_name_unsafe)) { | |
| 569 | 569 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_EXISTS, ERR_ERROR); | 
| 570 | 570 | } | 
| 571 | 571 | |
| @@ -573,11 +573,11 @@ discard block | ||
| 573 | 573 | $player_language = ''; | 
| 574 | 574 | $player_email = ''; | 
| 575 | 575 | // TODO - порнография - работа должна происходить над списком аккаунтов, а не только на одном аккаунте... | 
| 576 | -      foreach($this->providers_authorised as $provider) { | |
| 577 | -        if(!$player_language && $provider->account->account_language) { | |
| 576 | +      foreach ($this->providers_authorised as $provider) { | |
| 577 | +        if (!$player_language && $provider->account->account_language) { | |
| 578 | 578 | $player_language = $provider->account->account_language; | 
| 579 | 579 | } | 
| 580 | -        if(!$player_email && $provider->account->account_email) { | |
| 580 | +        if (!$player_email && $provider->account->account_email) { | |
| 581 | 581 | $player_email = $provider->account->account_email; | 
| 582 | 582 | } | 
| 583 | 583 | } | 
| @@ -593,7 +593,7 @@ discard block | ||
| 593 | 593 | )); | 
| 594 | 594 | // Зарегестрировать на него аккаунты из self::$accounts_authorised | 
| 595 | 595 | $a_user = self::$user; | 
| 596 | -      foreach($this->providers_authorised as $provider) { | |
| 596 | +      foreach ($this->providers_authorised as $provider) { | |
| 597 | 597 | // TODO - порнография. Должен быть отдельный класс трансляторов - в т.ч. и кэширующий транслятор | 
| 598 | 598 | // TODO - ну и работа должна происходить над списком аккаунтов, а не только на одном аккаунте... | 
| 599 | 599 | // self::db_translate_register_user($provider->provider_id, $provider->account->account_id, $a_user['id']); | 
| @@ -605,7 +605,7 @@ discard block | ||
| 605 | 605 | |
| 606 | 606 | SN::db_transaction_commit(); | 
| 607 | 607 | $this->register_status = LOGIN_SUCCESS; | 
| 608 | -    } catch(Exception $e) { | |
| 608 | +    } catch (Exception $e) { | |
| 609 | 609 | SN::db_transaction_rollback(); | 
| 610 | 610 | |
| 611 | 611 | // Если старое имя занято | 
| @@ -624,10 +624,10 @@ discard block | ||
| 624 | 624 | // Пробиваем все ИД игроков по базе - есть ли вообще такие записи | 
| 625 | 625 | // Вообще-то это не особо нужно - у нас по определению стоят констраинты | 
| 626 | 626 | // Зато так мы узнаем максимальный authlevel, проверим права имперсонейта и вытащим все записи юзеров | 
| 627 | -    foreach($this->user_id_to_provider as $user_id => $cork) { | |
| 627 | +    foreach ($this->user_id_to_provider as $user_id => $cork) { | |
| 628 | 628 | $user = db_user_by_id($user_id); | 
| 629 | 629 | // Если записи игрока в БД не существует? | 
| 630 | -      if(empty($user['id'])) { | |
| 630 | +      if (empty($user['id'])) { | |
| 631 | 631 | // Удаляем этого и переходим к следующему | 
| 632 | 632 | unset($this->user_id_to_provider[$user_id]); | 
| 633 | 633 | // Де-регистрируем игрока из таблицы трансляции игроков | 
| @@ -648,7 +648,7 @@ discard block | ||
| 648 | 648 | // OK v4.5 | 
| 649 | 649 |    protected function get_active_user() { | 
| 650 | 650 | // Проверяем куку "текущего игрока" из браузера | 
| 651 | - if( | |
| 651 | + if ( | |
| 652 | 652 | // Кука не пустая | 
| 653 | 653 | ($_COOKIE[SN_COOKIE_U] = trim($_COOKIE[SN_COOKIE_U])) && !empty($_COOKIE[SN_COOKIE_U]) | 
| 654 | 654 | // И в куке находится ID | 
| @@ -673,7 +673,7 @@ discard block | ||
| 673 | 673 | } | 
| 674 | 674 | |
| 675 | 675 | // В куке нет валидного ИД записи игрока, доступной с текущих аккаунтов | 
| 676 | -    if(empty(self::$user['id'])) { | |
| 676 | +    if (empty(self::$user['id'])) { | |
| 677 | 677 | // Берем первого из доступных | 
| 678 | 678 | // TODO - default_user | 
| 679 | 679 | self::$user = reset($this->accessible_user_row_list); | 
| @@ -697,7 +697,7 @@ discard block | ||
| 697 | 697 | |
| 698 | 698 | $result = array(); | 
| 699 | 699 | |
| 700 | -    if($user_id && empty($this->is_impersonating)) { | |
| 700 | +    if ($user_id && empty($this->is_impersonating)) { | |
| 701 | 701 | // self::db_counter_insert(); | 
| 702 | 702 | self::$device->db_counter_insert($user_id); | 
| 703 | 703 | |
| @@ -705,12 +705,12 @@ discard block | ||
| 705 | 705 | |
| 706 | 706 | sys_user_options_unpack($user); | 
| 707 | 707 | |
| 708 | -      if($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) { | |
| 708 | +      if ($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) { | |
| 709 | 709 | $user['banaday'] = 0; | 
| 710 | 710 | $user['vacation'] = SN_TIME_NOW; | 
| 711 | 711 | } | 
| 712 | 712 | |
| 713 | - $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip']; | |
| 713 | + $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip']; | |
| 714 | 714 | $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain']; | 
| 715 | 715 | |
| 716 | 716 | $result[F_BANNED_STATUS] = $user['banaday']; | 
| @@ -724,13 +724,13 @@ discard block | ||
| 724 | 724 | ); | 
| 725 | 725 | } | 
| 726 | 726 | |
| 727 | -    if($extra = $config->security_ban_extra) { | |
| 727 | +    if ($extra = $config->security_ban_extra) { | |
| 728 | 728 |        $extra = explode(',', $extra); | 
| 729 | - array_walk($extra,'trim'); | |
| 729 | + array_walk($extra, 'trim'); | |
| 730 | 730 | in_array(self::$device->device_id, $extra) and die(); | 
| 731 | 731 | } | 
| 732 | 732 | |
| 733 | -    if(self::$login_message) { | |
| 733 | +    if (self::$login_message) { | |
| 734 | 734 | $result[F_LOGIN_MESSAGE] = self::$login_message; | 
| 735 | 735 | } | 
| 736 | 736 | |
| @@ -766,21 +766,21 @@ discard block | ||
| 766 | 766 |    protected function register_player_name_validate($player_name_unsafe) { | 
| 767 | 767 | // TODO - переделать под RAW-строки | 
| 768 | 768 | // Если имя игрока пустое - NO GO! | 
| 769 | -    if(trim($player_name_unsafe) == '') { | |
| 769 | +    if (trim($player_name_unsafe) == '') { | |
| 770 | 770 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_EMPTY, ERR_ERROR); | 
| 771 | 771 | } | 
| 772 | 772 | // Проверяем, что бы в начале и конце не было пустых символов | 
| 773 | -    if($player_name_unsafe != trim($player_name_unsafe)) { | |
| 773 | +    if ($player_name_unsafe != trim($player_name_unsafe)) { | |
| 774 | 774 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_TRIMMED, ERR_ERROR); | 
| 775 | 775 | } | 
| 776 | 776 | // Если логин имеет запрещенные символы - NO GO! | 
| 777 | -    if(strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { | |
| 777 | +    if (strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { | |
| 778 | 778 | // TODO - выдавать в сообщение об ошибке список запрещенных символов | 
| 779 | 779 | // TODO - заранее извещать игрока, какие символы являются запрещенными | 
| 780 | 780 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_RESTRICTED_CHARACTERS, ERR_ERROR); | 
| 781 | 781 | } | 
| 782 | 782 | // Если логин меньше минимальной длины - NO GO! | 
| 783 | -    if(strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) { | |
| 783 | +    if (strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) { | |
| 784 | 784 | // TODO - выдавать в сообщение об ошибке минимальную длину имени игрока | 
| 785 | 785 | // TODO - заранее извещать игрока, какая минимальная и максимальная длина имени | 
| 786 | 786 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_SHORT, ERR_ERROR); | 
| @@ -838,7 +838,7 @@ discard block | ||
| 838 | 838 | } | 
| 839 | 839 | |
| 840 | 840 |    protected static function flog($message, $die = false) { | 
| 841 | -    if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { | |
| 841 | +    if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) { | |
| 842 | 842 | return; | 
| 843 | 843 | } | 
| 844 | 844 | list($called, $caller) = debug_backtrace(false); | 
| @@ -851,7 +851,7 @@ discard block | ||
| 851 | 851 |      $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; | 
| 852 | 852 | |
| 853 | 853 |      SN::log_file("$message - $caller_name"); | 
| 854 | -    if($die) { | |
| 854 | +    if ($die) { | |
| 855 | 855 |        $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); | 
| 856 | 856 | } | 
| 857 | 857 | } |