| @@ -48,106 +48,106 @@ discard block | ||
| 48 | 48 | } | 
| 49 | 49 | |
| 50 | 50 |  switch($mode) { | 
| 51 | - case 'write': | |
| 52 | - $error_list = array(); | |
| 53 | -    $template = gettemplate('msg_message_compose', true); | |
| 51 | + case 'write': | |
| 52 | + $error_list = array(); | |
| 53 | +      $template = gettemplate('msg_message_compose', true); | |
| 54 | 54 | |
| 55 | -    $recipient_name = sys_get_param_str_unsafe('recipient_name'); | |
| 56 | -    if($recipient_name) { | |
| 57 | - $recipient_row = DBStaticUser::db_user_by_username($recipient_name); | |
| 58 | - } | |
| 55 | +      $recipient_name = sys_get_param_str_unsafe('recipient_name'); | |
| 56 | +      if($recipient_name) { | |
| 57 | + $recipient_row = DBStaticUser::db_user_by_username($recipient_name); | |
| 58 | + } | |
| 59 | 59 | |
| 60 | -    if(!$recipient_row) { | |
| 61 | -      $recipient_id = sys_get_param_id('id'); | |
| 62 | - $recipient_row = DBStaticUser::db_user_by_id($recipient_id); | |
| 63 | 60 |        if(!$recipient_row) { | 
| 64 | - $recipient_id = 0; | |
| 61 | +        $recipient_id = sys_get_param_id('id'); | |
| 62 | + $recipient_row = DBStaticUser::db_user_by_id($recipient_id); | |
| 63 | +        if(!$recipient_row) { | |
| 64 | + $recipient_id = 0; | |
| 65 | + } | |
| 65 | 66 | } | 
| 66 | - } | |
| 67 | - | |
| 68 | -    if($recipient_row) { | |
| 69 | - $recipient_id = $recipient_row['id']; | |
| 70 | - $recipient_name = $recipient_row['username']; | |
| 71 | - } | |
| 72 | - | |
| 73 | -    if($recipient_id == $user['id']) { | |
| 74 | -      $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_self_send'], 'STATUS' => ERR_ERROR); | |
| 75 | - } | |
| 76 | - | |
| 77 | - $re = 0; | |
| 78 | -    $subject = sys_get_param_str('subject'); | |
| 79 | -    while(strpos($subject, classLocale::$lang['msg_answer_prefix']) !== false) { | |
| 80 | - $subject = substr($subject, strlen(classLocale::$lang['msg_answer_prefix'])); | |
| 81 | - $re++; | |
| 82 | - } | |
| 83 | - $re ? $subject = classLocale::$lang['msg_answer_prefix'] . $subject : false; | |
| 84 | 67 | |
| 85 | -    if(sys_get_param_str('msg_send')) { | |
| 86 | - $subject = $subject ? $subject : classLocale::$lang['msg_subject_default']; | |
| 68 | +      if($recipient_row) { | |
| 69 | + $recipient_id = $recipient_row['id']; | |
| 70 | + $recipient_name = $recipient_row['username']; | |
| 71 | + } | |
| 87 | 72 | |
| 88 | -      if(!$recipient_id) { | |
| 89 | -        $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_player_not_found'], 'STATUS' => ERR_ERROR); | |
| 73 | +      if($recipient_id == $user['id']) { | |
| 74 | +        $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_self_send'], 'STATUS' => ERR_ERROR); | |
| 90 | 75 | } | 
| 91 | 76 | |
| 92 | -      $text = sys_get_param_str('text'); | |
| 93 | -      if(!$text) { | |
| 94 | -        $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_no_text'], 'STATUS' => ERR_ERROR); | |
| 77 | + $re = 0; | |
| 78 | +      $subject = sys_get_param_str('subject'); | |
| 79 | +      while(strpos($subject, classLocale::$lang['msg_answer_prefix']) !== false) { | |
| 80 | + $subject = substr($subject, strlen(classLocale::$lang['msg_answer_prefix'])); | |
| 81 | + $re++; | |
| 95 | 82 | } | 
| 83 | + $re ? $subject = classLocale::$lang['msg_answer_prefix'] . $subject : false; | |
| 96 | 84 | |
| 97 | -      if(empty($error_list)) { | |
| 98 | -        $error_list[] = array('MESSAGE' => classLocale::$lang['msg_not_message_sent'], 'STATUS' => ERR_NONE); | |
| 85 | +      if(sys_get_param_str('msg_send')) { | |
| 86 | + $subject = $subject ? $subject : classLocale::$lang['msg_subject_default']; | |
| 99 | 87 | |
| 100 | - $user_safe_name = db_escape($user['username']); | |
| 101 | - $recipient_name = db_escape($recipient_name); | |
| 102 | -        msg_send_simple_message($recipient_id, $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, "{$user_safe_name} [{$user['galaxy']}:{$user['system']}:{$user['planet']}]", $subject, $text, true); | |
| 88 | +        if(!$recipient_id) { | |
| 89 | +          $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_player_not_found'], 'STATUS' => ERR_ERROR); | |
| 90 | + } | |
| 103 | 91 | |
| 104 | - //$recipient_id = 0; | |
| 105 | - //$recipient_name = ''; | |
| 106 | - //$subject = ''; | |
| 107 | - $text = ''; | |
| 92 | +        $text = sys_get_param_str('text'); | |
| 93 | +        if(!$text) { | |
| 94 | +          $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_no_text'], 'STATUS' => ERR_ERROR); | |
| 95 | + } | |
| 108 | 96 | |
| 109 | - $msg_sent = true; | |
| 110 | -      } else { | |
| 111 | -        $subject = sys_get_param_str_unsafe('subject'); | |
| 112 | -        $text = sys_get_param_str_unsafe('text'); | |
| 113 | - } | |
| 114 | -      $recipient_name = sys_get_param_str_unsafe('recipient_name'); | |
| 115 | - } | |
| 97 | +        if(empty($error_list)) { | |
| 98 | +          $error_list[] = array('MESSAGE' => classLocale::$lang['msg_not_message_sent'], 'STATUS' => ERR_NONE); | |
| 116 | 99 | |
| 117 | - $subject = $subject ? $subject : classLocale::$lang['msg_subject_default']; | |
| 100 | + $user_safe_name = db_escape($user['username']); | |
| 101 | + $recipient_name = db_escape($recipient_name); | |
| 102 | +          msg_send_simple_message($recipient_id, $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, "{$user_safe_name} [{$user['galaxy']}:{$user['system']}:{$user['planet']}]", $subject, $text, true); | |
| 118 | 103 | |
| 119 | - $template->assign_vars(array( | |
| 120 | - 'RECIPIENT_ID' => $recipient_id, | |
| 121 | - 'RECIPIENT_NAME' => htmlspecialchars($recipient_name), | |
| 122 | - 'SUBJECT' => htmlspecialchars($subject), | |
| 123 | - 'TEXT' => htmlspecialchars($text), | |
| 124 | - )); | |
| 104 | + //$recipient_id = 0; | |
| 105 | + //$recipient_name = ''; | |
| 106 | + //$subject = ''; | |
| 107 | + $text = ''; | |
| 125 | 108 | |
| 126 | -    foreach($error_list as $error_message) { | |
| 127 | -      $template->assign_block_vars('result', $error_message); | |
| 128 | - } | |
| 109 | + $msg_sent = true; | |
| 110 | +        } else { | |
| 111 | +          $subject = sys_get_param_str_unsafe('subject'); | |
| 112 | +          $text = sys_get_param_str_unsafe('text'); | |
| 113 | + } | |
| 114 | +        $recipient_name = sys_get_param_str_unsafe('recipient_name'); | |
| 115 | + } | |
| 129 | 116 | |
| 130 | - $message_query = db_message_list_get_last_20($user, $recipient_id); | |
| 131 | -    while($message_row = db_fetch($message_query)) { | |
| 132 | -      $template->assign_block_vars('messages', array( | |
| 133 | - 'ID' => $message_row['message_id'], | |
| 134 | - 'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF), | |
| 135 | - 'FROM' => htmlspecialchars($message_row['message_from']), | |
| 136 | - 'SUBJ' => htmlspecialchars($message_row['message_subject']), | |
| 137 | - 'TEXT' => in_array($message_row['message_type'], array(MSG_TYPE_PLAYER, MSG_TYPE_ALLIANCE)) && $message_row['message_sender'] ? nl2br(htmlspecialchars($message_row['message_text'])) : nl2br($message_row['message_text']), | |
| 117 | + $subject = $subject ? $subject : classLocale::$lang['msg_subject_default']; | |
| 138 | 118 | |
| 139 | - 'FROM_ID' => $message_row['message_sender'], | |
| 119 | + $template->assign_vars(array( | |
| 120 | + 'RECIPIENT_ID' => $recipient_id, | |
| 121 | + 'RECIPIENT_NAME' => htmlspecialchars($recipient_name), | |
| 122 | + 'SUBJECT' => htmlspecialchars($subject), | |
| 123 | + 'TEXT' => htmlspecialchars($text), | |
| 140 | 124 | )); | 
| 141 | - } | |
| 142 | 125 | |
| 143 | - break; | |
| 126 | +      foreach($error_list as $error_message) { | |
| 127 | +        $template->assign_block_vars('result', $error_message); | |
| 128 | + } | |
| 129 | + | |
| 130 | + $message_query = db_message_list_get_last_20($user, $recipient_id); | |
| 131 | +      while($message_row = db_fetch($message_query)) { | |
| 132 | +        $template->assign_block_vars('messages', array( | |
| 133 | + 'ID' => $message_row['message_id'], | |
| 134 | + 'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF), | |
| 135 | + 'FROM' => htmlspecialchars($message_row['message_from']), | |
| 136 | + 'SUBJ' => htmlspecialchars($message_row['message_subject']), | |
| 137 | + 'TEXT' => in_array($message_row['message_type'], array(MSG_TYPE_PLAYER, MSG_TYPE_ALLIANCE)) && $message_row['message_sender'] ? nl2br(htmlspecialchars($message_row['message_text'])) : nl2br($message_row['message_text']), | |
| 138 | + | |
| 139 | + 'FROM_ID' => $message_row['message_sender'], | |
| 140 | + )); | |
| 141 | + } | |
| 144 | 142 | |
| 145 | - case 'delete': | |
| 146 | - $query_add = ''; | |
| 143 | + break; | |
| 147 | 144 | |
| 148 | -    $message_range = sys_get_param_str('message_range'); | |
| 145 | + case 'delete': | |
| 146 | + $query_add = ''; | |
| 149 | 147 | |
| 150 | -    switch($message_range) { | |
| 148 | +      $message_range = sys_get_param_str('message_range'); | |
| 149 | + | |
| 150 | +      switch($message_range) { | |
| 151 | 151 | case 'unchecked': | 
| 152 | 152 | case 'checked': | 
| 153 | 153 |          $marked_message_list = sys_get_param('mark', array()); | 
| @@ -171,65 +171,65 @@ discard block | ||
| 171 | 171 | case 'all': | 
| 172 | 172 | $query_add = $query_add ? $query_add : true; | 
| 173 | 173 | break; | 
| 174 | - } | |
| 174 | + } | |
| 175 | 175 | |
| 176 | 176 |      if($query_add) { | 
| 177 | 177 | $query_add = $query_add === true ? '' : $query_add; | 
| 178 | 178 | db_message_list_delete($user, $query_add); | 
| 179 | 179 | } | 
| 180 | 180 | |
| 181 | - case 'show': | |
| 182 | -    if($current_class == MSG_TYPE_OUTBOX) { | |
| 183 | - $message_query = db_message_list_outbox_by_user_id($user['id']); | |
| 184 | -    } else { | |
| 185 | -      if($current_class == MSG_TYPE_NEW) { | |
| 186 | - $SubUpdateQry = array(); | |
| 187 | -        foreach($sn_message_class_list as $message_class_id => $message_class) { | |
| 188 | -          if($message_class_id != MSG_TYPE_OUTBOX) { | |
| 189 | -            $SubUpdateQry[] = "`{$message_class['name']}` = '0'"; | |
| 190 | - $user[$message_class['name']] = 0; | |
| 181 | + case 'show': | |
| 182 | +      if($current_class == MSG_TYPE_OUTBOX) { | |
| 183 | + $message_query = db_message_list_outbox_by_user_id($user['id']); | |
| 184 | +      } else { | |
| 185 | +        if($current_class == MSG_TYPE_NEW) { | |
| 186 | + $SubUpdateQry = array(); | |
| 187 | +          foreach($sn_message_class_list as $message_class_id => $message_class) { | |
| 188 | +            if($message_class_id != MSG_TYPE_OUTBOX) { | |
| 189 | +              $SubUpdateQry[] = "`{$message_class['name']}` = '0'"; | |
| 190 | + $user[$message_class['name']] = 0; | |
| 191 | + } | |
| 191 | 192 | } | 
| 193 | +          $SubUpdateQry = implode(',', $SubUpdateQry); | |
| 194 | +        } else { | |
| 195 | +          $SubUpdateQry = "`{$sn_message_class_list[$current_class]['name']}` = '0', `{$sn_message_class_list[MSG_TYPE_NEW]['name']}` = `{$sn_message_class_list[MSG_TYPE_NEW]['name']}` - '{$user[$sn_message_class_list[$current_class]['name']]}'"; | |
| 196 | +          $SubSelectQry = "AND `message_type` = '{$current_class}'"; | |
| 197 | + | |
| 198 | + $user[$sn_message_class_list[MSG_TYPE_NEW]['name']] -= $user[$sn_message_class_list[$current_class]['name']]; | |
| 199 | + $user[$sn_message_class_list[$current_class]['name']] = 0; | |
| 192 | 200 | } | 
| 193 | -        $SubUpdateQry = implode(',', $SubUpdateQry); | |
| 194 | -      } else { | |
| 195 | -        $SubUpdateQry = "`{$sn_message_class_list[$current_class]['name']}` = '0', `{$sn_message_class_list[MSG_TYPE_NEW]['name']}` = `{$sn_message_class_list[MSG_TYPE_NEW]['name']}` - '{$user[$sn_message_class_list[$current_class]['name']]}'"; | |
| 196 | -        $SubSelectQry = "AND `message_type` = '{$current_class}'"; | |
| 197 | 201 | |
| 198 | - $user[$sn_message_class_list[MSG_TYPE_NEW]['name']] -= $user[$sn_message_class_list[$current_class]['name']]; | |
| 199 | - $user[$sn_message_class_list[$current_class]['name']] = 0; | |
| 202 | + DBStaticUser::db_user_set_by_id($user['id'], $SubUpdateQry); | |
| 203 | + $message_query = db_message_list_by_owner_and_string($user, $SubSelectQry); | |
| 200 | 204 | } | 
| 201 | 205 | |
| 202 | - DBStaticUser::db_user_set_by_id($user['id'], $SubUpdateQry); | |
| 203 | - $message_query = db_message_list_by_owner_and_string($user, $SubSelectQry); | |
| 204 | - } | |
| 205 | - | |
| 206 | -    if(sys_get_param_int('return')) { | |
| 207 | -      header('Location: messages.php'); | |
| 208 | - die(); | |
| 209 | - } | |
| 206 | +      if(sys_get_param_int('return')) { | |
| 207 | +        header('Location: messages.php'); | |
| 208 | + die(); | |
| 209 | + } | |
| 210 | 210 | |
| 211 | -    $template = gettemplate('msg_message_list', true); | |
| 212 | -    while($message_row = db_fetch($message_query)) { | |
| 213 | -      $template->assign_block_vars('messages', array( | |
| 214 | - 'ID' => $message_row['message_id'], | |
| 215 | - 'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF), | |
| 216 | - 'FROM' => htmlspecialchars($message_row['message_from']), | |
| 217 | - 'SUBJ' => htmlspecialchars($message_row['message_subject']), | |
| 218 | - 'TEXT' => in_array($message_row['message_type'], array(MSG_TYPE_PLAYER, MSG_TYPE_ALLIANCE)) && $message_row['message_sender'] ? nl2br(htmlspecialchars($message_row['message_text'])) : nl2br($message_row['message_text']), | |
| 219 | - | |
| 220 | - 'FROM_ID' => $message_row['message_sender'], | |
| 221 | - 'SUBJ_SANITIZED' => htmlspecialchars($message_row['message_subject']), | |
| 222 | - 'STYLE' => $current_class == MSG_TYPE_OUTBOX ? $sn_message_class_list[MSG_TYPE_OUTBOX]['name'] : $sn_message_class_list[$message_row['message_type']]['name'], | |
| 223 | - )); | |
| 224 | - } | |
| 211 | +      $template = gettemplate('msg_message_list', true); | |
| 212 | +      while($message_row = db_fetch($message_query)) { | |
| 213 | +        $template->assign_block_vars('messages', array( | |
| 214 | + 'ID' => $message_row['message_id'], | |
| 215 | + 'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF), | |
| 216 | + 'FROM' => htmlspecialchars($message_row['message_from']), | |
| 217 | + 'SUBJ' => htmlspecialchars($message_row['message_subject']), | |
| 218 | + 'TEXT' => in_array($message_row['message_type'], array(MSG_TYPE_PLAYER, MSG_TYPE_ALLIANCE)) && $message_row['message_sender'] ? nl2br(htmlspecialchars($message_row['message_text'])) : nl2br($message_row['message_text']), | |
| 219 | + | |
| 220 | + 'FROM_ID' => $message_row['message_sender'], | |
| 221 | + 'SUBJ_SANITIZED' => htmlspecialchars($message_row['message_subject']), | |
| 222 | + 'STYLE' => $current_class == MSG_TYPE_OUTBOX ? $sn_message_class_list[MSG_TYPE_OUTBOX]['name'] : $sn_message_class_list[$message_row['message_type']]['name'], | |
| 223 | + )); | |
| 224 | + } | |
| 225 | 225 | |
| 226 | - $current_class_text = classLocale::$lang['msg_class'][$current_class]; | |
| 226 | + $current_class_text = classLocale::$lang['msg_class'][$current_class]; | |
| 227 | 227 | |
| 228 | - $template->assign_vars(array( | |
| 229 | - "MESSAGE_CLASS" => $current_class, | |
| 230 | - "MESSAGE_CLASS_TEXT" => $current_class_text, | |
| 231 | - )); | |
| 232 | - break; | |
| 228 | + $template->assign_vars(array( | |
| 229 | + "MESSAGE_CLASS" => $current_class, | |
| 230 | + "MESSAGE_CLASS_TEXT" => $current_class_text, | |
| 231 | + )); | |
| 232 | + break; | |
| 233 | 233 | } | 
| 234 | 234 | |
| 235 | 235 |  if(!$template) { | 
| @@ -12,24 +12,24 @@ discard block | ||
| 12 | 12 | global $template_result, $user; | 
| 13 | 13 | |
| 14 | 14 | // Напоминание для Администрации, что игра отключена | 
| 15 | -if($template_result[F_GAME_DISABLE]) { | |
| 15 | +if ($template_result[F_GAME_DISABLE]) { | |
| 16 | 16 | echo '<div class="global_admin_warning">', $template_result[F_GAME_DISABLE_REASON], '</div>'; | 
| 17 | 17 | } | 
| 18 | 18 | unset($disable_reason); | 
| 19 | 19 | |
| 20 | 20 | |
| 21 | -if(defined('IN_ADMIN') && IN_ADMIN === true) { | |
| 21 | +if (defined('IN_ADMIN') && IN_ADMIN === true) { | |
| 22 | 22 |    lng_include('admin'); | 
| 23 | -} elseif($sys_user_logged_in) { | |
| 23 | +} elseif ($sys_user_logged_in) { | |
| 24 | 24 | sys_user_vacation($user); | 
| 25 | 25 | |
| 26 | 26 | $planet_id = SetSelectedPlanet($user); | 
| 27 | 27 | |
| 28 | 28 | // TODO НЕ НУЖНО АЛЬЯНС КАЖДЫЙ РАЗ ОБНОВЛЯТЬ!!! | 
| 29 | -  if($user['ally_id']) { | |
| 29 | +  if ($user['ally_id']) { | |
| 30 | 30 | sn_db_transaction_start(); | 
| 31 | 31 | sn_ali_fill_user_ally($user); | 
| 32 | -    if(!$user['ally']['player']['id']) { | |
| 32 | +    if (!$user['ally']['player']['id']) { | |
| 33 | 33 | // sn_sys_logout(false, true); | 
| 34 | 34 | // core_auth::logout(false); | 
| 35 | 35 | classSupernova::$auth->logout(false); | 
| @@ -37,7 +37,7 @@ discard block | ||
| 37 | 37 | } | 
| 38 | 38 | // TODO UNCOMMENT | 
| 39 | 39 | que_process($user['ally']['player']); | 
| 40 | - DBStaticUser::db_user_set_by_id($user['ally']['player']['id'], '`onlinetime` = ' . SN_TIME_NOW); | |
| 40 | + DBStaticUser::db_user_set_by_id($user['ally']['player']['id'], '`onlinetime` = '.SN_TIME_NOW); | |
| 41 | 41 | sn_db_transaction_commit(); | 
| 42 | 42 | } | 
| 43 | 43 | |
| @@ -48,7 +48,7 @@ discard block | ||
| 48 | 48 | sn_db_transaction_commit(); | 
| 49 | 49 | |
| 50 | 50 | $planetrow = $global_data['planet']; | 
| 51 | -  if(!($planetrow && isset($planetrow['id']) && $planetrow['id'])) { | |
| 51 | +  if (!($planetrow && isset($planetrow['id']) && $planetrow['id'])) { | |
| 52 | 52 | // sn_sys_logout(false, true); | 
| 53 | 53 | // core_auth::logout(false); | 
| 54 | 54 | classSupernova::$auth->logout(false); | 
| @@ -3,22 +3,22 @@ discard block | ||
| 3 | 3 |  define('INSIDE', true); | 
| 4 | 4 |  define('INSTALL', false); | 
| 5 | 5 |  define('IN_ADMIN', true); | 
| 6 | -require('../common.' . substr(strrchr(__FILE__, '.'), 1)); | |
| 6 | +require('../common.'.substr(strrchr(__FILE__, '.'), 1)); | |
| 7 | 7 | |
| 8 | -if($user['authlevel'] < 3) { | |
| 8 | +if ($user['authlevel'] < 3) { | |
| 9 | 9 | AdminMessage(classLocale::$lang['adm_err_denied']); | 
| 10 | 10 | } | 
| 11 | 11 | |
| 12 | 12 |  lng_include('admin'); | 
| 13 | 13 | |
| 14 | 14 |  $user_id = sys_get_param_id('uid'); | 
| 15 | -if(!($user_row = DBStaticUser::db_user_by_id($user_id))) { | |
| 15 | +if (!($user_row = DBStaticUser::db_user_by_id($user_id))) { | |
| 16 | 16 | AdminMessage(sprintf(classLocale::$lang['adm_dm_user_none'], $user_id)); | 
| 17 | 17 | } | 
| 18 | 18 | |
| 19 | 19 |  $template = gettemplate('admin/admin_user', true); | 
| 20 | 20 | |
| 21 | -if(!empty($user_row['user_last_browser_id'])) { | |
| 21 | +if (!empty($user_row['user_last_browser_id'])) { | |
| 22 | 22 | $user_row['browser_user_agent'] = db_browser_agent_get_by_id($user_row['user_last_browser_id']); | 
| 23 | 23 | } | 
| 24 | 24 | |
| @@ -54,10 +54,10 @@ discard block | ||
| 54 | 54 | 'raidsloose', | 
| 55 | 55 | 'raidswin', | 
| 56 | 56 | 'total_rank', | 
| 57 | - 'total_points', ), | |
| 57 | + 'total_points',), | |
| 58 | 58 | ); | 
| 59 | -foreach($formats as $callable => $field_list) { | |
| 60 | -  foreach($field_list as $field_name) { | |
| 59 | +foreach ($formats as $callable => $field_list) { | |
| 60 | +  foreach ($field_list as $field_name) { | |
| 61 | 61 | $user_row[$field_name] = call_user_func($callable, $user_row[$field_name]); | 
| 62 | 62 | } | 
| 63 | 63 | } | 
| @@ -7,7 +7,7 @@ discard block | ||
| 7 | 7 | */ | 
| 8 | 8 | |
| 9 | 9 |  function sys_user_vacation($user) { | 
| 10 | -  if(sys_get_param_str('vacation') == 'leave') { | |
| 10 | +  if (sys_get_param_str('vacation') == 'leave') { | |
| 11 | 11 |      if ($user['vacation'] < SN_TIME_NOW) { | 
| 12 | 12 | $user['vacation'] = 0; | 
| 13 | 13 | $user['vacation_next'] = SN_TIME_NOW + classSupernova::$config->player_vacation_timeout; | 
| @@ -15,7 +15,7 @@ discard block | ||
| 15 | 15 | } | 
| 16 | 16 | } | 
| 17 | 17 | |
| 18 | -  if($user['vacation']) { | |
| 18 | +  if ($user['vacation']) { | |
| 19 | 19 | // sn_sys_logout(false, true); | 
| 20 | 20 | // core_auth::logout(false, true); | 
| 21 | 21 | |
| @@ -45,33 +45,33 @@ discard block | ||
| 45 | 45 | // TODO: Full rewrite | 
| 46 | 46 | sn_db_transaction_start(); | 
| 47 | 47 | $TheUser = DBStaticUser::db_user_by_id($UserID); | 
| 48 | -  if ( $TheUser['ally_id'] != 0 ) { | |
| 49 | -    $TheAlly = doquery ( "SELECT * FROM `{{alliance}}` WHERE `id` = '" . $TheUser['ally_id'] . "';", '', true ); | |
| 48 | +  if ($TheUser['ally_id'] != 0) { | |
| 49 | +    $TheAlly = doquery("SELECT * FROM `{{alliance}}` WHERE `id` = '".$TheUser['ally_id']."';", '', true); | |
| 50 | 50 | $TheAlly['ally_members'] -= 1; | 
| 51 | -    if ( $TheAlly['ally_members'] > 0 ) { | |
| 52 | -      doquery ( "UPDATE `{{alliance}}` SET `ally_members` = '" . $TheAlly['ally_members'] . "' WHERE `id` = '" . $TheAlly['id'] . "';"); | |
| 51 | +    if ($TheAlly['ally_members'] > 0) { | |
| 52 | +      doquery("UPDATE `{{alliance}}` SET `ally_members` = '".$TheAlly['ally_members']."' WHERE `id` = '".$TheAlly['id']."';"); | |
| 53 | 53 |      } else { | 
| 54 | -      doquery ( "DELETE FROM `{{alliance}}` WHERE `id` = '" . $TheAlly['id'] . "';"); | |
| 55 | -      doquery ( "DELETE FROM `{{statpoints}}` WHERE `stat_type` = '2' AND `id_owner` = '" . $TheAlly['id'] . "';"); | |
| 54 | +      doquery("DELETE FROM `{{alliance}}` WHERE `id` = '".$TheAlly['id']."';"); | |
| 55 | +      doquery("DELETE FROM `{{statpoints}}` WHERE `stat_type` = '2' AND `id_owner` = '".$TheAlly['id']."';"); | |
| 56 | 56 | } | 
| 57 | 57 | } | 
| 58 | -  doquery ( "DELETE FROM `{{statpoints}}` WHERE `stat_type` = '1' AND `id_owner` = '" . $UserID . "';"); | |
| 58 | +  doquery("DELETE FROM `{{statpoints}}` WHERE `stat_type` = '1' AND `id_owner` = '".$UserID."';"); | |
| 59 | 59 | |
| 60 | 60 | db_planet_list_delete_by_owner($UserID); | 
| 61 | 61 | |
| 62 | -  doquery ( "DELETE FROM `{{messages}}` WHERE `message_sender` = '" . $UserID . "';"); | |
| 63 | -  doquery ( "DELETE FROM `{{messages}}` WHERE `message_owner` = '" . $UserID . "';"); | |
| 64 | -  doquery ( "DELETE FROM `{{notes}}` WHERE `owner` = '" . $UserID . "';"); | |
| 62 | +  doquery("DELETE FROM `{{messages}}` WHERE `message_sender` = '".$UserID."';"); | |
| 63 | +  doquery("DELETE FROM `{{messages}}` WHERE `message_owner` = '".$UserID."';"); | |
| 64 | +  doquery("DELETE FROM `{{notes}}` WHERE `owner` = '".$UserID."';"); | |
| 65 | 65 | FleetList::db_fleet_list_delete_by_owner($UserID); | 
| 66 | 66 |  //  doquery ( "DELETE FROM `{{rw}}` WHERE `id_owner1` = '" . $UserID . "';"); | 
| 67 | 67 |  //  doquery ( "DELETE FROM `{{rw}}` WHERE `id_owner2` = '" . $UserID . "';"); | 
| 68 | -  doquery ( "DELETE FROM `{{buddy}}` WHERE `BUDDY_SENDER_ID` = '" . $UserID . "';"); | |
| 69 | -  doquery ( "DELETE FROM `{{buddy}}` WHERE `BUDDY_OWNER_ID` = '" . $UserID . "';"); | |
| 70 | -  doquery ( "DELETE FROM `{{annonce}}` WHERE `user` = '" . $UserID . "';"); | |
| 68 | +  doquery("DELETE FROM `{{buddy}}` WHERE `BUDDY_SENDER_ID` = '".$UserID."';"); | |
| 69 | +  doquery("DELETE FROM `{{buddy}}` WHERE `BUDDY_OWNER_ID` = '".$UserID."';"); | |
| 70 | +  doquery("DELETE FROM `{{annonce}}` WHERE `user` = '".$UserID."';"); | |
| 71 | 71 | |
| 72 | 72 | |
| 73 | 73 | classSupernova::db_del_record_by_id(LOC_USER, $UserID); | 
| 74 | -  doquery ( "DELETE FROM `{{referrals}}` WHERE (`id` = '{$UserID}') OR (`id_partner` = '{$UserID}');"); | |
| 74 | +  doquery("DELETE FROM `{{referrals}}` WHERE (`id` = '{$UserID}') OR (`id_partner` = '{$UserID}');"); | |
| 75 | 75 |    classSupernova::$config->db_saveItem('users_amount', classSupernova::$config->db_loadItem('users_amount') - 1); | 
| 76 | 76 | sn_db_transaction_commit(); | 
| 77 | 77 | } | 
| @@ -87,7 +87,7 @@ discard block | ||
| 87 | 87 | $ban_current = DBStaticUser::db_user_by_id($banned['id'], false, 'banaday'); | 
| 88 | 88 | $ban_until = ($ban_current['banaday'] ? $ban_current['banaday'] : SN_TIME_NOW) + $term; | 
| 89 | 89 | |
| 90 | -  DBStaticUser::db_user_set_by_id($banned['id'], "`banaday` = {$ban_until} " . ($is_vacation ? ", `vacation` = '{$ban_until}' " : '')); | |
| 90 | +  DBStaticUser::db_user_set_by_id($banned['id'], "`banaday` = {$ban_until} ".($is_vacation ? ", `vacation` = '{$ban_until}' " : '')); | |
| 91 | 91 | |
| 92 | 92 | $banned['username'] = db_escape($banned['username']); | 
| 93 | 93 | $banner['username'] = db_escape($banner['username']); | 
| @@ -105,7 +105,7 @@ discard block | ||
| 105 | 105 | * @param string $reason | 
| 106 | 106 | */ | 
| 107 | 107 |  function sys_admin_player_ban_unset($banner, $banned, $reason = '') { | 
| 108 | - DBStaticUser::db_user_set_by_id($banned['id'], "`banaday` = 0, `vacation` = " . SN_TIME_NOW . ""); | |
| 108 | + DBStaticUser::db_user_set_by_id($banned['id'], "`banaday` = 0, `vacation` = ".SN_TIME_NOW.""); | |
| 109 | 109 | |
| 110 | 110 | $banned['username'] = db_escape($banned['username']); | 
| 111 | 111 | $banner['username'] = db_escape($banner['username']); | 
| @@ -134,7 +134,7 @@ discard block | ||
| 134 | 134 | |
| 135 | 135 | 'total_points' => $options['total_points'] = empty($options['total_points']) ? 0 : $options['total_points'], | 
| 136 | 136 | |
| 137 | - 'options' => (empty($options['options']) ? $player_options_string : $options['options']) . (empty($options['options_extra']) ? '' : $options['options_extra']), | |
| 137 | + 'options' => (empty($options['options']) ? $player_options_string : $options['options']).(empty($options['options_extra']) ? '' : $options['options_extra']), | |
| 138 | 138 | |
| 139 | 139 | 'galaxy' => $options['galaxy'] = intval($options['galaxy'] ? $options['galaxy'] : 0), | 
| 140 | 140 | 'system' => $options['system'] = intval($options['system'] ? $options['system'] : 0), | 
| @@ -145,28 +145,28 @@ discard block | ||
| 145 | 145 | !empty($options['password_encoded_unsafe']) ? $field_set['password'] = $options['password_encoded_unsafe'] : false; | 
| 146 | 146 | |
| 147 | 147 | $user_new = classSupernova::db_ins_field_set(LOC_USER, $field_set); | 
| 148 | -  if(!($options['galaxy'] && $options['system'] && $options['planet'])) { | |
| 148 | +  if (!($options['galaxy'] && $options['system'] && $options['planet'])) { | |
| 149 | 149 | $options['galaxy'] = classSupernova::$config->LastSettedGalaxyPos; | 
| 150 | 150 | $options['system'] = classSupernova::$config->LastSettedSystemPos; | 
| 151 | - $segment_size = floor(Vector::$knownPlanets/ 3); | |
| 151 | + $segment_size = floor(Vector::$knownPlanets / 3); | |
| 152 | 152 | $segment = floor(classSupernova::$config->LastSettedPlanetPos / $segment_size); | 
| 153 | 153 | $segment++; | 
| 154 | 154 | $options['planet'] = mt_rand(1 + $segment * $segment_size, ($segment + 1) * $segment_size); | 
| 155 | 155 | |
| 156 | 156 | // $new_planet_id = 0; | 
| 157 | -    while(true) { | |
| 158 | -      if($options['planet'] > Vector::$knownPlanets) { | |
| 157 | +    while (true) { | |
| 158 | +      if ($options['planet'] > Vector::$knownPlanets) { | |
| 159 | 159 | $options['planet'] = mt_rand(0, $segment_size - 1) + 1; | 
| 160 | 160 | $options['system']++; | 
| 161 | 161 | } | 
| 162 | -      if($options['system'] > Vector::$knownSystems) { | |
| 162 | +      if ($options['system'] > Vector::$knownSystems) { | |
| 163 | 163 | $options['system'] = 1; | 
| 164 | 164 | $options['galaxy']++; | 
| 165 | 165 | } | 
| 166 | - $options['galaxy'] > Vector::$knownGalaxies? $options['galaxy'] = 1 : false; | |
| 166 | + $options['galaxy'] > Vector::$knownGalaxies ? $options['galaxy'] = 1 : false; | |
| 167 | 167 | |
| 168 | 168 | $galaxy_row = db_planet_by_gspt($options['galaxy'], $options['system'], $options['planet'], PT_PLANET, true, 'id'); | 
| 169 | -      if(!$galaxy_row['id']) { | |
| 169 | +      if (!$galaxy_row['id']) { | |
| 170 | 170 | classSupernova::$config->db_saveItem(array( | 
| 171 | 171 | 'LastSettedGalaxyPos' => $options['galaxy'], | 
| 172 | 172 | 'LastSettedSystemPos' => $options['system'], | 
| @@ -189,7 +189,7 @@ discard block | ||
| 189 | 189 | $username_safe = db_escape($username_unsafe); | 
| 190 | 190 | db_player_name_history_replace($user_new, $username_safe); | 
| 191 | 191 | |
| 192 | -  if(!empty($options['partner_id']) && ($referral_row = DBStaticUser::db_user_by_id($options['partner_id'], true))) { | |
| 192 | +  if (!empty($options['partner_id']) && ($referral_row = DBStaticUser::db_user_by_id($options['partner_id'], true))) { | |
| 193 | 193 | db_referral_insert($options, $user_new); | 
| 194 | 194 | } | 
| 195 | 195 | |
| @@ -11,15 +11,15 @@ discard block | ||
| 11 | 11 | $announce_list = db_news_list_get_by_query($template, $query_where, $query_limit); | 
| 12 | 12 | |
| 13 | 13 | $users = array(); | 
| 14 | -  while($announce = db_fetch($announce_list)) { | |
| 15 | -    if($announce['user_id'] && !isset($users[$announce['user_id']])) { | |
| 14 | +  while ($announce = db_fetch($announce_list)) { | |
| 15 | +    if ($announce['user_id'] && !isset($users[$announce['user_id']])) { | |
| 16 | 16 | $users[$announce['user_id']] = DBStaticUser::db_user_by_id($announce['user_id']); | 
| 17 | 17 | } | 
| 18 | 18 | |
| 19 | 19 |      $survey_vote = array('survey_vote_id' => 1); | 
| 20 | 20 | $survey_complete = strtotime($announce['survey_until']) < SN_TIME_NOW; | 
| 21 | 21 | |
| 22 | -    if($announce['survey_id'] && !empty($user['id'])) { | |
| 22 | +    if ($announce['survey_id'] && !empty($user['id'])) { | |
| 23 | 23 | $survey_vote = !$survey_complete ? db_survey_get_vote($announce, $user) : array(); | 
| 24 | 24 | } | 
| 25 | 25 | |
| @@ -31,8 +31,7 @@ discard block | ||
| 31 | 31 | 'ANNOUNCE' => cht_message_parse($announce['strAnnounce'], false, intval($announce['authlevel'])), | 
| 32 | 32 | 'DETAIL_URL' => $announce['detail_url'], | 
| 33 | 33 | 'USER_NAME' => | 
| 34 | -        isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) : | |
| 35 | - js_safe_string($announce['user_name']), | |
| 34 | +        isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) : js_safe_string($announce['user_name']), | |
| 36 | 35 | 'NEW' => $announce['unix_time'] + classSupernova::$config->game_news_actual >= SN_TIME_NOW, | 
| 37 | 36 | 'FUTURE' => $announce['unix_time'] > SN_TIME_NOW, | 
| 38 | 37 | 'SURVEY_ID' => $announce['survey_id'], | 
| @@ -42,25 +41,25 @@ discard block | ||
| 42 | 41 | 'SURVEY_UNTIL' => $announce['survey_until'], | 
| 43 | 42 | )); | 
| 44 | 43 | |
| 45 | -    foreach($announce_exploded as $announce_paragraph) { | |
| 44 | +    foreach ($announce_exploded as $announce_paragraph) { | |
| 46 | 45 |        $template->assign_block_vars('announces.paragraph', array( | 
| 47 | 46 | 'TEXT' => $announce_paragraph, | 
| 48 | 47 | )); | 
| 49 | 48 | } | 
| 50 | 49 | |
| 51 | -    if($announce['survey_id']) { | |
| 50 | +    if ($announce['survey_id']) { | |
| 52 | 51 | $survey_query = db_survey_get_answer_texts($announce); | 
| 53 | 52 | $survey_vote_result = array(); | 
| 54 | 53 | $total_votes = 0; | 
| 55 | -      while($row = db_fetch($survey_query)) { | |
| 54 | +      while ($row = db_fetch($survey_query)) { | |
| 56 | 55 | $survey_vote_result[] = $row; | 
| 57 | 56 | $total_votes += $row['VOTES']; | 
| 58 | 57 | } | 
| 59 | 58 | |
| 60 | -      if(empty($survey_vote) && !$survey_complete) { | |
| 59 | +      if (empty($survey_vote) && !$survey_complete) { | |
| 61 | 60 | // Can vote | 
| 62 | 61 | $survey_query = db_survey_answers_get_list_by_parent($announce); | 
| 63 | -        while($row = db_fetch($survey_query)) { | |
| 62 | +        while ($row = db_fetch($survey_query)) { | |
| 64 | 63 |            $template->assign_block_vars('announces.survey_answers', array( | 
| 65 | 64 | 'ID' => $row['survey_answer_id'], | 
| 66 | 65 | 'TEXT' => $row['survey_answer_text'], | 
| @@ -68,7 +67,7 @@ discard block | ||
| 68 | 67 | } | 
| 69 | 68 |        } else { | 
| 70 | 69 | // Show result | 
| 71 | -        foreach($survey_vote_result as &$vote_result) { | |
| 70 | +        foreach ($survey_vote_result as &$vote_result) { | |
| 72 | 71 | $vote_percent = $total_votes ? $vote_result['VOTES'] / $total_votes * 100 : 0; | 
| 73 | 72 | $vote_result['PERCENT'] = $vote_percent; | 
| 74 | 73 | $vote_result['PERCENT_TEXT'] = round($vote_percent, 1); | 
| @@ -85,8 +84,8 @@ discard block | ||
| 85 | 84 | } | 
| 86 | 85 | |
| 87 | 86 |  function nws_mark_read(&$user) { | 
| 88 | -  if(isset($user['id'])) { | |
| 89 | - DBStaticUser::db_user_set_by_id($user['id'], '`news_lastread` = ' . SN_TIME_NOW); | |
| 87 | +  if (isset($user['id'])) { | |
| 88 | + DBStaticUser::db_user_set_by_id($user['id'], '`news_lastread` = '.SN_TIME_NOW); | |
| 90 | 89 | $user['news_lastread'] = SN_TIME_NOW; | 
| 91 | 90 | } | 
| 92 | 91 | |
| @@ -94,17 +93,17 @@ discard block | ||
| 94 | 93 | } | 
| 95 | 94 | |
| 96 | 95 |  function survey_vote(&$user) { | 
| 97 | -  if(empty($user['id'])) { | |
| 96 | +  if (empty($user['id'])) { | |
| 98 | 97 | return true; | 
| 99 | 98 | } | 
| 100 | 99 | |
| 101 | 100 | sn_db_transaction_start(); | 
| 102 | 101 |    $survey_id = sys_get_param_id('survey_id'); | 
| 103 | 102 | $is_voted = db_survey_vote_get($user, $survey_id); | 
| 104 | -  if(empty($is_voted)) { | |
| 103 | +  if (empty($is_voted)) { | |
| 105 | 104 |      $survey_vote_id = sys_get_param_id('survey_vote'); | 
| 106 | 105 | $is_answer_exists = db_survey_answer_get($survey_id, $survey_vote_id); | 
| 107 | -    if(!empty($is_answer_exists)) { | |
| 106 | +    if (!empty($is_answer_exists)) { | |
| 108 | 107 | $user_name_safe = db_escape($user['username']); | 
| 109 | 108 | db_survey_vote_insert($user, $survey_id, $survey_vote_id, $user_name_safe); | 
| 110 | 109 | } | 
| @@ -2,31 +2,31 @@ discard block | ||
| 2 | 2 | |
| 3 | 3 | $classLocale = classLocale::$lang; | 
| 4 | 4 | |
| 5 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { | |
| 5 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { | |
| 6 | 6 |    classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); | 
| 7 | 7 | } | 
| 8 | 8 | |
| 9 | 9 | // Changing rank for single user | 
| 10 | 10 |  $id_user = sys_get_param_id('id_user'); | 
| 11 | -if(isset($_GET['id_rank'])) { | |
| 11 | +if (isset($_GET['id_rank'])) { | |
| 12 | 12 |    $id_rank = sys_get_param_int('id_rank'); | 
| 13 | 13 | } | 
| 14 | -if($id_user && isset($id_rank) && $user_admin) { | |
| 14 | +if ($id_user && isset($id_rank) && $user_admin) { | |
| 15 | 15 |    DBStaticUser::db_user_set_by_id($id_user, "`ally_rank_id` = {$id_rank}"); | 
| 16 | 16 | } | 
| 17 | 17 | |
| 18 | 18 |  $id_kick = sys_get_param_id('kick'); | 
| 19 | 19 | |
| 20 | -if($id_kick && $user_can_kick) { | |
| 20 | +if ($id_kick && $user_can_kick) { | |
| 21 | 21 | $u = DBStaticUser::db_user_by_id($id_kick, true); | 
| 22 | -  if($u['ally_id'] == $ally['id'] && $u['id'] != $ally['ally_owner']) { | |
| 22 | +  if ($u['ally_id'] == $ally['id'] && $u['id'] != $ally['ally_owner']) { | |
| 23 | 23 | DBStaticUser::db_user_set_by_id($id_kick, '`ally_id`= null, `ally_name` = null, `ally_tag` = null, ally_register_time = 0, ally_rank_id = 0'); | 
| 24 | 24 | db_ally_update_member_decrease($ally); | 
| 25 | 25 | } | 
| 26 | 26 | } | 
| 27 | 27 | |
| 28 | 28 |  $sort2 = sys_get_param_int('sort2'); | 
| 29 | -if($sort2) { | |
| 29 | +if ($sort2) { | |
| 30 | 30 | $sort2s = "DESC"; | 
| 31 | 31 | $sort2 = 0; | 
| 32 | 32 |  } else { | 
| @@ -35,7 +35,7 @@ discard block | ||
| 35 | 35 | } | 
| 36 | 36 | |
| 37 | 37 |  $sort1 = sys_get_param_int('sort1'); | 
| 38 | -if($sort1 > 5 || $sort1 < 0) { | |
| 38 | +if ($sort1 > 5 || $sort1 < 0) { | |
| 39 | 39 | $sort1 = 0; | 
| 40 | 40 | } | 
| 41 | 41 | $sort1s = array( | 
| @@ -49,28 +49,28 @@ discard block | ||
| 49 | 49 | |
| 50 | 50 |  $template = gettemplate('ali_members', true); | 
| 51 | 51 | |
| 52 | -$userList = DBStaticUser::db_user_list("`ally_id`= {$user['ally_id']} ORDER BY " . sprintf($sort1s[$sort1], $sort2s), false, | |
| 52 | +$userList = DBStaticUser::db_user_list("`ally_id`= {$user['ally_id']} ORDER BY ".sprintf($sort1s[$sort1], $sort2s), false, | |
| 53 | 53 | 'id, username, galaxy, system, planet, onlinetime, ally_rank_id, ally_register_time, total_points'); | 
| 54 | 54 | |
| 55 | 55 | // while ($userRow = db_fetch($userList)) | 
| 56 | -foreach($userList as $userRow) { | |
| 56 | +foreach ($userList as $userRow) { | |
| 57 | 57 | $i++; | 
| 58 | -  if(!isset($ranks[$userRow['ally_rank_id']])) { | |
| 58 | +  if (!isset($ranks[$userRow['ally_rank_id']])) { | |
| 59 | 59 | $userRow['ally_rank_id'] = 0; | 
| 60 | 60 | } | 
| 61 | 61 | |
| 62 | -  if($ally['ally_owner'] == $userRow['id']) { | |
| 62 | +  if ($ally['ally_owner'] == $userRow['id']) { | |
| 63 | 63 | $ally_range = ($ally['ally_owner_range']) ? $ally['ally_owner_range'] : classLocale::$lang['Founder']; | 
| 64 | 64 |    } else { | 
| 65 | -    if($user_admin) { | |
| 66 | - $ally_range = '<select onchange="window.location=\'alliance.php?mode=admin&edit=members&id_user=' . $userRow['id'] . '&id_rank=\' + this.value">'; | |
| 65 | +    if ($user_admin) { | |
| 66 | + $ally_range = '<select onchange="window.location=\'alliance.php?mode=admin&edit=members&id_user='.$userRow['id'].'&id_rank=\' + this.value">'; | |
| 67 | 67 | |
| 68 | -      foreach($ranks as $rankID => $rankArray) { | |
| 69 | - $ally_range .= '<option value="' . $rankID . '"'; | |
| 70 | -        if($rankID == $userRow['ally_rank_id']) { | |
| 68 | +      foreach ($ranks as $rankID => $rankArray) { | |
| 69 | + $ally_range .= '<option value="'.$rankID.'"'; | |
| 70 | +        if ($rankID == $userRow['ally_rank_id']) { | |
| 71 | 71 | $ally_range .= " selected"; | 
| 72 | 72 | } | 
| 73 | - $ally_range .= '>' . $rankArray['name']; | |
| 73 | + $ally_range .= '>'.$rankArray['name']; | |
| 74 | 74 | $ally_range .= '</option>'; | 
| 75 | 75 | } | 
| 76 | 76 | $ally_range .= '</select>'; | 
| @@ -80,20 +80,20 @@ discard block | ||
| 80 | 80 | } | 
| 81 | 81 | |
| 82 | 82 | $last_active = time() - $userRow["onlinetime"]; | 
| 83 | -  if($user_admin) { | |
| 84 | -    if($last_active < 60) { | |
| 83 | +  if ($user_admin) { | |
| 84 | +    if ($last_active < 60) { | |
| 85 | 85 |        $tmp = "lime>{$classLocale['On']}"; | 
| 86 | -    } elseif($last_active < 60 * 60) { | |
| 86 | +    } elseif ($last_active < 60 * 60) { | |
| 87 | 87 | $last_active = round($last_active / 60); | 
| 88 | 88 |        $tmp = "lime>{$last_active} {$classLocale['sys_min_short']}"; | 
| 89 | -    } elseif($last_active < 60 * 60 * 24) { | |
| 89 | +    } elseif ($last_active < 60 * 60 * 24) { | |
| 90 | 90 | $last_active = round($last_active / (60 * 60)); | 
| 91 | 91 |        $tmp = "green>{$last_active} {$classLocale['sys_hrs_short']}"; | 
| 92 | 92 |      } else { | 
| 93 | 93 | $last_active = round($last_active / (60 * 60 * 24)); | 
| 94 | -      if($last_active < 7) { | |
| 94 | +      if ($last_active < 7) { | |
| 95 | 95 | $tmp = "yellow"; | 
| 96 | -      } elseif($last_active < 30) { | |
| 96 | +      } elseif ($last_active < 30) { | |
| 97 | 97 | $tmp = "orange"; | 
| 98 | 98 |        } else { | 
| 99 | 99 | $tmp = "red"; | 
| @@ -101,10 +101,10 @@ discard block | ||
| 101 | 101 |        $tmp .= ">{$last_active} {$classLocale['sys_day_short']}"; | 
| 102 | 102 | } | 
| 103 | 103 |    } else { | 
| 104 | -    if($user_onlinestatus) { | |
| 105 | -      if($last_active < 60 * 5) { | |
| 104 | +    if ($user_onlinestatus) { | |
| 105 | +      if ($last_active < 60 * 5) { | |
| 106 | 106 |          $tmp = "lime>{$classLocale['On']}"; | 
| 107 | -      } elseif($last_active < 60 * 15) { | |
| 107 | +      } elseif ($last_active < 60 * 15) { | |
| 108 | 108 |          $tmp = "yellow>{$classLocale['ali_lessThen15min']}"; | 
| 109 | 109 |        } else { | 
| 110 | 110 |          $tmp = "red>{$classLocale['Off']}"; | 
| @@ -124,21 +124,21 @@ discard block | ||
| 124 | 124 | 'SYSTEM' => $userRow['system'], | 
| 125 | 125 | 'PLANET' => $userRow['planet'], | 
| 126 | 126 | 'POINTS' => pretty_number($userRow['total_points']), | 
| 127 | - 'ONLINE' => '<font color=' . $tmp . '</font>', | |
| 127 | + 'ONLINE' => '<font color='.$tmp.'</font>', | |
| 128 | 128 | 'RANK' => $ally_range, | 
| 129 | 129 | 'REGISTER_TIME' => date(FMT_DATE_TIME, $userRow['ally_register_time']), | 
| 130 | 130 | 'SHOW_KICK' => $user['id'] != $userRow['id'] && $ally['ally_owner'] != $userRow['id'], | 
| 131 | 131 | )); | 
| 132 | 132 | } | 
| 133 | 133 | |
| 134 | -if($i != $ally['ally_members']) { | |
| 134 | +if ($i != $ally['ally_members']) { | |
| 135 | 135 | db_ally_update_member_set($i, $ally); | 
| 136 | 136 | } | 
| 137 | 137 | |
| 138 | 138 | $template->assign_vars(array( | 
| 139 | - 'mode' => $mode . ($edit ? "&edit=" . $edit : ''), | |
| 139 | + 'mode' => $mode.($edit ? "&edit=".$edit : ''), | |
| 140 | 140 | 'ADMIN_MODE' => $user_can_kick, | 
| 141 | - 'dpath' => SN_ROOT_VIRTUAL . $dpath, | |
| 141 | + 'dpath' => SN_ROOT_VIRTUAL.$dpath, | |
| 142 | 142 | 'onlineMessage' => $user_admin ? classLocale::$lang['ali_sys_lastActive'] : classLocale::$lang['Online'], | 
| 143 | 143 | 'memberCount' => count($userList), | 
| 144 | 144 | 'memberslist' => $page_list, | 
| @@ -2,7 +2,7 @@ discard block | ||
| 2 | 2 | // Pretty Safe | 
| 3 | 3 | // TODO: Add ally_tag to usertable | 
| 4 | 4 | |
| 5 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { | |
| 5 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { | |
| 6 | 6 |    classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); | 
| 7 | 7 | } | 
| 8 | 8 | |
| @@ -11,21 +11,21 @@ discard block | ||
| 11 | 11 |  $ally_name_raw = sys_get_param_str_unsafe('name'); | 
| 12 | 12 | $ally_name = db_escape($ally_name_raw); | 
| 13 | 13 | |
| 14 | -if($ally_tag) { | |
| 15 | -  if(!$ally_name_raw || !$ally_tag_raw) { | |
| 14 | +if ($ally_tag) { | |
| 15 | +  if (!$ally_name_raw || !$ally_tag_raw) { | |
| 16 | 16 | message(classLocale::$lang['have_not_name'], classLocale::$lang['make_alliance']); | 
| 17 | 17 | } | 
| 18 | 18 | |
| 19 | 19 | $query = db_ally_get_by_name_or_tag($ally_tag, $ally_name); | 
| 20 | -  if($query) { | |
| 20 | +  if ($query) { | |
| 21 | 21 |      message(str_replace('%s', $query['ally_tag'] == $ally_tag_raw ? $ally_tag_raw : $ally_name_raw, classLocale::$lang['always_exist']), classLocale::$lang['make_alliance']); | 
| 22 | 22 | } | 
| 23 | 23 | |
| 24 | 24 | db_ally_insert($ally_name, $ally_tag, $user); | 
| 25 | 25 | $ally_id = db_insert_id(); | 
| 26 | -  DBStaticUser::db_user_set_by_id($user['id'], "`ally_tag` = '{$ally_tag}', `ally_id`= {$ally_id}, `ally_name`='{$ally_name}', `ally_register_time`= " . SN_TIME_NOW . ""); | |
| 26 | +  DBStaticUser::db_user_set_by_id($user['id'], "`ally_tag` = '{$ally_tag}', `ally_id`= {$ally_id}, `ally_name`='{$ally_name}', `ally_register_time`= ".SN_TIME_NOW.""); | |
| 27 | 27 | |
| 28 | -  $ally_user = classSupernova::db_ins_record(LOC_USER, "`username` = '[{$ally_tag}]', `register_time` = " . SN_TIME_NOW . ", `user_as_ally` = {$ally_id}"); | |
| 28 | +  $ally_user = classSupernova::db_ins_record(LOC_USER, "`username` = '[{$ally_tag}]', `register_time` = ".SN_TIME_NOW.", `user_as_ally` = {$ally_id}"); | |
| 29 | 29 | // $ally_user_id = db_insert_id(); | 
| 30 | 30 | $ally_user_id = is_array($ally_user) ? $ally_user['id'] : 'NULL'; | 
| 31 | 31 | db_ally_update_ally_user($ally_user_id, $ally_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 | |
| @@ -10,16 +10,16 @@ discard block | ||
| 10 | 10 | |
| 11 | 11 |  $d = sys_get_param_id('d'); | 
| 12 | 12 | |
| 13 | -if($d) { | |
| 13 | +if ($d) { | |
| 14 | 14 | db_ally_request_deny($d); | 
| 15 | 15 | } | 
| 16 | 16 | |
| 17 | 17 |  $id_user = sys_get_param_id('id_user'); | 
| 18 | 18 | |
| 19 | -if($id_user) { | |
| 19 | +if ($id_user) { | |
| 20 | 20 | $ally_name_safe = db_escape($ally['ally_name']); | 
| 21 | 21 | $ally_tag_safe = db_escape($ally['ally_tag']); | 
| 22 | -  DBStaticUser::db_user_set_by_id($id_user, "`ally_id` = '{$ally['id']}', `ally_name` = '{$ally_name_safe}', `ally_tag` = '{$ally_tag_safe}', `ally_register_time` = " . SN_TIME_NOW . ", `ally_rank_id` = 0"); | |
| 22 | +  DBStaticUser::db_user_set_by_id($id_user, "`ally_id` = '{$ally['id']}', `ally_name` = '{$ally_name_safe}', `ally_tag` = '{$ally_tag_safe}', `ally_register_time` = ".SN_TIME_NOW.", `ally_rank_id` = 0"); | |
| 23 | 23 | db_ally_update_member_increase($ally); | 
| 24 | 24 | db_ally_request_delete_by_user_id($id_user); | 
| 25 | 25 | } | 
| @@ -224,7 +224,7 @@ discard block | ||
| 224 | 224 | // Проверить наличие такого имени в истории имён | 
| 225 | 225 |        do { | 
| 226 | 226 | sn_db_transaction_rollback(); | 
| 227 | - $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000); | |
| 227 | + $this->player_suggested_name = 'Emperor '.mt_rand($max_user_id + 1, $max_user_id + 1000); | |
| 228 | 228 | sn_db_transaction_start(); | 
| 229 | 229 | } while (db_player_name_exists($this->player_suggested_name)); | 
| 230 | 230 | |
| @@ -233,7 +233,7 @@ discard block | ||
| 233 | 233 |      if ($player_name_submitted) { | 
| 234 | 234 | $this->register_player_db_create($this->player_suggested_name); // OK 4.5 | 
| 235 | 235 |        if ($this->register_status == LOGIN_SUCCESS) { | 
| 236 | - sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); | |
| 236 | + sys_redirect(SN_ROOT_VIRTUAL.'overview.php'); | |
| 237 | 237 |        } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { | 
| 238 | 238 | // self::$player_suggested_name .= ' ' . $this->account->account_id; | 
| 239 | 239 | } | 
| @@ -259,8 +259,8 @@ discard block | ||
| 259 | 259 | ); | 
| 260 | 260 | |
| 261 | 261 |      if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { | 
| 262 | -      $prohibited_characters = array_map(function ($value) { | |
| 263 | - return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; | |
| 262 | +      $prohibited_characters = array_map(function($value) { | |
| 263 | + return "'".htmlentities($value, ENT_QUOTES, 'UTF-8')."'"; | |
| 264 | 264 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); | 
| 265 | 265 |        $template_result[F_PLAYER_REGISTER_MESSAGE] .= implode(', ', $prohibited_characters); | 
| 266 | 266 | } | 
| @@ -307,7 +307,7 @@ discard block | ||
| 307 | 307 | |
| 308 | 308 |      foreach ($this->providers as $provider_id => $provider) { | 
| 309 | 309 | $login_status = $provider->login(); // OK v4.5 | 
| 310 | - self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); | |
| 310 | + self::flog(($provider->manifest['name'].'->'.'login_try - ').(empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); | |
| 311 | 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 | |
| @@ -347,7 +347,7 @@ discard block | ||
| 347 | 347 |          if (!$this->is_player_register) { | 
| 348 | 348 | // Нет - отправляем на процесс регистрации | 
| 349 | 349 |            $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id')); | 
| 350 | - sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : '')); | |
| 350 | + sys_redirect(SN_ROOT_VIRTUAL.'index.php?page=player_register&player_register=1'.($partner_id ? '&id_ref='.$partner_id : '')); | |
| 351 | 351 | } | 
| 352 | 352 |        } else { | 
| 353 | 353 | // Да, есть доступные игроки, которые так же прописаны в базе | 
| @@ -407,7 +407,7 @@ discard block | ||
| 407 | 407 | } | 
| 408 | 408 | |
| 409 | 409 |      if ($redirect === true) { | 
| 410 | - sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); | |
| 410 | + sys_redirect(SN_ROOT_RELATIVE.(empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); | |
| 411 | 411 |      } elseif ($redirect !== false) { | 
| 412 | 412 | sys_redirect($redirect); | 
| 413 | 413 | } | 
| @@ -702,7 +702,7 @@ discard block | ||
| 702 | 702 | $user['vacation'] = SN_TIME_NOW; | 
| 703 | 703 | } | 
| 704 | 704 | |
| 705 | - $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip']; | |
| 705 | + $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip']; | |
| 706 | 706 | $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain']; | 
| 707 | 707 | |
| 708 | 708 | $result[F_BANNED_STATUS] = $user['banaday']; | 
| @@ -710,9 +710,9 @@ discard block | ||
| 710 | 710 | |
| 711 | 711 | $proxy_safe = static::$db->db_escape(self::$device->ip_v4_proxy_chain); | 
| 712 | 712 | |
| 713 | - DBStaticUser::db_user_set_by_id($user['id'], "`onlinetime` = " . SN_TIME_NOW . ", | |
| 714 | - `banaday` = " . static::$db->db_escape($user['banaday']) . ", `vacation` = " . static::$db->db_escape($user['vacation']) . ", | |
| 715 | -      `user_lastip` = '" . static::$db->db_escape($user['user_lastip']) . "', `user_last_proxy` = '{$proxy_safe}', `user_last_browser_id` = " . self::$device->browser_id | |
| 713 | + DBStaticUser::db_user_set_by_id($user['id'], "`onlinetime` = ".SN_TIME_NOW.", | |
| 714 | + `banaday` = " . static::$db->db_escape($user['banaday']).", `vacation` = ".static::$db->db_escape($user['vacation']).", | |
| 715 | +      `user_lastip` = '" . static::$db->db_escape($user['user_lastip'])."', `user_last_proxy` = '{$proxy_safe}', `user_last_browser_id` = ".self::$device->browser_id | |
| 716 | 716 | ); | 
| 717 | 717 | } | 
| 718 | 718 | |
| @@ -805,7 +805,7 @@ discard block | ||
| 805 | 805 | */ | 
| 806 | 806 | // OK v4 | 
| 807 | 807 |    public static function password_encode($password, $salt) { | 
| 808 | - return md5($password . $salt); | |
| 808 | + return md5($password.$salt); | |
| 809 | 809 | } | 
| 810 | 810 | /** | 
| 811 | 811 | * Генерирует соль | 
| @@ -831,10 +831,10 @@ discard block | ||
| 831 | 831 | } | 
| 832 | 832 | list($called, $caller) = debug_backtrace(false); | 
| 833 | 833 | $caller_name = | 
| 834 | - (!empty($caller['class']) ? $caller['class'] : '') . | |
| 835 | - (!empty($caller['type']) ? $caller['type'] : '') . | |
| 836 | - (!empty($caller['function']) ? $caller['function'] : '') . | |
| 837 | - (!empty($called['line']) ? ':' . $called['line'] : ''); | |
| 834 | + (!empty($caller['class']) ? $caller['class'] : ''). | |
| 835 | + (!empty($caller['type']) ? $caller['type'] : ''). | |
| 836 | + (!empty($caller['function']) ? $caller['function'] : ''). | |
| 837 | + (!empty($called['line']) ? ':'.$called['line'] : ''); | |
| 838 | 838 | |
| 839 | 839 |      $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; | 
| 840 | 840 | |
| @@ -842,7 +842,7 @@ discard block | ||
| 842 | 842 |      if ($die) { | 
| 843 | 843 | // pdump($caller); | 
| 844 | 844 | // pdump(debug_backtrace(false)); | 
| 845 | -      $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); | |
| 845 | +      $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в ".get_called_class()." (располагается в ".get_class()."). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); | |
| 846 | 846 | } | 
| 847 | 847 | } | 
| 848 | 848 | |