| @@ -12,7 +12,7 @@ discard block | ||
| 12 | 12 | |
| 13 | 13 |  include('common.' . substr(strrchr(__FILE__, '.'), 1)); | 
| 14 | 14 | |
| 15 | -if(classSupernova::$config->game_mode == GAME_BLITZ) { | |
| 15 | +if (classSupernova::$config->game_mode == GAME_BLITZ) { | |
| 16 | 16 | message(classLocale::$lang['sys_blitz_page_disabled'], classLocale::$lang['sys_error'], 'overview.php', 10); | 
| 17 | 17 | die(); | 
| 18 | 18 | } | 
| @@ -25,8 +25,8 @@ discard block | ||
| 25 | 25 | |
| 26 | 26 |  $template = gettemplate('search', true); | 
| 27 | 27 | |
| 28 | -if($searchtext && $type) { | |
| 29 | -  switch($type) { | |
| 28 | +if ($searchtext && $type) { | |
| 29 | +  switch ($type) { | |
| 30 | 30 | case "planetname": | 
| 31 | 31 | // $search = db_planet_list_search($searchtext); | 
| 32 | 32 | break; | 
| @@ -41,8 +41,8 @@ discard block | ||
| 41 | 41 | break; | 
| 42 | 42 | } | 
| 43 | 43 | |
| 44 | -  while($row = db_fetch($search)) { | |
| 45 | -    if($type == 'playername' || $type == 'planetname') { | |
| 44 | +  while ($row = db_fetch($search)) { | |
| 45 | +    if ($type == 'playername' || $type == 'planetname') { | |
| 46 | 46 |        $template->assign_block_vars('search_result', array( | 
| 47 | 47 | 'PLAYER_ID' => $row['uid'], | 
| 48 | 48 | 'PLAYER_NAME' => htmlentities($row['username'], ENT_COMPAT, 'UTF-8'), | 
| @@ -57,7 +57,7 @@ discard block | ||
| 57 | 57 | 'ALLY_NAME' => htmlentities($row['ally_name'], ENT_COMPAT, 'UTF-8'), | 
| 58 | 58 | 'ALLY_TAG' => htmlentities($row['ally_tag'], ENT_COMPAT, 'UTF-8'), | 
| 59 | 59 | )); | 
| 60 | -    } elseif($type == 'ally') { | |
| 60 | +    } elseif ($type == 'ally') { | |
| 61 | 61 |        $template->assign_block_vars('search_result', array( | 
| 62 | 62 | 'ALLY_NAME' => htmlentities($row['ally_name'], ENT_COMPAT, 'UTF-8'), | 
| 63 | 63 | 'ALLY_TAG' => htmlentities($row['ally_tag'], ENT_COMPAT, 'UTF-8'), | 
| @@ -75,7 +75,7 @@ discard block | ||
| 75 | 75 | 'ally' => 'sys_alliance', | 
| 76 | 76 | ); | 
| 77 | 77 | |
| 78 | -foreach($search_type as $type_id => $type_lang) { | |
| 78 | +foreach ($search_type as $type_id => $type_lang) { | |
| 79 | 79 |    $template->assign_block_vars('type', array( | 
| 80 | 80 | 'ID' => $type_id, | 
| 81 | 81 | 'TEXT' => classLocale::$lang[$type_lang], | 
| @@ -26,7 +26,7 @@ | ||
| 26 | 26 | 'GROUP BY `unit_snid`' | 
| 27 | 27 | ); | 
| 28 | 28 | $result = array(); | 
| 29 | -  while($row = db_fetch($query)) { | |
| 29 | +  while ($row = db_fetch($query)) { | |
| 30 | 30 | $result[$row['unit_snid']] = $row; | 
| 31 | 31 | } | 
| 32 | 32 | |
| @@ -1,6 +1,6 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -if(!defined('IN_UPDATE')) { | |
| 3 | +if (!defined('IN_UPDATE')) { | |
| 4 | 4 |    die('Trying to call update helpers externally!'); | 
| 5 | 5 | } | 
| 6 | 6 | |
| @@ -8,13 +8,13 @@ discard block | ||
| 8 | 8 | global $update_tables; | 
| 9 | 9 | |
| 10 | 10 | upd_add_more_time(); | 
| 11 | -  if(!$no_log) { | |
| 11 | +  if (!$no_log) { | |
| 12 | 12 |      upd_log_message("Performing query '{$query}'"); | 
| 13 | 13 | } | 
| 14 | 14 | |
| 15 | 15 | // classSupernova::$db->sn_db_connect(); | 
| 16 | -  if(!(strpos($query, '{{') === false)) { | |
| 17 | -    foreach($update_tables as $tableName => $cork) { | |
| 16 | +  if (!(strpos($query, '{{') === false)) { | |
| 17 | +    foreach ($update_tables as $tableName => $cork) { | |
| 18 | 18 |        $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix . $tableName, $query); | 
| 19 | 19 | } | 
| 20 | 20 | } | 
| @@ -27,9 +27,9 @@ discard block | ||
| 27 | 27 | global $sys_log_disabled; | 
| 28 | 28 | |
| 29 | 29 | classSupernova::$config->db_loadItem($key); | 
| 30 | -  if($condition || !isset(classSupernova::$config->$key)) { | |
| 30 | +  if ($condition || !isset(classSupernova::$config->$key)) { | |
| 31 | 31 | upd_add_more_time(); | 
| 32 | -    if(!$sys_log_disabled) { | |
| 32 | +    if (!$sys_log_disabled) { | |
| 33 | 33 |        upd_log_message("Updating config key '{$key}' with value '{$default_value}'"); | 
| 34 | 34 | } | 
| 35 | 35 | classSupernova::$config->db_saveItem($key, $default_value); | 
| @@ -57,7 +57,7 @@ discard block | ||
| 57 | 57 |  function upd_log_message($message) { | 
| 58 | 58 | global $sys_log_disabled, $upd_log, $debug; | 
| 59 | 59 | |
| 60 | -  if($sys_log_disabled) { | |
| 60 | +  if ($sys_log_disabled) { | |
| 61 | 61 |  //    print("{$message}<br />"); | 
| 62 | 62 |    } else { | 
| 63 | 63 |      $upd_log .= "{$message}\r\n"; | 
| @@ -68,15 +68,15 @@ discard block | ||
| 68 | 68 |  function upd_unset_table_info($table_name) { | 
| 69 | 69 | global $update_tables, $update_indexes, $update_foreigns; | 
| 70 | 70 | |
| 71 | -  if(isset($update_tables[$table_name])) { | |
| 71 | +  if (isset($update_tables[$table_name])) { | |
| 72 | 72 | unset($update_tables[$table_name]); | 
| 73 | 73 | } | 
| 74 | 74 | |
| 75 | -  if(isset($update_indexes[$table_name])) { | |
| 75 | +  if (isset($update_indexes[$table_name])) { | |
| 76 | 76 | unset($update_indexes[$table_name]); | 
| 77 | 77 | } | 
| 78 | 78 | |
| 79 | -  if(isset($update_foreigns[$table_name])) { | |
| 79 | +  if (isset($update_foreigns[$table_name])) { | |
| 80 | 80 | unset($update_foreigns[$table_name]); | 
| 81 | 81 | } | 
| 82 | 82 | } | 
| @@ -90,18 +90,18 @@ discard block | ||
| 90 | 90 | upd_unset_table_info($tableName); | 
| 91 | 91 | |
| 92 | 92 |    $q1 = upd_do_query("SHOW FULL COLUMNS FROM {$prefix_table_name};", true); | 
| 93 | -  while($r1 = db_fetch($q1)) { | |
| 93 | +  while ($r1 = db_fetch($q1)) { | |
| 94 | 94 | $update_tables[$tableName][$r1['Field']] = $r1; | 
| 95 | 95 | } | 
| 96 | 96 | |
| 97 | 97 |    $q1 = upd_do_query("SHOW INDEX FROM {$prefix_table_name};", true); | 
| 98 | -  while($r1 = db_fetch($q1)) { | |
| 98 | +  while ($r1 = db_fetch($q1)) { | |
| 99 | 99 |      $update_indexes[$tableName][$r1['Key_name']] .= "{$r1['Column_name']},"; | 
| 100 | 100 | $update_indexes_full[$tableName][$r1['Key_name']][$r1['Column_name']] = $r1; | 
| 101 | 101 | } | 
| 102 | 102 | |
| 103 | 103 |    $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true); | 
| 104 | -  while($r1 = db_fetch($q1)) { | |
| 104 | +  while ($r1 = db_fetch($q1)) { | |
| 105 | 105 | $table_referenced = str_replace(classSupernova::$config->db_prefix, '', $r1['REFERENCED_TABLE_NAME']); | 
| 106 | 106 | |
| 107 | 107 |      $update_foreigns[$tableName][$r1['CONSTRAINT_NAME']] .= "{$r1['COLUMN_NAME']},{$table_referenced},{$r1['REFERENCED_COLUMN_NAME']};"; | 
| @@ -116,7 +116,7 @@ discard block | ||
| 116 | 116 | * @return bool|mysqli_result|void | 
| 117 | 117 | */ | 
| 118 | 118 |  function upd_alter_table($table, $alters, $condition = true) { | 
| 119 | -  if(!$condition) { | |
| 119 | +  if (!$condition) { | |
| 120 | 120 | return; | 
| 121 | 121 | } | 
| 122 | 122 | |
| @@ -124,7 +124,7 @@ discard block | ||
| 124 | 124 | $alters_print = is_array($alters) ? dump($alters) : $alters; | 
| 125 | 125 |    upd_log_message("Altering table '{$table}' with alterations {$alters_print}"); | 
| 126 | 126 | |
| 127 | -  if(!is_array($alters)) { | |
| 127 | +  if (!is_array($alters)) { | |
| 128 | 128 | $alters = array($alters); | 
| 129 | 129 | } | 
| 130 | 130 | |
| @@ -133,7 +133,7 @@ discard block | ||
| 133 | 133 | |
| 134 | 134 | $result = upd_do_query($qry); | 
| 135 | 135 | $error = db_error(); | 
| 136 | -  if($error) { | |
| 136 | +  if ($error) { | |
| 137 | 137 |      die("Altering error for table `{$table}`: {$error}<br />{$alters_print}"); | 
| 138 | 138 | } | 
| 139 | 139 | |
| @@ -152,12 +152,12 @@ discard block | ||
| 152 | 152 |  function upd_create_table($table_name, $declaration) { | 
| 153 | 153 | global $update_tables; | 
| 154 | 154 | |
| 155 | -  if(!$update_tables[$table_name]) { | |
| 155 | +  if (!$update_tables[$table_name]) { | |
| 156 | 156 |      upd_do_query('set foreign_key_checks = 0;', true); | 
| 157 | 157 | $db_prefix = classSupernova::$config->db_prefix; | 
| 158 | 158 |      $result = upd_do_query("CREATE TABLE IF NOT EXISTS `{$db_prefix}{$table_name}` {$declaration}"); | 
| 159 | 159 | $error = db_error(); | 
| 160 | -    if($error) { | |
| 160 | +    if ($error) { | |
| 161 | 161 |        die("Creating error for table `{$table_name}`: {$error}<br />" . dump($declaration)); | 
| 162 | 162 | } | 
| 163 | 163 |      upd_do_query('set foreign_key_checks = 1;', true); | 
| @@ -183,14 +183,14 @@ discard block | ||
| 183 | 183 | |
| 184 | 184 | |
| 185 | 185 |  function upd_db_unit_changeset_prepare($unit_id, $unit_value, $user, $planet_id = null) { | 
| 186 | -  if(!is_array($user)) { | |
| 186 | +  if (!is_array($user)) { | |
| 187 | 187 | // TODO - remove later | 
| 188 | 188 |      print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER is not ARRAY</h1>'); | 
| 189 | 189 | pdump(debug_backtrace()); | 
| 190 | 190 |      die('USER is not ARRAY'); | 
| 191 | 191 | } | 
| 192 | 192 | |
| 193 | -  if(!isset($user['id']) || !$user['id']) { | |
| 193 | +  if (!isset($user['id']) || !$user['id']) { | |
| 194 | 194 | // TODO - remove later | 
| 195 | 195 |      print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER[id] пустой</h1>'); | 
| 196 | 196 | pdump($user); | 
| @@ -205,7 +205,7 @@ discard block | ||
| 205 | 205 | |
| 206 | 206 | $db_changeset = array(); | 
| 207 | 207 | $temp = upd_db_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id'); | 
| 208 | -  if($temp['unit_id']) { | |
| 208 | +  if ($temp['unit_id']) { | |
| 209 | 209 | // update | 
| 210 | 210 | $db_changeset = array( | 
| 211 | 211 | 'action' => SQL_OP_UPDATE, | 
| @@ -250,41 +250,41 @@ discard block | ||
| 250 | 250 | |
| 251 | 251 | |
| 252 | 252 |  function upd_db_changeset_apply($db_changeset) { | 
| 253 | -  if(!is_array($db_changeset) || empty($db_changeset)) { | |
| 253 | +  if (!is_array($db_changeset) || empty($db_changeset)) { | |
| 254 | 254 | return; | 
| 255 | 255 | } | 
| 256 | 256 | |
| 257 | -  foreach($db_changeset as $table_name => $table_data) { | |
| 258 | -    foreach($table_data as $record_id => $conditions) { | |
| 257 | +  foreach ($db_changeset as $table_name => $table_data) { | |
| 258 | +    foreach ($table_data as $record_id => $conditions) { | |
| 259 | 259 | $where = ''; | 
| 260 | -      if(!empty($conditions['where'])) { | |
| 260 | +      if (!empty($conditions['where'])) { | |
| 261 | 261 |          $where = 'WHERE ' . implode(' AND ', $conditions['where']); | 
| 262 | 262 | } | 
| 263 | 263 | |
| 264 | 264 | $fields = array(); | 
| 265 | -      if($conditions['fields']) { | |
| 266 | -        foreach($conditions['fields'] as $field_name => $field_data) { | |
| 265 | +      if ($conditions['fields']) { | |
| 266 | +        foreach ($conditions['fields'] as $field_name => $field_data) { | |
| 267 | 267 |            $condition = "`{$field_name}` = "; | 
| 268 | 268 | $value = ''; | 
| 269 | -          if($field_data['delta']) { | |
| 269 | +          if ($field_data['delta']) { | |
| 270 | 270 |              $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; | 
| 271 | -          } elseif($field_data['set']) { | |
| 271 | +          } elseif ($field_data['set']) { | |
| 272 | 272 |              $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); | 
| 273 | 273 | } | 
| 274 | -          if($value) { | |
| 274 | +          if ($value) { | |
| 275 | 275 | $fields[] = $condition . $value; | 
| 276 | 276 | } | 
| 277 | 277 | } | 
| 278 | 278 | } | 
| 279 | 279 |        $fields = implode(',', $fields); | 
| 280 | 280 | |
| 281 | -      switch($conditions['action']) { | |
| 281 | +      switch ($conditions['action']) { | |
| 282 | 282 | case SQL_OP_DELETE: | 
| 283 | 283 |            upd_do_query("DELETE FROM {{{$table_name}}} {$where}"); | 
| 284 | 284 | break; | 
| 285 | 285 | |
| 286 | 286 | case SQL_OP_UPDATE: | 
| 287 | -          if($fields) { | |
| 287 | +          if ($fields) { | |
| 288 | 288 | /*if($table_name == 'unit') | 
| 289 | 289 |              { | 
| 290 | 290 |                pdump("UPDATE {{{$table_name}}} SET {$fields} {$where}"); | 
| @@ -295,13 +295,13 @@ discard block | ||
| 295 | 295 | break; | 
| 296 | 296 | |
| 297 | 297 | case SQL_OP_INSERT: | 
| 298 | -          if($fields) { | |
| 298 | +          if ($fields) { | |
| 299 | 299 |              upd_do_query("INSERT INTO {{{$table_name}}} SET {$fields}"); | 
| 300 | 300 | } | 
| 301 | 301 | break; | 
| 302 | 302 | |
| 303 | 303 | case SQL_OP_REPLACE: | 
| 304 | -          if($fields) { | |
| 304 | +          if ($fields) { | |
| 305 | 305 |              upd_do_query("REPLACE INTO {{{$table_name}}} SET {$fields}"); | 
| 306 | 306 | } | 
| 307 | 307 | break; | 
| @@ -2,7 +2,7 @@ discard block | ||
| 2 | 2 | |
| 3 | 3 | $classLocale = classLocale::$lang; | 
| 4 | 4 | |
| 5 | -if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) | |
| 5 | +if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) | |
| 6 | 6 |  { | 
| 7 | 7 |    $debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403); | 
| 8 | 8 | } | 
| @@ -17,50 +17,50 @@ discard block | ||
| 17 | 17 | )); | 
| 18 | 18 | |
| 19 | 19 |  $info_action = sys_get_param_int('action'); | 
| 20 | -if($info_action) | |
| 20 | +if ($info_action) | |
| 21 | 21 |  { | 
| 22 | 22 | try | 
| 23 | 23 |    { | 
| 24 | 24 | sn_db_transaction_start(); | 
| 25 | 25 | |
| 26 | 26 | $user = db_user_by_id($user['id'], true); | 
| 27 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->rpg_cost_info) | |
| 27 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->rpg_cost_info) | |
| 28 | 28 |      { | 
| 29 | 29 | throw new Exception(MARKET_NO_DM, ERR_ERROR); | 
| 30 | 30 | } | 
| 31 | 31 | |
| 32 | - switch($info_action) | |
| 32 | + switch ($info_action) | |
| 33 | 33 |      { | 
| 34 | 34 | case MARKET_INFO_PLAYER: | 
| 35 | 35 |          $user_info_name_unsafe = sys_get_param_str_unsafe('user_info_name'); | 
| 36 | - if(!$user_info_name_unsafe) | |
| 36 | + if (!$user_info_name_unsafe) | |
| 37 | 37 |          { | 
| 38 | 38 | throw new Exception(MARKET_INFO_PLAYER_WRONG, ERR_ERROR); | 
| 39 | 39 | } | 
| 40 | 40 | |
| 41 | - if(is_id($user_info_name_unsafe)) | |
| 41 | + if (is_id($user_info_name_unsafe)) | |
| 42 | 42 |          { | 
| 43 | 43 | $user_info = db_user_by_id($user_info_name_unsafe, true, '`id`, `username`', true); | 
| 44 | 44 | } | 
| 45 | - if(!is_array($user_info)) | |
| 45 | + if (!is_array($user_info)) | |
| 46 | 46 |          { | 
| 47 | 47 | $user_info = db_user_by_username($user_info_name_unsafe, true, '`id`, `username`', true, true); | 
| 48 | 48 | } | 
| 49 | - if(!is_array($user_info)) | |
| 49 | + if (!is_array($user_info)) | |
| 50 | 50 |          { | 
| 51 | 51 | throw new Exception(MARKET_INFO_PLAYER_NOT_FOUND, ERR_ERROR); | 
| 52 | 52 | } | 
| 53 | - if($user_info['id'] == $user['id']) | |
| 53 | + if ($user_info['id'] == $user['id']) | |
| 54 | 54 |          { | 
| 55 | 55 | throw new Exception(MARKET_INFO_PLAYER_SAME, ERR_ERROR); | 
| 56 | 56 | } | 
| 57 | 57 | |
| 58 | 58 | $msg_text = array(); | 
| 59 | -        foreach(sn_get_groups('mercenaries') as $mercenary_id) | |
| 59 | +        foreach (sn_get_groups('mercenaries') as $mercenary_id) | |
| 60 | 60 |          { | 
| 61 | 61 |            $msg_text[] = "{$classLocale['tech'][$mercenary_id]} - " . (($mercenary_level = mrc_get_level($user_info, null, $mercenary_id)) ? "{$classLocale['sys_level']} {$mercenary_level}" : classLocale::$lang['eco_mrk_info_not_hired']); | 
| 62 | 62 | } | 
| 63 | - if($mercenary_level = mrc_get_level($user_info, null, UNIT_PREMIUM)) | |
| 63 | + if ($mercenary_level = mrc_get_level($user_info, null, UNIT_PREMIUM)) | |
| 64 | 64 |          { | 
| 65 | 65 |            $msg_text[] = "{$classLocale['tech'][UNIT_PREMIUM]} - {$mercenary_level} {$classLocale['sys_level']}"; | 
| 66 | 66 | } | 
| @@ -74,7 +74,7 @@ discard block | ||
| 74 | 74 | break; | 
| 75 | 75 | } | 
| 76 | 76 | |
| 77 | -    if(!rpg_points_change($user['id'], RPG_MARKET_INFO_MERCENARY, -classSupernova::$config->rpg_cost_info, "Using Black Market page {$classLocale['eco_mrk_info']} - getting info about user ID {$user_info['id']}")) | |
| 77 | +    if (!rpg_points_change($user['id'], RPG_MARKET_INFO_MERCENARY, -classSupernova::$config->rpg_cost_info, "Using Black Market page {$classLocale['eco_mrk_info']} - getting info about user ID {$user_info['id']}")) | |
| 78 | 78 |      { | 
| 79 | 79 | // TODO: throw new Exception(MARKET_INFO_PLAYER_SAME, ERR_ERROR); | 
| 80 | 80 | } | 
| @@ -3,7 +3,7 @@ discard block | ||
| 3 | 3 | // @version 1.0 | 
| 4 | 4 | // @copyright 2008 by Chlorel for XNova | 
| 5 | 5 | |
| 6 | -if(SN_IN_FLEET !== true) { | |
| 6 | +if (SN_IN_FLEET !== true) { | |
| 7 | 7 |    $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); | 
| 8 | 8 | } | 
| 9 | 9 | |
| @@ -20,25 +20,25 @@ discard block | ||
| 20 | 20 | |
| 21 | 21 | // Test de coherance de la destination (voir si elle se trouve dans les limites de l'univers connu | 
| 22 | 22 | $errorlist = ''; | 
| 23 | -  if(!$galaxy || $galaxy > classSupernova::$config->game_maxGalaxy || $galaxy < 1) { | |
| 23 | +  if (!$galaxy || $galaxy > classSupernova::$config->game_maxGalaxy || $galaxy < 1) { | |
| 24 | 24 | $errorlist .= classLocale::$lang['fl_limit_galaxy']; | 
| 25 | 25 | } | 
| 26 | -  if(!$system || $system > classSupernova::$config->game_maxSystem || $system < 1) { | |
| 26 | +  if (!$system || $system > classSupernova::$config->game_maxSystem || $system < 1) { | |
| 27 | 27 | $errorlist .= classLocale::$lang['fl_limit_system']; | 
| 28 | 28 | } | 
| 29 | -  if(!$planet || $planet < 1 || ($planet > classSupernova::$config->game_maxPlanet && $target_mission != MT_EXPLORE)) { | |
| 29 | +  if (!$planet || $planet < 1 || ($planet > classSupernova::$config->game_maxPlanet && $target_mission != MT_EXPLORE)) { | |
| 30 | 30 | $errorlist .= classLocale::$lang['fl_limit_planet']; | 
| 31 | 31 | } | 
| 32 | -  if($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) { | |
| 32 | +  if ($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) { | |
| 33 | 33 | $errorlist .= classLocale::$lang['fl_ownpl_err']; | 
| 34 | 34 | } | 
| 35 | -  if(!$planet_type) { | |
| 35 | +  if (!$planet_type) { | |
| 36 | 36 | $errorlist .= classLocale::$lang['fl_no_planettype']; | 
| 37 | 37 | } | 
| 38 | -  if($planet_type != PT_PLANET && $planet_type != PT_DEBRIS && $planet_type != PT_MOON) { | |
| 38 | +  if ($planet_type != PT_PLANET && $planet_type != PT_DEBRIS && $planet_type != PT_MOON) { | |
| 39 | 39 | $errorlist .= classLocale::$lang['fl_fleet_err_pl']; | 
| 40 | 40 | } | 
| 41 | -  if(empty($missiontype[$target_mission])) { | |
| 41 | +  if (empty($missiontype[$target_mission])) { | |
| 42 | 42 | $errorlist .= classLocale::$lang['fl_bad_mission']; | 
| 43 | 43 | } | 
| 44 | 44 | |
| @@ -47,7 +47,7 @@ discard block | ||
| 47 | 47 |    $TransDeuterium = max(0, sys_get_param_float('resource2')); | 
| 48 | 48 | $StorageNeeded = $TransMetal + $TransCrystal + $TransDeuterium; | 
| 49 | 49 | |
| 50 | -  if(!$StorageNeeded && $target_mission == MT_TRANSPORT) { | |
| 50 | +  if (!$StorageNeeded && $target_mission == MT_TRANSPORT) { | |
| 51 | 51 | $errorlist .= classLocale::$lang['fl_noenoughtgoods']; | 
| 52 | 52 | } | 
| 53 | 53 | |
| @@ -56,41 +56,41 @@ discard block | ||
| 56 | 56 | $user = db_user_by_id($user['id'], true); | 
| 57 | 57 | $planetrow = db_planet_by_id($planetrow['id'], true); | 
| 58 | 58 | |
| 59 | -  if($target_mission == MT_EXPLORE) { | |
| 60 | -    if($MaxExpeditions == 0) { | |
| 59 | +  if ($target_mission == MT_EXPLORE) { | |
| 60 | +    if ($MaxExpeditions == 0) { | |
| 61 | 61 | $errorlist .= classLocale::$lang['fl_expe_notech']; | 
| 62 | -    } elseif($FlyingExpeditions >= $MaxExpeditions) { | |
| 62 | +    } elseif ($FlyingExpeditions >= $MaxExpeditions) { | |
| 63 | 63 | $errorlist .= classLocale::$lang['fl_expe_max']; | 
| 64 | 64 | } | 
| 65 | 65 |    } else { | 
| 66 | -    if($TargetPlanet['id_owner']) { | |
| 67 | -      if($target_mission == MT_COLONIZE) { | |
| 66 | +    if ($TargetPlanet['id_owner']) { | |
| 67 | +      if ($target_mission == MT_COLONIZE) { | |
| 68 | 68 | $errorlist .= classLocale::$lang['fl_colonized']; | 
| 69 | 69 | } | 
| 70 | 70 | |
| 71 | -      if($TargetPlanet['id_owner'] == $planetrow['id_owner']) { | |
| 72 | -        if($target_mission == MT_ATTACK) { | |
| 71 | +      if ($TargetPlanet['id_owner'] == $planetrow['id_owner']) { | |
| 72 | +        if ($target_mission == MT_ATTACK) { | |
| 73 | 73 | $errorlist .= classLocale::$lang['fl_no_self_attack']; | 
| 74 | 74 | } | 
| 75 | 75 | |
| 76 | -        if($target_mission == MT_SPY) { | |
| 76 | +        if ($target_mission == MT_SPY) { | |
| 77 | 77 | $errorlist .= classLocale::$lang['fl_no_self_spy']; | 
| 78 | 78 | } | 
| 79 | 79 |        } else { | 
| 80 | -        if($target_mission == MT_RELOCATE) { | |
| 80 | +        if ($target_mission == MT_RELOCATE) { | |
| 81 | 81 | $errorlist .= classLocale::$lang['fl_only_stay_at_home']; | 
| 82 | 82 | } | 
| 83 | 83 | } | 
| 84 | 84 |      } else { | 
| 85 | -      if($target_mission < MT_COLONIZE) { | |
| 85 | +      if ($target_mission < MT_COLONIZE) { | |
| 86 | 86 | $errorlist .= classLocale::$lang['fl_unknow_target']; | 
| 87 | 87 |        } else { | 
| 88 | -        if($target_mission == MT_DESTROY) { | |
| 88 | +        if ($target_mission == MT_DESTROY) { | |
| 89 | 89 | $errorlist .= classLocale::$lang['fl_nomoon']; | 
| 90 | 90 | } | 
| 91 | 91 | |
| 92 | -        if($target_mission == MT_RECYCLE) { | |
| 93 | -          if($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) { | |
| 92 | +        if ($target_mission == MT_RECYCLE) { | |
| 93 | +          if ($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) { | |
| 94 | 94 | $errorlist .= classLocale::$lang['fl_nodebris']; | 
| 95 | 95 | } | 
| 96 | 96 | } | 
| @@ -99,13 +99,13 @@ discard block | ||
| 99 | 99 | } | 
| 100 | 100 | |
| 101 | 101 | |
| 102 | -  if(sn_module::$sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) { | |
| 102 | +  if (sn_module::$sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) { | |
| 103 | 103 | $captain = sn_module::$sn_module['unit_captain']->unit_captain_get($planetrow['id']); | 
| 104 | 104 | // mrc_get_level($user, $planetrow, UNIT_CAPTAIN, true); | 
| 105 | -    if(!$captain) { | |
| 105 | +    if (!$captain) { | |
| 106 | 106 | $errorlist .= classLocale::$lang['module_unit_captain_error_no_captain']; | 
| 107 | -    } elseif($captain['unit_location_type'] == LOC_PLANET) { | |
| 108 | -      if($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) { | |
| 107 | +    } elseif ($captain['unit_location_type'] == LOC_PLANET) { | |
| 108 | +      if ($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) { | |
| 109 | 109 | $errorlist .= classLocale::$lang['module_unit_captain_error_captain_already_bound']; | 
| 110 | 110 | } | 
| 111 | 111 |      } else { | 
| @@ -113,14 +113,14 @@ discard block | ||
| 113 | 113 | } | 
| 114 | 114 | } | 
| 115 | 115 | |
| 116 | -  if($errorlist) { | |
| 116 | +  if ($errorlist) { | |
| 117 | 117 | sn_db_transaction_rollback(); | 
| 118 | 118 |      message("<span class='error'><ul>{$errorlist}</ul></span>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, false); | 
| 119 | 119 | } | 
| 120 | 120 | |
| 121 | 121 | // On verifie s'il y a assez de vaisseaux sur la planete ! | 
| 122 | -  foreach($fleetarray as $Ship => $Count) { | |
| 123 | -    if($Count > mrc_get_level($user, $planetrow, $Ship)) { | |
| 122 | +  foreach ($fleetarray as $Ship => $Count) { | |
| 123 | +    if ($Count > mrc_get_level($user, $planetrow, $Ship)) { | |
| 124 | 124 |        message("<span class='error'><b>{$classLocale['fl_fleet_err']}</b></span>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); | 
| 125 | 125 | } | 
| 126 | 126 | } | 
| @@ -131,10 +131,10 @@ discard block | ||
| 131 | 131 | //But is it acs?? | 
| 132 | 132 | //Well all acs fleets must have a fleet code. | 
| 133 | 133 | //The co-ords must be the same as where the acs fleet is going. | 
| 134 | -  if($fleet_group && sys_get_param_str('acs_target_mr') == "g{$galaxy}s{$system}p{$planet}t{$planet_type}") { | |
| 134 | +  if ($fleet_group && sys_get_param_str('acs_target_mr') == "g{$galaxy}s{$system}p{$planet}t{$planet_type}") { | |
| 135 | 135 | //ACS attack must exist (if acs fleet has arrived this will also return false (2 checks in 1!!!) | 
| 136 | 136 | $aks = db_acs_get_by_group_id($fleet_group); | 
| 137 | -    if(!$aks) { | |
| 137 | +    if (!$aks) { | |
| 138 | 138 | $fleet_group = 0; | 
| 139 | 139 |      } else { | 
| 140 | 140 | //Also it must be mission type 2 | 
| @@ -145,31 +145,31 @@ discard block | ||
| 145 | 145 | $planet = $aks['planet']; | 
| 146 | 146 | $planet_type = $aks['planet_type']; | 
| 147 | 147 | } | 
| 148 | -  } elseif($target_mission == MT_AKS) { | |
| 148 | +  } elseif ($target_mission == MT_AKS) { | |
| 149 | 149 | //Check that a failed acs attack isn't being sent, if it is, make it an attack fleet. | 
| 150 | 150 | $target_mission = MT_ATTACK; | 
| 151 | 151 | } | 
| 152 | 152 | |
| 153 | -  if($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) { | |
| 153 | +  if ($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) { | |
| 154 | 154 |      $TargetPlanet = array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet, 'id_owner' => 0); | 
| 155 | 155 | } | 
| 156 | 156 |    $options = array('fleet_speed_percent' => $speed_percent, 'fleet_group' => $fleet_group, 'resources' => $StorageNeeded); | 
| 157 | 157 | $cant_attack = flt_can_attack($planetrow, $TargetPlanet, $fleetarray, $target_mission, $options); | 
| 158 | 158 | |
| 159 | -  if($cant_attack !== ATTACK_ALLOWED) { | |
| 159 | +  if ($cant_attack !== ATTACK_ALLOWED) { | |
| 160 | 160 |      message("<span class='error'><b>{$classLocale['fl_attack_error'][$cant_attack]}</b></span>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 99); | 
| 161 | 161 | } | 
| 162 | 162 | |
| 163 | 163 | $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1); | 
| 164 | -  if(!in_array($speed_percent, $speed_possible)) { | |
| 164 | +  if (!in_array($speed_percent, $speed_possible)) { | |
| 165 | 165 |      message("<span class='error'><b>" . classLocale::$lang['fl_cheat_speed'] . "</b></span>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); | 
| 166 | 166 | } | 
| 167 | 167 | |
| 168 | 168 | $mission_time_in_seconds = 0; | 
| 169 | 169 | $arrival_time = SN_TIME_NOW + $time_to_travel; | 
| 170 | -  if($target_mission == MT_AKS && $aks) { | |
| 170 | +  if ($target_mission == MT_AKS && $aks) { | |
| 171 | 171 |  //    if($fleet_start_time > $aks['ankunft']) { | 
| 172 | -    if($arrival_time > $aks['ankunft']) { | |
| 172 | +    if ($arrival_time > $aks['ankunft']) { | |
| 173 | 173 | message(classLocale::$lang['fl_aks_too_slow'] . 'Fleet arrival: ' . date(FMT_DATE_TIME, $arrival_time) . " AKS arrival: " . date(FMT_DATE_TIME, $aks['ankunft']), classLocale::$lang['fl_error']); | 
| 174 | 174 | } | 
| 175 | 175 | $group_sync_delta_time = $aks['ankunft'] - $arrival_time; | 
| @@ -178,11 +178,11 @@ discard block | ||
| 178 | 178 | // Set return time to ACS return time + fleet's time to travel | 
| 179 | 179 | $return_time = $aks['ankunft'] + $time_to_travel; | 
| 180 | 180 |    } else { | 
| 181 | -    if($target_mission == MT_EXPLORE || $target_mission == MT_HOLD) { | |
| 181 | +    if ($target_mission == MT_EXPLORE || $target_mission == MT_HOLD) { | |
| 182 | 182 | $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : ($target_mission == MT_HOLD ? 12 : 0); | 
| 183 | -      if($max_duration) { | |
| 183 | +      if ($max_duration) { | |
| 184 | 184 |          $mission_time_in_hours = sys_get_param_id('missiontime'); | 
| 185 | -        if($mission_time_in_hours > $max_duration || $mission_time_in_hours < 1) { | |
| 185 | +        if ($mission_time_in_hours > $max_duration || $mission_time_in_hours < 1) { | |
| 186 | 186 |            $debug->warning('Supplying wrong mission time', 'Hack attempt', 302, array('base_dump' => true)); | 
| 187 | 187 | die(); | 
| 188 | 188 | } | 
| @@ -196,19 +196,19 @@ discard block | ||
| 196 | 196 | $FleetStorage = 0; | 
| 197 | 197 | |
| 198 | 198 | $db_changeset = array(); | 
| 199 | -  foreach($fleetarray as $Ship => $Count) { | |
| 199 | +  foreach ($fleetarray as $Ship => $Count) { | |
| 200 | 200 | $FleetStorage += get_unit_param($Ship, P_CAPACITY) * $Count; | 
| 201 | 201 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($Ship, -$Count, $user, $planetrow['id']); | 
| 202 | 202 | } | 
| 203 | 203 | $FleetStorage -= $consumption; | 
| 204 | 204 | |
| 205 | -  if($StorageNeeded > $FleetStorage) { | |
| 205 | +  if ($StorageNeeded > $FleetStorage) { | |
| 206 | 206 |      message("<span class='error'><b>" . classLocale::$lang['fl_nostoragespa'] . pretty_number($StorageNeeded - $FleetStorage) . "</b></span>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); | 
| 207 | 207 | } | 
| 208 | -  if($planetrow['deuterium'] < $TransDeuterium + $consumption) { | |
| 208 | +  if ($planetrow['deuterium'] < $TransDeuterium + $consumption) { | |
| 209 | 209 |      message("<font color=\"red\"><b>" . classLocale::$lang['fl_no_deuterium'] . pretty_number($TransDeuterium + $consumption - $planetrow['deuterium']) . "</b></font>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); | 
| 210 | 210 | } | 
| 211 | -  if(($planetrow['metal'] < $TransMetal) || ($planetrow['crystal'] < $TransCrystal)) { | |
| 211 | +  if (($planetrow['metal'] < $TransMetal) || ($planetrow['crystal'] < $TransCrystal)) { | |
| 212 | 212 |      message("<font color=\"red\"><b>" . classLocale::$lang['fl_no_resources'] . "</b></font>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); | 
| 213 | 213 | } | 
| 214 | 214 | |
| @@ -238,7 +238,7 @@ discard block | ||
| 238 | 238 | |
| 239 | 239 |    $template = gettemplate('fleet3', true); | 
| 240 | 240 | |
| 241 | -  if(is_array($captain)) { | |
| 241 | +  if (is_array($captain)) { | |
| 242 | 242 |      db_unit_set_by_id($captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$objFleet->dbId}"); | 
| 243 | 243 | } | 
| 244 | 244 | |
| @@ -251,7 +251,7 @@ discard block | ||
| 251 | 251 | 'START_LEFT' => floor($return_time + 1 - SN_TIME_NOW), | 
| 252 | 252 | ); | 
| 253 | 253 | |
| 254 | -  if(!empty($TargetPlanet)) { | |
| 254 | +  if (!empty($TargetPlanet)) { | |
| 255 | 255 | $template_route += array( | 
| 256 | 256 | 'END_TYPE_TEXT_SH' => classLocale::$lang['sys_planet_type_sh'][$TargetPlanet['planet_type']], | 
| 257 | 257 | 'END_COORDS' => uni_render_coordinates($TargetPlanet), | 
| @@ -264,8 +264,8 @@ discard block | ||
| 264 | 264 |    $template->assign_block_vars('fleets', $template_route); | 
| 265 | 265 | |
| 266 | 266 |    $sn_groups_fleet = sn_get_groups('fleet'); | 
| 267 | -  foreach($fleetarray as $ship_id => $ship_count) { | |
| 268 | -    if(in_array($ship_id, $sn_groups_fleet) && $ship_count) { | |
| 267 | +  foreach ($fleetarray as $ship_id => $ship_count) { | |
| 268 | +    if (in_array($ship_id, $sn_groups_fleet) && $ship_count) { | |
| 269 | 269 | // $ship_base_data = get_ship_data($ship_id, $user); | 
| 270 | 270 |        $template->assign_block_vars('fleets.ships', array( | 
| 271 | 271 | 'ID' => $ship_id, | 
| @@ -5,29 +5,29 @@ discard block | ||
| 5 | 5 | $avatar_filename = $fullsize_filename = SN_ROOT_PHYSICAL . 'images/avatar/' . $prefix . '_' . $subject_id; | 
| 6 | 6 | $avatar_filename .= '.png'; | 
| 7 | 7 | $fullsize_filename .= '_full.png'; | 
| 8 | -    if(sys_get_param_int('avatar_remove')) { | |
| 9 | -      if(file_exists($avatar_filename) && !unlink($avatar_filename)) { | |
| 8 | +    if (sys_get_param_int('avatar_remove')) { | |
| 9 | +      if (file_exists($avatar_filename) && !unlink($avatar_filename)) { | |
| 10 | 10 | throw new Exception(classLocale::$lang['opt_msg_avatar_error_delete'], ERR_ERROR); | 
| 11 | 11 | } | 
| 12 | 12 | $avatar_field = 0; | 
| 13 | 13 | throw new Exception(classLocale::$lang['opt_msg_avatar_removed'], ERR_NONE); | 
| 14 | -    } elseif($_FILES['avatar']['size']) { | |
| 15 | -      if(!in_array($_FILES['avatar']['type'], array('image/gif', 'image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png')) || $_FILES['avatar']['size'] > 204800) { | |
| 14 | +    } elseif ($_FILES['avatar']['size']) { | |
| 15 | +      if (!in_array($_FILES['avatar']['type'], array('image/gif', 'image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png')) || $_FILES['avatar']['size'] > 204800) { | |
| 16 | 16 | throw new Exception(classLocale::$lang['opt_msg_avatar_error_unsupported'], ERR_WARNING); | 
| 17 | 17 | } | 
| 18 | 18 | |
| 19 | -      if($_FILES['avatar']['error']) { | |
| 19 | +      if ($_FILES['avatar']['error']) { | |
| 20 | 20 | throw new Exception(sprintf(classLocale::$lang['opt_msg_avatar_error_upload'], $_FILES['avatar']['error']), ERR_ERROR); | 
| 21 | 21 | } | 
| 22 | 22 | |
| 23 | -      if(!($avatar_image = imagecreatefromstring(file_get_contents($_FILES['avatar']['tmp_name'])))) { | |
| 23 | +      if (!($avatar_image = imagecreatefromstring(file_get_contents($_FILES['avatar']['tmp_name'])))) { | |
| 24 | 24 | throw new Exception(classLocale::$lang['opt_msg_avatar_error_unsupported'], ERR_WARNING); | 
| 25 | 25 | } | 
| 26 | 26 | |
| 27 | 27 | $avatar_size = getimagesize($_FILES['avatar']['tmp_name']); | 
| 28 | 28 | $avatar_max_width = classSupernova::$config->avatar_max_width; | 
| 29 | 29 | $avatar_max_height = classSupernova::$config->avatar_max_height; | 
| 30 | -      if($avatar_size[0] > $avatar_max_width || $avatar_size[1] > $avatar_max_height) { | |
| 30 | +      if ($avatar_size[0] > $avatar_max_width || $avatar_size[1] > $avatar_max_height) { | |
| 31 | 31 | $aspect_ratio = min($avatar_max_width / $avatar_size[0], $avatar_max_height / $avatar_size[1]); | 
| 32 | 32 | $avatar_image_new = imagecreatetruecolor($avatar_size[0] * $aspect_ratio, $avatar_size[0] * $aspect_ratio); | 
| 33 | 33 | $result = imagecopyresized($avatar_image_new, $avatar_image, 0, 0, 0, 0, $avatar_size[0] * $aspect_ratio, $avatar_size[0] * $aspect_ratio, $avatar_size[0], $avatar_size[1]); | 
| @@ -35,11 +35,11 @@ discard block | ||
| 35 | 35 | $avatar_image = $avatar_image_new; | 
| 36 | 36 | } | 
| 37 | 37 | |
| 38 | -      if(file_exists($avatar_filename) && !unlink($avatar_filename)) { | |
| 38 | +      if (file_exists($avatar_filename) && !unlink($avatar_filename)) { | |
| 39 | 39 | throw new Exception(classLocale::$lang['opt_msg_avatar_error_delete'], ERR_ERROR); | 
| 40 | 40 | } | 
| 41 | 41 | |
| 42 | -      if(!imagepng($avatar_image, $avatar_filename, 9)) { | |
| 42 | +      if (!imagepng($avatar_image, $avatar_filename, 9)) { | |
| 43 | 43 | throw new Exception(classLocale::$lang['opt_msg_avatar_error_writing'], ERR_ERROR); | 
| 44 | 44 | } | 
| 45 | 45 | |
| @@ -47,7 +47,7 @@ discard block | ||
| 47 | 47 | imagedestroy($avatar_image); | 
| 48 | 48 | throw new Exception(classLocale::$lang['opt_msg_avatar_uploaded'], ERR_NONE); | 
| 49 | 49 | } | 
| 50 | -  } catch(Exception $e) { | |
| 50 | +  } catch (Exception $e) { | |
| 51 | 51 | return array( | 
| 52 | 52 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, | 
| 53 | 53 | 'MESSAGE' => $e->getMessage() | 
| @@ -9,12 +9,12 @@ discard block | ||
| 9 | 9 |      $uni_galaxy = sys_get_param_int('galaxy', $planetrow['galaxy']); | 
| 10 | 10 |      $uni_system = sys_get_param_int('system'); | 
| 11 | 11 | |
| 12 | - if($uni_galaxy < 1 || $uni_galaxy > classSupernova::$config->game_maxGalaxy) | |
| 12 | + if ($uni_galaxy < 1 || $uni_galaxy > classSupernova::$config->game_maxGalaxy) | |
| 13 | 13 |      { | 
| 14 | 14 | throw new exception(classLocale::$lang['uni_msg_error_wrong_galaxy'], ERR_ERROR); | 
| 15 | 15 | } | 
| 16 | 16 | |
| 17 | - if($uni_system < 0 || $uni_system > classSupernova::$config->game_maxSystem) | |
| 17 | + if ($uni_system < 0 || $uni_system > classSupernova::$config->game_maxSystem) | |
| 18 | 18 |      { | 
| 19 | 19 | throw new exception(classLocale::$lang['uni_msg_error_wrong_system'], ERR_ERROR); | 
| 20 | 20 | } | 
| @@ -23,12 +23,12 @@ discard block | ||
| 23 | 23 | $uni_row['universe_price'] += $uni_system ? classSupernova::$config->uni_price_system : classSupernova::$config->uni_price_galaxy; | 
| 24 | 24 |      $uni_row['universe_name'] = strip_tags($uni_row['universe_name'] ? $uni_row['universe_name'] : ($uni_system ? "{$classLocale['sys_system']} [{$uni_galaxy}:{$uni_system}]" : "{$classLocale['sys_galaxy']} {$uni_galaxy}")); | 
| 25 | 25 | |
| 26 | -    if(sys_get_param_str('uni_name_submit')) | |
| 26 | +    if (sys_get_param_str('uni_name_submit')) | |
| 27 | 27 |      { | 
| 28 | 28 |        $uni_row['universe_name'] = strip_tags(sys_get_param_str('uni_name')); | 
| 29 | 29 | |
| 30 | 30 |        $uni_price = sys_get_param_float('uni_price'); | 
| 31 | - if($uni_price < $uni_row['universe_price']) | |
| 31 | + if ($uni_price < $uni_row['universe_price']) | |
| 32 | 32 |        { | 
| 33 | 33 | throw new exception(classLocale::$lang['uni_msg_error_low_price'], ERR_ERROR); | 
| 34 | 34 | } | 
| @@ -37,12 +37,12 @@ discard block | ||
| 37 | 37 | sn_db_transaction_start(); | 
| 38 | 38 | $user = db_user_by_id($user['id'], true); | 
| 39 | 39 | // if($user[get_unit_param(RES_DARK_MATTER, P_NAME)] < $uni_price) | 
| 40 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $uni_price) | |
| 40 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $uni_price) | |
| 41 | 41 |        { | 
| 42 | 42 | throw new exception(classLocale::$lang['uni_msg_error_no_dm'], ERR_ERROR); | 
| 43 | 43 | } | 
| 44 | 44 | |
| 45 | -      if(!rpg_points_change($user['id'], RPG_RENAME, -$uni_price, "Renaming [{$uni_galaxy}:{$uni_system}] to " . sys_get_param_str_unsafe('uni_name'))) | |
| 45 | +      if (!rpg_points_change($user['id'], RPG_RENAME, -$uni_price, "Renaming [{$uni_galaxy}:{$uni_system}] to " . sys_get_param_str_unsafe('uni_name'))) | |
| 46 | 46 |        { | 
| 47 | 47 | throw new exception(classLocale::$lang['sys_msg_err_update_dm'], ERR_ERROR); | 
| 48 | 48 | } | 
| @@ -1,14 +1,14 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | 3 |  function flt_fleet_speed($user, $fleet) { | 
| 4 | -  if(!is_array($fleet)) { | |
| 4 | +  if (!is_array($fleet)) { | |
| 5 | 5 | $fleet = array($fleet => 1); | 
| 6 | 6 | } | 
| 7 | 7 | |
| 8 | 8 | $speeds = array(); | 
| 9 | -  if(!empty($fleet)) { | |
| 10 | -    foreach($fleet as $ship_id => $amount) { | |
| 11 | -      if($amount && in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { | |
| 9 | +  if (!empty($fleet)) { | |
| 10 | +    foreach ($fleet as $ship_id => $amount) { | |
| 11 | +      if ($amount && in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { | |
| 12 | 12 | $single_ship_data = get_ship_data($ship_id, $user); | 
| 13 | 13 | $speeds[] = $single_ship_data['speed']; | 
| 14 | 14 | } | 
| @@ -19,11 +19,11 @@ discard block | ||
| 19 | 19 | } | 
| 20 | 20 | |
| 21 | 21 |  function flt_travel_distance($from, $to) { | 
| 22 | -  if($from['galaxy'] != $to['galaxy']) { | |
| 22 | +  if ($from['galaxy'] != $to['galaxy']) { | |
| 23 | 23 | $distance = abs($from['galaxy'] - $to['galaxy']) * classSupernova::$config->uni_galaxy_distance; | 
| 24 | -  } elseif($from['system'] != $to['system']) { | |
| 24 | +  } elseif ($from['system'] != $to['system']) { | |
| 25 | 25 | $distance = abs($from['system'] - $to['system']) * 5 * 19 + 2700; | 
| 26 | -  } elseif($from['planet'] != $to['planet']) { | |
| 26 | +  } elseif ($from['planet'] != $to['planet']) { | |
| 27 | 27 | $distance = abs($from['planet'] - $to['planet']) * 5 + 1000; | 
| 28 | 28 |    } else { | 
| 29 | 29 | $distance = 5; | 
| @@ -50,14 +50,14 @@ discard block | ||
| 50 | 50 | |
| 51 | 51 | $game_fleet_speed = flt_server_flight_speed_multiplier(); | 
| 52 | 52 | $fleet_speed = flt_fleet_speed($user_row, $fleet_array); | 
| 53 | -  if(!empty($fleet_array) && $fleet_speed && $game_fleet_speed) { | |
| 53 | +  if (!empty($fleet_array) && $fleet_speed && $game_fleet_speed) { | |
| 54 | 54 | $speed_percent = $speed_percent ? max(min($speed_percent, 10), 1) : 10; | 
| 55 | 55 | $real_speed = $speed_percent * sqrt($fleet_speed); | 
| 56 | 56 | |
| 57 | 57 | $duration = max(1, round((35000 / $speed_percent * sqrt($distance * 10 / $fleet_speed) + 10) / $game_fleet_speed)); | 
| 58 | 58 | |
| 59 | -    foreach($fleet_array as $ship_id => $ship_count) { | |
| 60 | -      if(!$ship_id || !$ship_count) { | |
| 59 | +    foreach ($fleet_array as $ship_id => $ship_count) { | |
| 60 | +      if (!$ship_id || !$ship_count) { | |
| 61 | 61 | continue; | 
| 62 | 62 | } | 
| 63 | 63 | |
| @@ -85,19 +85,19 @@ discard block | ||
| 85 | 85 |  function flt_bashing_check($user, $enemy, $planet_dst, $mission, $flight_duration, $fleet_group = 0) { | 
| 86 | 86 | $config_bashing_attacks = classSupernova::$config->fleet_bashing_attacks; | 
| 87 | 87 | $config_bashing_interval = classSupernova::$config->fleet_bashing_interval; | 
| 88 | -  if(!$config_bashing_attacks) { | |
| 88 | +  if (!$config_bashing_attacks) { | |
| 89 | 89 | // Bashing allowed - protection disabled | 
| 90 | 90 | return ATTACK_ALLOWED; | 
| 91 | 91 | } | 
| 92 | 92 | |
| 93 | 93 | $bashing_result = ATTACK_BASHING; | 
| 94 | -  if($user['ally_id'] && $enemy['ally_id']) { | |
| 94 | +  if ($user['ally_id'] && $enemy['ally_id']) { | |
| 95 | 95 | $relations = ali_relations($user['ally_id'], $enemy['ally_id']); | 
| 96 | -    if(!empty($relations)) { | |
| 96 | +    if (!empty($relations)) { | |
| 97 | 97 | $relations = $relations[$enemy['ally_id']]; | 
| 98 | -      switch($relations['alliance_diplomacy_relation']) { | |
| 98 | +      switch ($relations['alliance_diplomacy_relation']) { | |
| 99 | 99 | case ALLY_DIPLOMACY_WAR: | 
| 100 | -          if(SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= classSupernova::$config->fleet_bashing_war_delay) { | |
| 100 | +          if (SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= classSupernova::$config->fleet_bashing_war_delay) { | |
| 101 | 101 | $bashing_result = ATTACK_BASHING_WAR_DELAY; | 
| 102 | 102 |            } else { | 
| 103 | 103 | return ATTACK_ALLOWED; | 
| @@ -119,9 +119,9 @@ discard block | ||
| 119 | 119 | |
| 120 | 120 | // Retrieving flying fleets | 
| 121 | 121 | $objFleetsBashing = FleetList::dbGetFleetListBashing($user['id'], $planet_dst); | 
| 122 | -  foreach($objFleetsBashing->_container as $fleetBashing) { | |
| 122 | +  foreach ($objFleetsBashing->_container as $fleetBashing) { | |
| 123 | 123 | // Checking for ACS - each ACS count only once | 
| 124 | -    if($fleetBashing->group_id) { | |
| 124 | +    if ($fleetBashing->group_id) { | |
| 125 | 125 |        $bashing_list["{$user['id']}_{$fleetBashing->group_id}"] = $fleetBashing->time_arrive_to_target; | 
| 126 | 126 |      } else { | 
| 127 | 127 | $bashing_list[] = $fleetBashing->time_arrive_to_target; | 
| @@ -129,12 +129,12 @@ discard block | ||
| 129 | 129 | } | 
| 130 | 130 | |
| 131 | 131 | // Check for joining to ACS - if there are already fleets in ACS no checks should be done | 
| 132 | -  if($mission == MT_AKS && $bashing_list["{$user['id']}_{$fleet_group}"]) { | |
| 132 | +  if ($mission == MT_AKS && $bashing_list["{$user['id']}_{$fleet_group}"]) { | |
| 133 | 133 | return ATTACK_ALLOWED; | 
| 134 | 134 | } | 
| 135 | 135 | |
| 136 | 136 | $query = db_bashing_list_get($user, $planet_dst, $time_limit); | 
| 137 | -  while($bashing_row = db_fetch($query)) { | |
| 137 | +  while ($bashing_row = db_fetch($query)) { | |
| 138 | 138 | $bashing_list[] = $bashing_row['bashing_time']; | 
| 139 | 139 | } | 
| 140 | 140 | |
| @@ -143,9 +143,9 @@ discard block | ||
| 143 | 143 | $last_attack = 0; | 
| 144 | 144 | $wave = 0; | 
| 145 | 145 | $attack = 1; | 
| 146 | -  foreach($bashing_list as &$bash_time) { | |
| 146 | +  foreach ($bashing_list as &$bash_time) { | |
| 147 | 147 | $attack++; | 
| 148 | -    if($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { | |
| 148 | +    if ($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { | |
| 149 | 149 | $attack = 1; | 
| 150 | 150 | $wave++; | 
| 151 | 151 | } | 
| @@ -162,16 +162,16 @@ discard block | ||
| 162 | 162 | //TODO: try..catch | 
| 163 | 163 | global $user; | 
| 164 | 164 | |
| 165 | -  if($user['vacation']) { | |
| 165 | +  if ($user['vacation']) { | |
| 166 | 166 | return $result = ATTACK_OWN_VACATION; | 
| 167 | 167 | } | 
| 168 | 168 | |
| 169 | -  if(empty($fleet) || !is_array($fleet)) { | |
| 169 | +  if (empty($fleet) || !is_array($fleet)) { | |
| 170 | 170 | return $result = ATTACK_NO_FLEET; | 
| 171 | 171 | } | 
| 172 | 172 | |
| 173 | 173 |    $sn_groups_mission = sn_get_groups('missions'); | 
| 174 | -  if(!isset($sn_groups_mission[$mission])) { | |
| 174 | +  if (!isset($sn_groups_mission[$mission])) { | |
| 175 | 175 | return $result = ATTACK_MISSION_ABSENT; | 
| 176 | 176 | } | 
| 177 | 177 | $sn_data_mission = $sn_groups_mission[$mission]; | 
| @@ -190,32 +190,32 @@ discard block | ||
| 190 | 190 | $resources = 0; | 
| 191 | 191 |    $ship_ids = sn_get_groups('fleet'); | 
| 192 | 192 |    $resource_ids = sn_get_groups('resources_loot'); | 
| 193 | -  foreach($fleet as $ship_id => $ship_count) { | |
| 193 | +  foreach ($fleet as $ship_id => $ship_count) { | |
| 194 | 194 | $is_ship = in_array($ship_id, $ship_ids); | 
| 195 | 195 | $is_resource = in_array($ship_id, $resource_ids); | 
| 196 | -    if(!$is_ship && !$is_resource) { | |
| 196 | +    if (!$is_ship && !$is_resource) { | |
| 197 | 197 | // TODO Спецобработчик для Капитана и модулей | 
| 198 | 198 | // return ATTACK_WRONG_UNIT; | 
| 199 | 199 | } | 
| 200 | 200 | |
| 201 | -    if($ship_count < 0) { | |
| 201 | +    if ($ship_count < 0) { | |
| 202 | 202 | return $result = $is_ship ? ATTACK_SHIP_COUNT_WRONG : ATTACK_RESOURCE_COUNT_WRONG; | 
| 203 | 203 | } | 
| 204 | 204 | |
| 205 | -    if($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { | |
| 205 | +    if ($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { | |
| 206 | 206 | // TODO ATTACK_NO_MISSILE | 
| 207 | 207 | return $result = $is_ship ? ATTACK_NO_SHIPS : ATTACK_NO_RESOURCES; | 
| 208 | 208 | } | 
| 209 | 209 | |
| 210 | -    if($is_ship) { | |
| 210 | +    if ($is_ship) { | |
| 211 | 211 | $single_ship_data = get_ship_data($ship_id, $user); | 
| 212 | -      if($single_ship_data[P_SPEED] <= 0) { | |
| 212 | +      if ($single_ship_data[P_SPEED] <= 0) { | |
| 213 | 213 | return $result = ATTACK_ZERO_SPEED; | 
| 214 | 214 | } | 
| 215 | 215 | $ships += $ship_count; | 
| 216 | 216 |        $recyclers += in_array($ship_id, sn_get_groups('flt_recyclers')) ? $ship_count : 0; | 
| 217 | 217 | $spies += $ship_id == SHIP_SPY ? $ship_count : 0; | 
| 218 | -    } elseif($is_resource) { | |
| 218 | +    } elseif ($is_resource) { | |
| 219 | 219 | $resources += $ship_count; | 
| 220 | 220 | } | 
| 221 | 221 | } | 
| @@ -226,7 +226,7 @@ discard block | ||
| 226 | 226 | } | 
| 227 | 227 | */ | 
| 228 | 228 | |
| 229 | -  if(isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { | |
| 229 | +  if (isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { | |
| 230 | 230 | return $result = ATTACK_RESOURCE_FORBIDDEN; | 
| 231 | 231 | } | 
| 232 | 232 | |
| @@ -238,78 +238,78 @@ discard block | ||
| 238 | 238 | */ | 
| 239 | 239 | |
| 240 | 240 | $speed = $options['fleet_speed_percent']; | 
| 241 | -  if($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { | |
| 241 | +  if ($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { | |
| 242 | 242 | return $result = ATTACK_WRONG_SPEED; | 
| 243 | 243 | } | 
| 244 | 244 | |
| 245 | 245 | $travel_data = flt_travel_data($user, $planet_src, $planet_dst, $fleet, $options['fleet_speed_percent']); | 
| 246 | 246 | |
| 247 | 247 | |
| 248 | -  if(mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { | |
| 248 | +  if (mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { | |
| 249 | 249 | return $result = ATTACK_NO_FUEL; | 
| 250 | 250 | } | 
| 251 | 251 | |
| 252 | -  if($travel_data['consumption'] > $travel_data['capacity']) { | |
| 252 | +  if ($travel_data['consumption'] > $travel_data['capacity']) { | |
| 253 | 253 | return $result = ATTACK_TOO_FAR; | 
| 254 | 254 | } | 
| 255 | 255 | |
| 256 | -  if($travel_data['hold'] < $resources) { | |
| 256 | +  if ($travel_data['hold'] < $resources) { | |
| 257 | 257 | return $result = ATTACK_OVERLOADED; | 
| 258 | 258 | } | 
| 259 | 259 | |
| 260 | 260 | $fleet_start_time = SN_TIME_NOW + $travel_data['duration']; | 
| 261 | 261 | |
| 262 | 262 | $fleet_group = $options['fleet_group']; | 
| 263 | -  if($fleet_group) { | |
| 264 | -    if($mission != MT_AKS) { | |
| 263 | +  if ($fleet_group) { | |
| 264 | +    if ($mission != MT_AKS) { | |
| 265 | 265 | return $result = ATTACK_WRONG_MISSION; | 
| 266 | 266 | }; | 
| 267 | 267 | |
| 268 | 268 | $acs = db_acs_get_by_group_id($fleet_group); | 
| 269 | -    if(!$acs['id']) { | |
| 269 | +    if (!$acs['id']) { | |
| 270 | 270 | return $result = ATTACK_NO_ACS; | 
| 271 | 271 | } | 
| 272 | 272 | |
| 273 | -    if($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) { | |
| 273 | +    if ($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) { | |
| 274 | 274 | return $result = ATTACK_ACS_WRONG_TARGET; | 
| 275 | 275 | } | 
| 276 | 276 | |
| 277 | -    if($fleet_start_time > $acs['ankunft']) { | |
| 277 | +    if ($fleet_start_time > $acs['ankunft']) { | |
| 278 | 278 | return $result = ATTACK_ACS_TOO_LATE; | 
| 279 | 279 | } | 
| 280 | 280 | } | 
| 281 | 281 | |
| 282 | 282 | $flying_fleets = $options['flying_fleets']; | 
| 283 | -  if(!$flying_fleets) { | |
| 283 | +  if (!$flying_fleets) { | |
| 284 | 284 | $flying_fleets = FleetList::fleet_count_flying($user['id']); | 
| 285 | 285 | } | 
| 286 | -  if(GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { | |
| 286 | +  if (GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { | |
| 287 | 287 | return $result = ATTACK_NO_SLOTS; | 
| 288 | 288 | } | 
| 289 | 289 | |
| 290 | 290 | // В одиночку шпионские зонды могут летать только в миссии Шпионаж, Передислокация и Транспорт | 
| 291 | -  if($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { | |
| 291 | +  if ($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { | |
| 292 | 292 | return $result = ATTACK_SPIES_LONLY; | 
| 293 | 293 | } | 
| 294 | 294 | |
| 295 | 295 | // Checking for no planet | 
| 296 | -  if(!$planet_dst['id_owner']) { | |
| 297 | -    if($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { | |
| 296 | +  if (!$planet_dst['id_owner']) { | |
| 297 | +    if ($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { | |
| 298 | 298 | return $result = ATTACK_NO_COLONIZER; | 
| 299 | 299 | } | 
| 300 | 300 | |
| 301 | -    if($mission == MT_EXPLORE || $mission == MT_COLONIZE) { | |
| 301 | +    if ($mission == MT_EXPLORE || $mission == MT_COLONIZE) { | |
| 302 | 302 | return $result = ATTACK_ALLOWED; | 
| 303 | 303 | } | 
| 304 | 304 | |
| 305 | 305 | return $result = ATTACK_NO_TARGET; | 
| 306 | 306 | } | 
| 307 | 307 | |
| 308 | -  if($mission == MT_RECYCLE) { | |
| 309 | -    if($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { | |
| 308 | +  if ($mission == MT_RECYCLE) { | |
| 309 | +    if ($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { | |
| 310 | 310 | return $result = ATTACK_NO_DEBRIS; | 
| 311 | 311 | } | 
| 312 | -    if($recyclers <= 0) { | |
| 312 | +    if ($recyclers <= 0) { | |
| 313 | 313 | return $result = ATTACK_NO_RECYCLERS; | 
| 314 | 314 | } | 
| 315 | 315 | |
| @@ -317,8 +317,8 @@ discard block | ||
| 317 | 317 | } | 
| 318 | 318 | |
| 319 | 319 | // Got planet. Checking if it is ours | 
| 320 | -  if($planet_dst['id_owner'] == $user['id']) { | |
| 321 | -    if($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { | |
| 320 | +  if ($planet_dst['id_owner'] == $user['id']) { | |
| 321 | +    if ($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { | |
| 322 | 322 | return $result = ATTACK_ALLOWED; | 
| 323 | 323 | } | 
| 324 | 324 | |
| @@ -326,19 +326,19 @@ discard block | ||
| 326 | 326 | } | 
| 327 | 327 | |
| 328 | 328 | // No, planet not ours. Cutting mission that can't be send to not-ours planet | 
| 329 | -  if($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { | |
| 329 | +  if ($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { | |
| 330 | 330 | return $result = ATTACK_WRONG_MISSION; | 
| 331 | 331 | } | 
| 332 | 332 | |
| 333 | 333 | $enemy = db_user_by_id($planet_dst['id_owner']); | 
| 334 | 334 | // We cannot attack or send resource to users in VACATION mode | 
| 335 | -  if($enemy['vacation'] && $mission != MT_RECYCLE) { | |
| 335 | +  if ($enemy['vacation'] && $mission != MT_RECYCLE) { | |
| 336 | 336 | return $result = ATTACK_VACATION; | 
| 337 | 337 | } | 
| 338 | 338 | |
| 339 | 339 | // Multi IP protection | 
| 340 | 340 | // TODO: Here we need a procedure to check proxies | 
| 341 | -  if(sys_is_multiaccount($user, $enemy)) { | |
| 341 | +  if (sys_is_multiaccount($user, $enemy)) { | |
| 342 | 342 | return $result = ATTACK_SAME_IP; | 
| 343 | 343 | } | 
| 344 | 344 | |
| @@ -346,8 +346,8 @@ discard block | ||
| 346 | 346 | $enemy_points = $enemy['total_points']; | 
| 347 | 347 | |
| 348 | 348 | // Is it transport? If yes - checking for buffing to prevent mega-alliance destroyer | 
| 349 | -  if($mission == MT_TRANSPORT) { | |
| 350 | -    if($user_points >= $enemy_points || classSupernova::$config->allow_buffing) { | |
| 349 | +  if ($mission == MT_TRANSPORT) { | |
| 350 | +    if ($user_points >= $enemy_points || classSupernova::$config->allow_buffing) { | |
| 351 | 351 | return $result = ATTACK_ALLOWED; | 
| 352 | 352 |      } else { | 
| 353 | 353 | return $result = ATTACK_BUFFING; | 
| @@ -357,66 +357,66 @@ discard block | ||
| 357 | 357 | // Only aggresive missions passed to this point. HOLD counts as passive but aggresive | 
| 358 | 358 | |
| 359 | 359 | // Is it admin with planet protection? | 
| 360 | -  if($planet_dst['id_level'] > $user['authlevel']) { | |
| 360 | +  if ($planet_dst['id_level'] > $user['authlevel']) { | |
| 361 | 361 | return $result = ATTACK_ADMIN; | 
| 362 | 362 | } | 
| 363 | 363 | |
| 364 | 364 | // Okay. Now skipping protection checks for inactive longer then 1 week | 
| 365 | -  if(!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) { | |
| 366 | - if( | |
| 365 | +  if (!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) { | |
| 366 | + if ( | |
| 367 | 367 | ($enemy_points <= classSupernova::$config->game_noob_points && $user_points > classSupernova::$config->game_noob_points) | 
| 368 | 368 | || | 
| 369 | 369 | (classSupernova::$config->game_noob_factor && $user_points > $enemy_points * classSupernova::$config->game_noob_factor) | 
| 370 | 370 |      ) { | 
| 371 | -      if($mission != MT_HOLD) { | |
| 371 | +      if ($mission != MT_HOLD) { | |
| 372 | 372 | return $result = ATTACK_NOOB; | 
| 373 | 373 | } | 
| 374 | -      if($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && classSupernova::$config->ally_help_weak)) { | |
| 374 | +      if ($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && classSupernova::$config->ally_help_weak)) { | |
| 375 | 375 | return $result = ATTACK_NOOB; | 
| 376 | 376 | } | 
| 377 | 377 | } | 
| 378 | 378 | } | 
| 379 | 379 | |
| 380 | 380 | // Is it HOLD mission? If yes - there should be ally deposit | 
| 381 | -  if($mission == MT_HOLD) { | |
| 382 | -    if(mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { | |
| 381 | +  if ($mission == MT_HOLD) { | |
| 382 | +    if (mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { | |
| 383 | 383 | return $result = ATTACK_ALLOWED; | 
| 384 | 384 | } | 
| 385 | 385 | |
| 386 | 386 | return $result = ATTACK_NO_ALLY_DEPOSIT; | 
| 387 | 387 | } | 
| 388 | 388 | |
| 389 | -  if($mission == MT_SPY) { | |
| 389 | +  if ($mission == MT_SPY) { | |
| 390 | 390 | return $result = $spies >= 1 ? ATTACK_ALLOWED : ATTACK_NO_SPIES; | 
| 391 | 391 | } | 
| 392 | 392 | |
| 393 | 393 | // Is it MISSILE mission? | 
| 394 | -  if($mission == MT_MISSILE) { | |
| 394 | +  if ($mission == MT_MISSILE) { | |
| 395 | 395 | $sn_data_mip = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET); | 
| 396 | -    if(mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { | |
| 396 | +    if (mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { | |
| 397 | 397 | return $result = ATTACK_NO_SILO; | 
| 398 | 398 | } | 
| 399 | 399 | |
| 400 | -    if(!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { | |
| 400 | +    if (!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { | |
| 401 | 401 | return $result = ATTACK_NO_MISSILE; | 
| 402 | 402 | } | 
| 403 | 403 | |
| 404 | 404 | $distance = abs($planet_dst['system'] - $planet_src['system']); | 
| 405 | 405 | $mip_range = flt_get_missile_range($user); | 
| 406 | -    if($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { | |
| 406 | +    if ($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { | |
| 407 | 407 | return $result = ATTACK_MISSILE_TOO_FAR; | 
| 408 | 408 | } | 
| 409 | 409 | |
| 410 | -    if(isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { | |
| 410 | +    if (isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { | |
| 411 | 411 | return $result = ATTACK_WRONG_STRUCTURE; | 
| 412 | 412 | } | 
| 413 | 413 | } | 
| 414 | 414 | |
| 415 | -  if($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { | |
| 415 | +  if ($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { | |
| 416 | 416 | return $result = ATTACK_WRONG_MISSION; | 
| 417 | 417 | } | 
| 418 | 418 | |
| 419 | -  if($mission == MT_ATTACK || $mission == MT_AKS || $mission == MT_DESTROY) { | |
| 419 | +  if ($mission == MT_ATTACK || $mission == MT_AKS || $mission == MT_DESTROY) { | |
| 420 | 420 | return $result = flt_bashing_check($user, $enemy, $planet_dst, $mission, $travel_data['duration'], $fleet_group); | 
| 421 | 421 | } | 
| 422 | 422 | |
| @@ -443,7 +443,7 @@ discard block | ||
| 443 | 443 | $from = $from['planet']; | 
| 444 | 444 | |
| 445 | 445 | $can_attack = flt_can_attack($from, $to, $fleet_REAL_array, $mission, $options); | 
| 446 | -  if($can_attack != ATTACK_ALLOWED) { | |
| 446 | +  if ($can_attack != ATTACK_ALLOWED) { | |
| 447 | 447 | $internal_transaction ? sn_db_transaction_rollback() : false; | 
| 448 | 448 | |
| 449 | 449 | return $can_attack; | 
| @@ -454,7 +454,7 @@ discard block | ||
| 454 | 454 | $travel_data = flt_travel_data($user, $from, $to, $fleet_REAL_array, $options['fleet_speed_percent']); | 
| 455 | 455 | |
| 456 | 456 | $time_on_mission = 0; | 
| 457 | -  if($mission == MT_EXPLORE || $mission == MT_HOLD) { | |
| 457 | +  if ($mission == MT_EXPLORE || $mission == MT_HOLD) { | |
| 458 | 458 | // TODO - include some checks about maximum and minumum stay_duration | 
| 459 | 459 | $time_on_mission = $options['stay_time'] * 3600; | 
| 460 | 460 | } | 
| @@ -477,14 +477,14 @@ discard block | ||
| 477 | 477 |    $sn_group_resources_loot = sn_get_groups('resources_loot'); | 
| 478 | 478 | $db_changeset = array(); | 
| 479 | 479 | $planet_row_changed_fields = array(); | 
| 480 | -  foreach($fleet_REAL_array as $unit_id => $amount) { | |
| 481 | -    if(!$amount || !$unit_id) { | |
| 480 | +  foreach ($fleet_REAL_array as $unit_id => $amount) { | |
| 481 | +    if (!$amount || !$unit_id) { | |
| 482 | 482 | continue; | 
| 483 | 483 | } | 
| 484 | 484 | |
| 485 | -    if(in_array($unit_id, $sn_group_fleet)) { | |
| 485 | +    if (in_array($unit_id, $sn_group_fleet)) { | |
| 486 | 486 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, -$amount, $user, $from['id']); | 
| 487 | -    } elseif(in_array($unit_id, $sn_group_resources_loot)) { | |
| 487 | +    } elseif (in_array($unit_id, $sn_group_resources_loot)) { | |
| 488 | 488 | $planet_row_changed_fields[pname_resource_name($unit_id)]['delta'] -= $amount; | 
| 489 | 489 | } | 
| 490 | 490 | } | 
| @@ -523,16 +523,16 @@ discard block | ||
| 523 | 523 | |
| 524 | 524 | $ship_data = array(); | 
| 525 | 525 | $fleet_array = array(); | 
| 526 | -  foreach($ship_list as $transport_id => $cork) { | |
| 526 | +  foreach ($ship_list as $transport_id => $cork) { | |
| 527 | 527 | $ship_data[$transport_id] = flt_travel_data($user, $from, $to, array($transport_id => 1), 10); | 
| 528 | 528 | } | 
| 529 | 529 | uasort($ship_data, 'flt_calculate_ship_to_transport_sort'); | 
| 530 | 530 | |
| 531 | 531 | $fleet_capacity = 0; | 
| 532 | 532 | $fuel_total = $fuel_left = mrc_get_level($user, $from, RES_DEUTERIUM); | 
| 533 | -  foreach($ship_data as $transport_id => &$ship_info) { | |
| 533 | +  foreach ($ship_data as $transport_id => &$ship_info) { | |
| 534 | 534 | $ship_loaded = min($ship_list[$transport_id], ceil($resource_amount / $ship_info['hold']), floor($fuel_left / $ship_info['consumption'])); | 
| 535 | -    if($ship_loaded) { | |
| 535 | +    if ($ship_loaded) { | |
| 536 | 536 | $fleet_array[$transport_id] = $ship_loaded; | 
| 537 | 537 | $resource_amount -= min($resource_amount, $ship_info['hold'] * $ship_loaded); | 
| 538 | 538 | $fuel_left -= $ship_info['consumption'] * $ship_loaded; | 
| @@ -4,13 +4,13 @@ discard block | ||
| 4 | 4 | |
| 5 | 5 |  function mrc_officer_accessible(&$user, $mercenary_id) { | 
| 6 | 6 | $mercenary_info = get_unit_param($mercenary_id); | 
| 7 | -  if(classSupernova::$config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) { | |
| 7 | +  if (classSupernova::$config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) { | |
| 8 | 8 | return true; | 
| 9 | 9 | } | 
| 10 | 10 | |
| 11 | -  if(isset($mercenary_info[P_REQUIRE])) { | |
| 12 | -    foreach($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) { | |
| 13 | -      if(mrc_get_level($user, null, $unit_id) < $unit_level) { | |
| 11 | +  if (isset($mercenary_info[P_REQUIRE])) { | |
| 12 | +    foreach ($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) { | |
| 13 | +      if (mrc_get_level($user, null, $unit_id) < $unit_level) { | |
| 14 | 14 | return false; | 
| 15 | 15 | } | 
| 16 | 16 | } | 
| @@ -26,35 +26,35 @@ discard block | ||
| 26 | 26 | $is_permanent = $mode == UNIT_PLANS || !classSupernova::$config->empire_mercenary_temporary; | 
| 27 | 27 | $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? classSupernova::$config->ali_bonus_members : 1); | 
| 28 | 28 | $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1; | 
| 29 | -    if(!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) { | |
| 29 | +    if (!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) { | |
| 30 | 30 | throw new Exception(classLocale::$lang['mrc_msg_error_wrong_mercenary'], ERR_ERROR); | 
| 31 | 31 | } | 
| 32 | 32 | |
| 33 | -    if(!mrc_officer_accessible($user, $mercenary_id)) { | |
| 33 | +    if (!mrc_officer_accessible($user, $mercenary_id)) { | |
| 34 | 34 | throw new Exception(classLocale::$lang['mrc_msg_error_requirements'], ERR_ERROR); | 
| 35 | 35 | } | 
| 36 | 36 | |
| 37 | 37 |      $mercenary_level = sys_get_param_int('mercenary_level'); | 
| 38 | -    if($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) { | |
| 38 | +    if ($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) { | |
| 39 | 39 | throw new Exception(classLocale::$lang['mrc_msg_error_wrong_level'], ERR_ERROR); | 
| 40 | 40 | } | 
| 41 | 41 | |
| 42 | -    if($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) { | |
| 42 | +    if ($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) { | |
| 43 | 43 | throw new Exception(classLocale::$lang['mrc_msg_error_wrong_period'], ERR_ERROR); | 
| 44 | 44 | } | 
| 45 | 45 | |
| 46 | 46 | sn_db_transaction_start(); | 
| 47 | 47 | |
| 48 | 48 | $mercenary_level_old = mrc_get_level($user, $planetrow, $mercenary_id, true, true); | 
| 49 | -    if(classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) { | |
| 49 | +    if (classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) { | |
| 50 | 50 | throw new Exception(classLocale::$lang['mrc_msg_error_already_hired'], ERR_ERROR); // Can't hire already hired temp mercenary - dismiss first | 
| 51 | -    } elseif(classSupernova::$config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) { | |
| 51 | +    } elseif (classSupernova::$config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) { | |
| 52 | 52 |        throw new Exception('', ERR_NONE); // Can't dismiss (!$mercenary_level) not hired (!$mercenary_level_old) temp mercenary. But no error | 
| 53 | 53 | } | 
| 54 | 54 | |
| 55 | -    if($mercenary_level) { | |
| 55 | +    if ($mercenary_level) { | |
| 56 | 56 | $darkmater_cost = eco_get_total_cost($mercenary_id, $mercenary_level); | 
| 57 | -      if(!classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old) { | |
| 57 | +      if (!classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old) { | |
| 58 | 58 | $darkmater_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level_old); | 
| 59 | 59 | $darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] -= $darkmater_cost_old[BUILD_CREATE][RES_DARK_MATTER]; | 
| 60 | 60 | } | 
| @@ -64,13 +64,13 @@ discard block | ||
| 64 | 64 | } | 
| 65 | 65 | $darkmater_cost *= $cost_alliance_multiplyer; | 
| 66 | 66 | |
| 67 | -    if(mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) { | |
| 67 | +    if (mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) { | |
| 68 | 68 | throw new Exception(classLocale::$lang['mrc_msg_error_no_resource'], ERR_ERROR); | 
| 69 | 69 | } | 
| 70 | 70 | |
| 71 | -    if(($darkmater_cost && $mercenary_level) || !$is_permanent) { | |
| 71 | +    if (($darkmater_cost && $mercenary_level) || !$is_permanent) { | |
| 72 | 72 | $unit_row = db_unit_by_location($user['id'], LOC_USER, $user['id'], $mercenary_id); | 
| 73 | -      if(is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) { | |
| 73 | +      if (is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) { | |
| 74 | 74 | $dismiss_full_cost = eco_get_total_cost($mercenary_id, $unit_row['unit_level']); | 
| 75 | 75 | $dismiss_full_cost = $dismiss_full_cost[BUILD_CREATE][RES_DARK_MATTER]; | 
| 76 | 76 | |
| @@ -83,7 +83,7 @@ discard block | ||
| 83 | 83 | db_unit_list_delete($user['id'], LOC_USER, $user['id'], $mercenary_id); | 
| 84 | 84 | } | 
| 85 | 85 | |
| 86 | -    if($darkmater_cost && $mercenary_level) { | |
| 86 | +    if ($darkmater_cost && $mercenary_level) { | |
| 87 | 87 | db_unit_set_insert( | 
| 88 | 88 |          "unit_player_id = {$user['id']}, | 
| 89 | 89 | unit_location_type = " . LOC_USER . ", | 
| @@ -100,7 +100,7 @@ discard block | ||
| 100 | 100 | } | 
| 101 | 101 | sn_db_transaction_commit(); | 
| 102 | 102 | sys_redirect($_SERVER['REQUEST_URI']); | 
| 103 | -  } catch(Exception $e) { | |
| 103 | +  } catch (Exception $e) { | |
| 104 | 104 | sn_db_transaction_rollback(); | 
| 105 | 105 | $operation_result = array( | 
| 106 | 106 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, | 
| @@ -118,7 +118,7 @@ discard block | ||
| 118 | 118 | $mode = in_array($mode, array(UNIT_MERCENARIES, UNIT_PLANS)) ? $mode : UNIT_MERCENARIES; | 
| 119 | 119 | $is_permanent = $mode == UNIT_PLANS || !classSupernova::$config->empire_mercenary_temporary; | 
| 120 | 120 | |
| 121 | -  if($mercenary_id = sys_get_param_int('mercenary_id')) { | |
| 121 | +  if ($mercenary_id = sys_get_param_int('mercenary_id')) { | |
| 122 | 122 | $operation_result = mrc_mercenary_hire($mode, $user, $mercenary_id); | 
| 123 | 123 | } | 
| 124 | 124 | |
| @@ -126,11 +126,11 @@ discard block | ||
| 126 | 126 | |
| 127 | 127 |    $template = gettemplate('mrc_mercenary_hire', true); | 
| 128 | 128 | |
| 129 | -  if(!empty($operation_result)) { | |
| 129 | +  if (!empty($operation_result)) { | |
| 130 | 130 |      $template->assign_block_vars('result', $operation_result); | 
| 131 | 131 | } | 
| 132 | 132 | |
| 133 | -  foreach($sn_powerup_buy_discounts as $hire_period => $hire_discount) { | |
| 133 | +  foreach ($sn_powerup_buy_discounts as $hire_period => $hire_discount) { | |
| 134 | 134 |      $template->assign_block_vars('period', array( | 
| 135 | 135 | 'LENGTH' => $hire_period, | 
| 136 | 136 | 'TEXT' => classLocale::$lang['mrc_period_list'][$hire_period], | 
| @@ -142,12 +142,12 @@ discard block | ||
| 142 | 142 | $user_dark_matter = mrc_get_level($user, null, RES_DARK_MATTER); | 
| 143 | 143 | $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? classSupernova::$config->ali_bonus_members : 1); | 
| 144 | 144 | $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1; | 
| 145 | -  foreach(sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) { | |
| 145 | +  foreach (sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) { | |
| 146 | 146 |      { | 
| 147 | 147 | $mercenary = get_unit_param($mercenary_id); | 
| 148 | 148 | $mercenary_bonus = $mercenary['bonus']; | 
| 149 | 149 |        $mercenary_bonus = $mercenary_bonus >= 0 ? "+{$mercenary_bonus}" : "{$mercenary_bonus}"; | 
| 150 | -      switch($mercenary['bonus_type']) { | |
| 150 | +      switch ($mercenary['bonus_type']) { | |
| 151 | 151 | case BONUS_PERCENT: | 
| 152 | 152 |            $mercenary_bonus = "{$mercenary_bonus}% "; | 
| 153 | 153 | break; | 
| @@ -164,7 +164,7 @@ discard block | ||
| 164 | 164 | $mercenary_level = mrc_get_level($user, null, $mercenary_id, false, true); | 
| 165 | 165 | $mercenary_level_bonus = max(0, mrc_get_level($user, null, $mercenary_id) - $mercenary_level); | 
| 166 | 166 | $total_cost_old = 0; | 
| 167 | -      if($is_permanent) { | |
| 167 | +      if ($is_permanent) { | |
| 168 | 168 | $total_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level); | 
| 169 | 169 | $total_cost_old = $total_cost_old[BUILD_CREATE][RES_DARK_MATTER] * $cost_alliance_multiplyer; | 
| 170 | 170 | } | 
| @@ -193,7 +193,7 @@ discard block | ||
| 193 | 193 | )); | 
| 194 | 194 | |
| 195 | 195 | $upgrade_cost = 1; | 
| 196 | -      for($i = classSupernova::$config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) { | |
| 196 | +      for ($i = classSupernova::$config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) { | |
| 197 | 197 | $total_cost = eco_get_total_cost($mercenary_id, $i); | 
| 198 | 198 | $total_cost[BUILD_CREATE][RES_DARK_MATTER] *= $cost_alliance_multiplyer; | 
| 199 | 199 | $upgrade_cost = $total_cost[BUILD_CREATE][RES_DARK_MATTER] - $total_cost_old; |