@@ -37,11 +37,11 @@ |
||
| 37 | 37 | /** |
| 38 | 38 | * @param float $range_start - Начало диапазона |
| 39 | 39 | * @param float $range_end - Конец диапазона |
| 40 | - * @param bool|int $round - До скольки знаков округлять результат. False - не округлять, True - округлять до целого, 1 - округлять до десятков, 2 - до сотен итд |
|
| 40 | + * @param boolean $round - До скольки знаков округлять результат. False - не округлять, True - округлять до целого, 1 - округлять до десятков, 2 - до сотен итд |
|
| 41 | 41 | * @param int $strict - В сколько сигм надо уложить результат |
| 42 | 42 | * @param bool|false $cut_extreme - надо ли обрезать крайние значения. Например, при $strict = 2 их слишком много |
| 43 | 43 | * |
| 44 | - * @return float|int |
|
| 44 | + * @return double |
|
| 45 | 45 | */ |
| 46 | 46 | function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
| 47 | 47 | if($cut_extreme) { |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | function geometry_progression_sum($n, $b1, $q) { |
| 4 | - return $q != 1 ? ($b1 * (pow($q, $n) - 1)/($q - 1)) : ($n * $b1); |
|
| 4 | + return $q != 1 ? ($b1 * (pow($q, $n) - 1) / ($q - 1)) : ($n * $b1); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | function sn_floor($value) |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @return float|int |
| 45 | 45 | */ |
| 46 | -function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
| 47 | - if($cut_extreme) { |
|
| 46 | +function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
| 47 | + if ($cut_extreme) { |
|
| 48 | 48 | $range_start--; |
| 49 | 49 | $range_end++; |
| 50 | 50 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $args = func_get_args(); |
| 62 | 62 | |
| 63 | - switch(func_num_args()) |
|
| 63 | + switch (func_num_args()) |
|
| 64 | 64 | { |
| 65 | 65 | case 0: |
| 66 | 66 | // trigger_error('median() requires at least one parameter',E_USER_WARNING); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | // fallthrough |
| 73 | 73 | |
| 74 | 74 | default: |
| 75 | - if(!is_array($args)) |
|
| 75 | + if (!is_array($args)) |
|
| 76 | 76 | { |
| 77 | 77 | // trigger_error('median() requires a list of numbers to operate on or an array of numbers', E_USER_NOTICE); |
| 78 | 78 | return false; |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | $n = count($args); |
| 84 | 84 | $h = intval($n / 2); |
| 85 | 85 | |
| 86 | - if($n % 2 == 0) |
|
| 86 | + if ($n % 2 == 0) |
|
| 87 | 87 | { |
| 88 | - $median = ($args[$h] + $args[$h-1]) / 2; |
|
| 88 | + $median = ($args[$h] + $args[$h - 1]) / 2; |
|
| 89 | 89 | } |
| 90 | 90 | else |
| 91 | 91 | { |
@@ -103,47 +103,47 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | function linear_calc(&$linear, $from = 0, $debug = false) |
| 105 | 105 | { |
| 106 | - for($i = $from; $i < count($linear); $i++) |
|
| 106 | + for ($i = $from; $i < count($linear); $i++) |
|
| 107 | 107 | { |
| 108 | 108 | $eq = &$linear[$i]; |
| 109 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
| 109 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
| 110 | 110 | { |
| 111 | 111 | $eq[$j] /= $eq[$from]; |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | - if($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
| 114 | + if ($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
| 115 | 115 | |
| 116 | - for($i = $from + 1; $i < count($linear); $i++) |
|
| 116 | + for ($i = $from + 1; $i < count($linear); $i++) |
|
| 117 | 117 | { |
| 118 | 118 | $eq = &$linear[$i]; |
| 119 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
| 119 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
| 120 | 120 | { |
| 121 | 121 | $eq[$j] -= $linear[$from][$j]; |
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | - if($debug) pdump($linear, 'Подставили х' . $from); |
|
| 124 | + if ($debug) pdump($linear, 'Подставили х' . $from); |
|
| 125 | 125 | |
| 126 | - if($from < count($linear) - 1) |
|
| 126 | + if ($from < count($linear) - 1) |
|
| 127 | 127 | { |
| 128 | 128 | linear_calc($linear, $from + 1, $debug); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if($from) |
|
| 131 | + if ($from) |
|
| 132 | 132 | { |
| 133 | - for($i = 0; $i < $from; $i++) |
|
| 133 | + for ($i = 0; $i < $from; $i++) |
|
| 134 | 134 | { |
| 135 | 135 | $eq = &$linear[$i]; |
| 136 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
| 136 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
| 137 | 137 | { |
| 138 | 138 | $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j]; |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | - if($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
| 141 | + if ($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
| 142 | 142 | } |
| 143 | 143 | else |
| 144 | 144 | { |
| 145 | - if($debug) pdump($linear, 'Результат' . $from); |
|
| 146 | - foreach($linear as $index => &$eq) |
|
| 145 | + if ($debug) pdump($linear, 'Результат' . $from); |
|
| 146 | + foreach ($linear as $index => &$eq) |
|
| 147 | 147 | { |
| 148 | 148 | pdump($eq[count($linear)], 'x' . $index); |
| 149 | 149 | } |
@@ -86,8 +86,7 @@ discard block |
||
| 86 | 86 | if($n % 2 == 0) |
| 87 | 87 | { |
| 88 | 88 | $median = ($args[$h] + $args[$h-1]) / 2; |
| 89 | - } |
|
| 90 | - else |
|
| 89 | + } else |
|
| 91 | 90 | { |
| 92 | 91 | $median = $args[$h]; |
| 93 | 92 | } |
@@ -111,7 +110,9 @@ discard block |
||
| 111 | 110 | $eq[$j] /= $eq[$from]; |
| 112 | 111 | } |
| 113 | 112 | } |
| 114 | - if($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
| 113 | + if($debug) { |
|
| 114 | + pdump($linear, 'Нормализовано по х' . $from); |
|
| 115 | + } |
|
| 115 | 116 | |
| 116 | 117 | for($i = $from + 1; $i < count($linear); $i++) |
| 117 | 118 | { |
@@ -121,7 +122,9 @@ discard block |
||
| 121 | 122 | $eq[$j] -= $linear[$from][$j]; |
| 122 | 123 | } |
| 123 | 124 | } |
| 124 | - if($debug) pdump($linear, 'Подставили х' . $from); |
|
| 125 | + if($debug) { |
|
| 126 | + pdump($linear, 'Подставили х' . $from); |
|
| 127 | + } |
|
| 125 | 128 | |
| 126 | 129 | if($from < count($linear) - 1) |
| 127 | 130 | { |
@@ -138,11 +141,14 @@ discard block |
||
| 138 | 141 | $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j]; |
| 139 | 142 | } |
| 140 | 143 | } |
| 141 | - if($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
| 142 | - } |
|
| 143 | - else |
|
| 144 | + if($debug) { |
|
| 145 | + pdump($linear, 'Подставили обратно х' . $from); |
|
| 146 | + } |
|
| 147 | + } else |
|
| 144 | 148 | { |
| 145 | - if($debug) pdump($linear, 'Результат' . $from); |
|
| 149 | + if($debug) { |
|
| 150 | + pdump($linear, 'Результат' . $from); |
|
| 151 | + } |
|
| 146 | 152 | foreach($linear as $index => &$eq) |
| 147 | 153 | { |
| 148 | 154 | pdump($eq[count($linear)], 'x' . $index); |
@@ -1,5 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | +/** |
|
| 4 | + * @return double |
|
| 5 | + */ |
|
| 3 | 6 | function flt_fleet_speed($user, $fleet) |
| 4 | 7 | { |
| 5 | 8 | if (!is_array($fleet)) |
@@ -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 | } |
@@ -21,11 +21,11 @@ discard block |
||
| 21 | 21 | function flt_travel_distance($from, $to) { |
| 22 | 22 | global $config; |
| 23 | 23 | |
| 24 | - if($from['galaxy'] != $to['galaxy']) { |
|
| 24 | + if ($from['galaxy'] != $to['galaxy']) { |
|
| 25 | 25 | $distance = abs($from['galaxy'] - $to['galaxy']) * $config->uni_galaxy_distance; |
| 26 | - } elseif($from['system'] != $to['system']) { |
|
| 26 | + } elseif ($from['system'] != $to['system']) { |
|
| 27 | 27 | $distance = abs($from['system'] - $to['system']) * 5 * 19 + 2700; |
| 28 | - } elseif($from['planet'] != $to['planet']) { |
|
| 28 | + } elseif ($from['planet'] != $to['planet']) { |
|
| 29 | 29 | $distance = abs($from['planet'] - $to['planet']) * 5 + 1000; |
| 30 | 30 | } else { |
| 31 | 31 | $distance = 5; |
@@ -52,14 +52,14 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | $game_fleet_speed = flt_server_flight_speed_multiplier(); |
| 54 | 54 | $fleet_speed = flt_fleet_speed($user_row, $fleet_array); |
| 55 | - if(!empty($fleet_array) && $fleet_speed && $game_fleet_speed) { |
|
| 55 | + if (!empty($fleet_array) && $fleet_speed && $game_fleet_speed) { |
|
| 56 | 56 | $speed_percent = $speed_percent ? max(min($speed_percent, 10), 1) : 10; |
| 57 | 57 | $real_speed = $speed_percent * sqrt($fleet_speed); |
| 58 | 58 | |
| 59 | 59 | $duration = max(1, round((35000 / $speed_percent * sqrt($distance * 10 / $fleet_speed) + 10) / $game_fleet_speed)); |
| 60 | 60 | |
| 61 | - foreach($fleet_array as $ship_id => $ship_count) { |
|
| 62 | - if(!$ship_id || !$ship_count) { |
|
| 61 | + foreach ($fleet_array as $ship_id => $ship_count) { |
|
| 62 | + if (!$ship_id || !$ship_count) { |
|
| 63 | 63 | continue; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -89,19 +89,19 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | $config_bashing_attacks = $config->fleet_bashing_attacks; |
| 91 | 91 | $config_bashing_interval = $config->fleet_bashing_interval; |
| 92 | - if(!$config_bashing_attacks) { |
|
| 92 | + if (!$config_bashing_attacks) { |
|
| 93 | 93 | // Bashing allowed - protection disabled |
| 94 | 94 | return ATTACK_ALLOWED; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | $bashing_result = ATTACK_BASHING; |
| 98 | - if($user['ally_id'] && $enemy['ally_id']) { |
|
| 98 | + if ($user['ally_id'] && $enemy['ally_id']) { |
|
| 99 | 99 | $relations = ali_relations($user['ally_id'], $enemy['ally_id']); |
| 100 | - if(!empty($relations)) { |
|
| 100 | + if (!empty($relations)) { |
|
| 101 | 101 | $relations = $relations[$enemy['ally_id']]; |
| 102 | - switch($relations['alliance_diplomacy_relation']) { |
|
| 102 | + switch ($relations['alliance_diplomacy_relation']) { |
|
| 103 | 103 | case ALLY_DIPLOMACY_WAR: |
| 104 | - if(SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= $config->fleet_bashing_war_delay) { |
|
| 104 | + if (SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= $config->fleet_bashing_war_delay) { |
|
| 105 | 105 | $bashing_result = ATTACK_BASHING_WAR_DELAY; |
| 106 | 106 | } else { |
| 107 | 107 | return ATTACK_ALLOWED; |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | // Retrieving flying fleets |
| 125 | 125 | $objFleetsBashing = FleetList::dbGetFleetListBashing($user['id'], $planet_dst); |
| 126 | - foreach($objFleetsBashing->_container as $fleetBashing) { |
|
| 126 | + foreach ($objFleetsBashing->_container as $fleetBashing) { |
|
| 127 | 127 | // Checking for ACS - each ACS count only once |
| 128 | - if($fleetBashing->group_id) { |
|
| 128 | + if ($fleetBashing->group_id) { |
|
| 129 | 129 | $bashing_list["{$user['id']}_{$fleetBashing->group_id}"] = $fleetBashing->time_arrive_to_target; |
| 130 | 130 | } else { |
| 131 | 131 | $bashing_list[] = $fleetBashing->time_arrive_to_target; |
@@ -133,12 +133,12 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | // Check for joining to ACS - if there are already fleets in ACS no checks should be done |
| 136 | - if($mission == MT_AKS && $bashing_list["{$user['id']}_{$fleet_group}"]) { |
|
| 136 | + if ($mission == MT_AKS && $bashing_list["{$user['id']}_{$fleet_group}"]) { |
|
| 137 | 137 | return ATTACK_ALLOWED; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | $query = db_bashing_list_get($user, $planet_dst, $time_limit); |
| 141 | - while($bashing_row = db_fetch($query)) { |
|
| 141 | + while ($bashing_row = db_fetch($query)) { |
|
| 142 | 142 | $bashing_list[] = $bashing_row['bashing_time']; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -147,9 +147,9 @@ discard block |
||
| 147 | 147 | $last_attack = 0; |
| 148 | 148 | $wave = 0; |
| 149 | 149 | $attack = 1; |
| 150 | - foreach($bashing_list as &$bash_time) { |
|
| 150 | + foreach ($bashing_list as &$bash_time) { |
|
| 151 | 151 | $attack++; |
| 152 | - if($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { |
|
| 152 | + if ($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { |
|
| 153 | 153 | $attack = 1; |
| 154 | 154 | $wave++; |
| 155 | 155 | } |
@@ -166,16 +166,16 @@ discard block |
||
| 166 | 166 | //TODO: try..catch |
| 167 | 167 | global $config, $user; |
| 168 | 168 | |
| 169 | - if($user['vacation']) { |
|
| 169 | + if ($user['vacation']) { |
|
| 170 | 170 | return $result = ATTACK_OWN_VACATION; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - if(empty($fleet) || !is_array($fleet)) { |
|
| 173 | + if (empty($fleet) || !is_array($fleet)) { |
|
| 174 | 174 | return $result = ATTACK_NO_FLEET; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | $sn_groups_mission = sn_get_groups('missions'); |
| 178 | - if(!isset($sn_groups_mission[$mission])) { |
|
| 178 | + if (!isset($sn_groups_mission[$mission])) { |
|
| 179 | 179 | return $result = ATTACK_MISSION_ABSENT; |
| 180 | 180 | } |
| 181 | 181 | $sn_data_mission = $sn_groups_mission[$mission]; |
@@ -194,32 +194,32 @@ discard block |
||
| 194 | 194 | $resources = 0; |
| 195 | 195 | $ship_ids = sn_get_groups('fleet'); |
| 196 | 196 | $resource_ids = sn_get_groups('resources_loot'); |
| 197 | - foreach($fleet as $ship_id => $ship_count) { |
|
| 197 | + foreach ($fleet as $ship_id => $ship_count) { |
|
| 198 | 198 | $is_ship = in_array($ship_id, $ship_ids); |
| 199 | 199 | $is_resource = in_array($ship_id, $resource_ids); |
| 200 | - if(!$is_ship && !$is_resource) { |
|
| 200 | + if (!$is_ship && !$is_resource) { |
|
| 201 | 201 | // TODO Спецобработчик для Капитана и модулей |
| 202 | 202 | // return ATTACK_WRONG_UNIT; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - if($ship_count < 0) { |
|
| 205 | + if ($ship_count < 0) { |
|
| 206 | 206 | return $result = $is_ship ? ATTACK_SHIP_COUNT_WRONG : ATTACK_RESOURCE_COUNT_WRONG; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - if($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { |
|
| 209 | + if ($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { |
|
| 210 | 210 | // TODO ATTACK_NO_MISSILE |
| 211 | 211 | return $result = $is_ship ? ATTACK_NO_SHIPS : ATTACK_NO_RESOURCES; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - if($is_ship) { |
|
| 214 | + if ($is_ship) { |
|
| 215 | 215 | $single_ship_data = get_ship_data($ship_id, $user); |
| 216 | - if($single_ship_data[P_SPEED] <= 0) { |
|
| 216 | + if ($single_ship_data[P_SPEED] <= 0) { |
|
| 217 | 217 | return $result = ATTACK_ZERO_SPEED; |
| 218 | 218 | } |
| 219 | 219 | $ships += $ship_count; |
| 220 | 220 | $recyclers += in_array($ship_id, sn_get_groups('flt_recyclers')) ? $ship_count : 0; |
| 221 | 221 | $spies += $ship_id == SHIP_SPY ? $ship_count : 0; |
| 222 | - } elseif($is_resource) { |
|
| 222 | + } elseif ($is_resource) { |
|
| 223 | 223 | $resources += $ship_count; |
| 224 | 224 | } |
| 225 | 225 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | } |
| 231 | 231 | */ |
| 232 | 232 | |
| 233 | - if(isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { |
|
| 233 | + if (isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { |
|
| 234 | 234 | return $result = ATTACK_RESOURCE_FORBIDDEN; |
| 235 | 235 | } |
| 236 | 236 | |
@@ -242,78 +242,78 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | |
| 244 | 244 | $speed = $options['fleet_speed_percent']; |
| 245 | - if($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { |
|
| 245 | + if ($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { |
|
| 246 | 246 | return $result = ATTACK_WRONG_SPEED; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | $travel_data = flt_travel_data($user, $planet_src, $planet_dst, $fleet, $options['fleet_speed_percent']); |
| 250 | 250 | |
| 251 | 251 | |
| 252 | - if(mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { |
|
| 252 | + if (mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { |
|
| 253 | 253 | return $result = ATTACK_NO_FUEL; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - if($travel_data['consumption'] > $travel_data['capacity']) { |
|
| 256 | + if ($travel_data['consumption'] > $travel_data['capacity']) { |
|
| 257 | 257 | return $result = ATTACK_TOO_FAR; |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - if($travel_data['hold'] < $resources) { |
|
| 260 | + if ($travel_data['hold'] < $resources) { |
|
| 261 | 261 | return $result = ATTACK_OVERLOADED; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | $fleet_start_time = SN_TIME_NOW + $travel_data['duration']; |
| 265 | 265 | |
| 266 | 266 | $fleet_group = $options['fleet_group']; |
| 267 | - if($fleet_group) { |
|
| 268 | - if($mission != MT_AKS) { |
|
| 267 | + if ($fleet_group) { |
|
| 268 | + if ($mission != MT_AKS) { |
|
| 269 | 269 | return $result = ATTACK_WRONG_MISSION; |
| 270 | 270 | }; |
| 271 | 271 | |
| 272 | 272 | $acs = db_acs_get_by_group_id($fleet_group); |
| 273 | - if(!$acs['id']) { |
|
| 273 | + if (!$acs['id']) { |
|
| 274 | 274 | return $result = ATTACK_NO_ACS; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - if($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) { |
|
| 277 | + if ($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) { |
|
| 278 | 278 | return $result = ATTACK_ACS_WRONG_TARGET; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - if($fleet_start_time > $acs['ankunft']) { |
|
| 281 | + if ($fleet_start_time > $acs['ankunft']) { |
|
| 282 | 282 | return $result = ATTACK_ACS_TOO_LATE; |
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | $flying_fleets = $options['flying_fleets']; |
| 287 | - if(!$flying_fleets) { |
|
| 287 | + if (!$flying_fleets) { |
|
| 288 | 288 | $flying_fleets = FleetList::fleet_count_flying($user['id']); |
| 289 | 289 | } |
| 290 | - if(GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { |
|
| 290 | + if (GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { |
|
| 291 | 291 | return $result = ATTACK_NO_SLOTS; |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | // В одиночку шпионские зонды могут летать только в миссии Шпионаж, Передислокация и Транспорт |
| 295 | - if($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { |
|
| 295 | + if ($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { |
|
| 296 | 296 | return $result = ATTACK_SPIES_LONLY; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | // Checking for no planet |
| 300 | - if(!$planet_dst['id_owner']) { |
|
| 301 | - if($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { |
|
| 300 | + if (!$planet_dst['id_owner']) { |
|
| 301 | + if ($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { |
|
| 302 | 302 | return $result = ATTACK_NO_COLONIZER; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - if($mission == MT_EXPLORE || $mission == MT_COLONIZE) { |
|
| 305 | + if ($mission == MT_EXPLORE || $mission == MT_COLONIZE) { |
|
| 306 | 306 | return $result = ATTACK_ALLOWED; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | return $result = ATTACK_NO_TARGET; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - if($mission == MT_RECYCLE) { |
|
| 313 | - if($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { |
|
| 312 | + if ($mission == MT_RECYCLE) { |
|
| 313 | + if ($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { |
|
| 314 | 314 | return $result = ATTACK_NO_DEBRIS; |
| 315 | 315 | } |
| 316 | - if($recyclers <= 0) { |
|
| 316 | + if ($recyclers <= 0) { |
|
| 317 | 317 | return $result = ATTACK_NO_RECYCLERS; |
| 318 | 318 | } |
| 319 | 319 | |
@@ -321,8 +321,8 @@ discard block |
||
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | // Got planet. Checking if it is ours |
| 324 | - if($planet_dst['id_owner'] == $user['id']) { |
|
| 325 | - if($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { |
|
| 324 | + if ($planet_dst['id_owner'] == $user['id']) { |
|
| 325 | + if ($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { |
|
| 326 | 326 | return $result = ATTACK_ALLOWED; |
| 327 | 327 | } |
| 328 | 328 | |
@@ -330,19 +330,19 @@ discard block |
||
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | // No, planet not ours. Cutting mission that can't be send to not-ours planet |
| 333 | - if($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { |
|
| 333 | + if ($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { |
|
| 334 | 334 | return $result = ATTACK_WRONG_MISSION; |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | $enemy = db_user_by_id($planet_dst['id_owner']); |
| 338 | 338 | // We cannot attack or send resource to users in VACATION mode |
| 339 | - if($enemy['vacation'] && $mission != MT_RECYCLE) { |
|
| 339 | + if ($enemy['vacation'] && $mission != MT_RECYCLE) { |
|
| 340 | 340 | return $result = ATTACK_VACATION; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | // Multi IP protection |
| 344 | 344 | // TODO: Here we need a procedure to check proxies |
| 345 | - if(sys_is_multiaccount($user, $enemy)) { |
|
| 345 | + if (sys_is_multiaccount($user, $enemy)) { |
|
| 346 | 346 | return $result = ATTACK_SAME_IP; |
| 347 | 347 | } |
| 348 | 348 | |
@@ -350,8 +350,8 @@ discard block |
||
| 350 | 350 | $enemy_points = $enemy['total_points']; |
| 351 | 351 | |
| 352 | 352 | // Is it transport? If yes - checking for buffing to prevent mega-alliance destroyer |
| 353 | - if($mission == MT_TRANSPORT) { |
|
| 354 | - if($user_points >= $enemy_points || $config->allow_buffing) { |
|
| 353 | + if ($mission == MT_TRANSPORT) { |
|
| 354 | + if ($user_points >= $enemy_points || $config->allow_buffing) { |
|
| 355 | 355 | return $result = ATTACK_ALLOWED; |
| 356 | 356 | } else { |
| 357 | 357 | return $result = ATTACK_BUFFING; |
@@ -361,66 +361,66 @@ discard block |
||
| 361 | 361 | // Only aggresive missions passed to this point. HOLD counts as passive but aggresive |
| 362 | 362 | |
| 363 | 363 | // Is it admin with planet protection? |
| 364 | - if($planet_dst['id_level'] > $user['authlevel']) { |
|
| 364 | + if ($planet_dst['id_level'] > $user['authlevel']) { |
|
| 365 | 365 | return $result = ATTACK_ADMIN; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | // Okay. Now skipping protection checks for inactive longer then 1 week |
| 369 | - if(!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) { |
|
| 370 | - if( |
|
| 369 | + if (!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) { |
|
| 370 | + if ( |
|
| 371 | 371 | ($enemy_points <= $config->game_noob_points && $user_points > $config->game_noob_points) |
| 372 | 372 | || |
| 373 | 373 | ($config->game_noob_factor && $user_points > $enemy_points * $config->game_noob_factor) |
| 374 | 374 | ) { |
| 375 | - if($mission != MT_HOLD) { |
|
| 375 | + if ($mission != MT_HOLD) { |
|
| 376 | 376 | return $result = ATTACK_NOOB; |
| 377 | 377 | } |
| 378 | - if($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && $config->ally_help_weak)) { |
|
| 378 | + if ($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && $config->ally_help_weak)) { |
|
| 379 | 379 | return $result = ATTACK_NOOB; |
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | // Is it HOLD mission? If yes - there should be ally deposit |
| 385 | - if($mission == MT_HOLD) { |
|
| 386 | - if(mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { |
|
| 385 | + if ($mission == MT_HOLD) { |
|
| 386 | + if (mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { |
|
| 387 | 387 | return $result = ATTACK_ALLOWED; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | return $result = ATTACK_NO_ALLY_DEPOSIT; |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - if($mission == MT_SPY) { |
|
| 393 | + if ($mission == MT_SPY) { |
|
| 394 | 394 | return $result = $spies >= 1 ? ATTACK_ALLOWED : ATTACK_NO_SPIES; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | // Is it MISSILE mission? |
| 398 | - if($mission == MT_MISSILE) { |
|
| 398 | + if ($mission == MT_MISSILE) { |
|
| 399 | 399 | $sn_data_mip = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET); |
| 400 | - if(mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { |
|
| 400 | + if (mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { |
|
| 401 | 401 | return $result = ATTACK_NO_SILO; |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - if(!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { |
|
| 404 | + if (!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { |
|
| 405 | 405 | return $result = ATTACK_NO_MISSILE; |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | $distance = abs($planet_dst['system'] - $planet_src['system']); |
| 409 | 409 | $mip_range = flt_get_missile_range($user); |
| 410 | - if($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { |
|
| 410 | + if ($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { |
|
| 411 | 411 | return $result = ATTACK_MISSILE_TOO_FAR; |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - if(isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { |
|
| 414 | + if (isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { |
|
| 415 | 415 | return $result = ATTACK_WRONG_STRUCTURE; |
| 416 | 416 | } |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - if($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { |
|
| 419 | + if ($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { |
|
| 420 | 420 | return $result = ATTACK_WRONG_MISSION; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - if($mission == MT_ATTACK || $mission == MT_AKS || $mission == MT_DESTROY) { |
|
| 423 | + if ($mission == MT_ATTACK || $mission == MT_AKS || $mission == MT_DESTROY) { |
|
| 424 | 424 | return $result = flt_bashing_check($user, $enemy, $planet_dst, $mission, $travel_data['duration'], $fleet_group); |
| 425 | 425 | } |
| 426 | 426 | |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | $from = $from['planet']; |
| 448 | 448 | |
| 449 | 449 | $can_attack = flt_can_attack($from, $to, $fleet_REAL_array, $mission, $options); |
| 450 | - if($can_attack != ATTACK_ALLOWED) { |
|
| 450 | + if ($can_attack != ATTACK_ALLOWED) { |
|
| 451 | 451 | $internal_transaction ? sn_db_transaction_rollback() : false; |
| 452 | 452 | |
| 453 | 453 | return $can_attack; |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | $travel_data = flt_travel_data($user, $from, $to, $fleet_REAL_array, $options['fleet_speed_percent']); |
| 459 | 459 | |
| 460 | 460 | $time_on_mission = 0; |
| 461 | - if($mission == MT_EXPLORE || $mission == MT_HOLD) { |
|
| 461 | + if ($mission == MT_EXPLORE || $mission == MT_HOLD) { |
|
| 462 | 462 | // TODO - include some checks about maximum and minumum stay_duration |
| 463 | 463 | $time_on_mission = $options['stay_time'] * 3600; |
| 464 | 464 | } |
@@ -481,14 +481,14 @@ discard block |
||
| 481 | 481 | $sn_group_resources_loot = sn_get_groups('resources_loot'); |
| 482 | 482 | $db_changeset = array(); |
| 483 | 483 | $planet_row_changed_fields = array(); |
| 484 | - foreach($fleet_REAL_array as $unit_id => $amount) { |
|
| 485 | - if(!$amount || !$unit_id) { |
|
| 484 | + foreach ($fleet_REAL_array as $unit_id => $amount) { |
|
| 485 | + if (!$amount || !$unit_id) { |
|
| 486 | 486 | continue; |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | - if(in_array($unit_id, $sn_group_fleet)) { |
|
| 489 | + if (in_array($unit_id, $sn_group_fleet)) { |
|
| 490 | 490 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, -$amount, $user, $from['id']); |
| 491 | - } elseif(in_array($unit_id, $sn_group_resources_loot)) { |
|
| 491 | + } elseif (in_array($unit_id, $sn_group_resources_loot)) { |
|
| 492 | 492 | $planet_row_changed_fields[pname_resource_name($unit_id)]['delta'] -= $amount; |
| 493 | 493 | } |
| 494 | 494 | } |
@@ -527,16 +527,16 @@ discard block |
||
| 527 | 527 | |
| 528 | 528 | $ship_data = array(); |
| 529 | 529 | $fleet_array = array(); |
| 530 | - foreach($ship_list as $transport_id => $cork) { |
|
| 530 | + foreach ($ship_list as $transport_id => $cork) { |
|
| 531 | 531 | $ship_data[$transport_id] = flt_travel_data($user, $from, $to, array($transport_id => 1), 10); |
| 532 | 532 | } |
| 533 | 533 | uasort($ship_data, 'flt_calculate_ship_to_transport_sort'); |
| 534 | 534 | |
| 535 | 535 | $fleet_capacity = 0; |
| 536 | 536 | $fuel_total = $fuel_left = mrc_get_level($user, $from, RES_DEUTERIUM); |
| 537 | - foreach($ship_data as $transport_id => &$ship_info) { |
|
| 537 | + foreach ($ship_data as $transport_id => &$ship_info) { |
|
| 538 | 538 | $ship_loaded = min($ship_list[$transport_id], ceil($resource_amount / $ship_info['hold']), floor($fuel_left / $ship_info['consumption'])); |
| 539 | - if($ship_loaded) { |
|
| 539 | + if ($ship_loaded) { |
|
| 540 | 540 | $fleet_array[$transport_id] = $ship_loaded; |
| 541 | 541 | $resource_amount -= min($resource_amount, $ship_info['hold'] * $ship_loaded); |
| 542 | 542 | $fuel_left -= $ship_info['consumption'] * $ship_loaded; |
@@ -29,6 +29,9 @@ |
||
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | +/** |
|
| 33 | + * @param string $group_name |
|
| 34 | + */ |
|
| 32 | 35 | function flt_spy_scan($target_planet, $group_name, $section_title, $target_user = array()) |
| 33 | 36 | { |
| 34 | 37 | global $lang; |
@@ -11,8 +11,8 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | // ---------------------------------------------------------------------------------------------------------------- |
| 13 | 13 | function coe_compress_add_units($unit_group, $target_planet, &$compress_data, $target_user = array()) { |
| 14 | - foreach($unit_group as $unit_id) { |
|
| 15 | - if(($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
| 14 | + foreach ($unit_group as $unit_id) { |
|
| 15 | + if (($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
| 16 | 16 | $compress_data[$unit_id] = $unit_count; |
| 17 | 17 | } |
| 18 | 18 | } |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | global $lang; |
| 23 | 23 | |
| 24 | 24 | $result = "<tr><td class=\"c\" colspan=\"4\">{$section_title}</td></tr>"; |
| 25 | - foreach(sn_get_groups($group_name) as $unit_id) { |
|
| 26 | - if(($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
| 25 | + foreach (sn_get_groups($group_name) as $unit_id) { |
|
| 26 | + if (($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
| 27 | 27 | $result .= "<tr><td align=\"left\" colspan=\"3\">{$lang['tech'][$unit_id]}</td><td align=\"right\">{$unit_amount}</td></tr>"; |
| 28 | 28 | } |
| 29 | 29 | |
@@ -54,14 +54,14 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | $objFleet = $mission_data->fleet; |
| 56 | 56 | |
| 57 | - if(empty($target_user_row['id']) || empty($target_planet_row['id']) || empty($spying_user_row['id'])) { |
|
| 57 | + if (empty($target_user_row['id']) || empty($target_planet_row['id']) || empty($spying_user_row['id'])) { |
|
| 58 | 58 | $objFleet->mark_fleet_as_returned_and_save(); |
| 59 | 59 | |
| 60 | 60 | return $result; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | $spy_probes = $objFleet->shipCountById(SHIP_SPY); |
| 64 | - if($spy_probes > 0) { |
|
| 64 | + if ($spy_probes > 0) { |
|
| 65 | 65 | $TargetSpyLvl = GetSpyLevel($target_user_row); |
| 66 | 66 | $CurrentSpyLvl = GetSpyLevel($spying_user_row); |
| 67 | 67 | $spy_diff_empire = $CurrentSpyLvl - $TargetSpyLvl; |
@@ -85,19 +85,19 @@ discard block |
||
| 85 | 85 | $spy_message .= "<td width=220>{$lang['sys_deuterium']}</td><td width=220 align=right>" . pretty_number($target_planet_row['deuterium']) . "</td>"; |
| 86 | 86 | $spy_message .= "<td width=220>{$lang['sys_energy']}</td><td width=220 align=right>" . pretty_number($target_planet_row['energy_max']) . "</td>"; |
| 87 | 87 | $spy_message .= "</tr>"; |
| 88 | - if($spy_diff >= 2) { |
|
| 88 | + if ($spy_diff >= 2) { |
|
| 89 | 89 | $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'fleet', $lang['tech'][UNIT_SHIPS], $target_user_row) . "</div>"; |
| 90 | 90 | coe_compress_add_units(sn_get_groups('fleet'), $target_planet_row, $combat_pack[0]); |
| 91 | 91 | } |
| 92 | - if($spy_diff >= 3) { |
|
| 92 | + if ($spy_diff >= 3) { |
|
| 93 | 93 | $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'defense', $lang['tech'][UNIT_DEFENCE], $target_user_row) . "</div>"; |
| 94 | 94 | coe_compress_add_units(sn_get_groups('defense_active'), $target_planet_row, $combat_pack[0]); |
| 95 | 95 | } |
| 96 | - if($spy_diff >= 5) { |
|
| 96 | + if ($spy_diff >= 5) { |
|
| 97 | 97 | $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'structures', $lang['tech'][UNIT_STRUCTURES], $target_user_row) . "</div>"; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if($spy_diff_empire >= 0) { |
|
| 100 | + if ($spy_diff_empire >= 0) { |
|
| 101 | 101 | $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'tech', $lang['tech'][UNIT_TECHNOLOGIES], $target_user_row) . "</div>"; |
| 102 | 102 | coe_compress_add_units(array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR), $target_planet_row, $combat_pack[0], $target_user_row); |
| 103 | 103 | } |
@@ -106,13 +106,13 @@ discard block |
||
| 106 | 106 | $simulator_link = sn_ube_simulator_encode_replay($combat_pack, 'D'); |
| 107 | 107 | |
| 108 | 108 | $target_unit_list = 0; |
| 109 | - foreach(sn_get_groups('fleet') as $unit_id) { |
|
| 109 | + foreach (sn_get_groups('fleet') as $unit_id) { |
|
| 110 | 110 | $target_unit_list += max(0, mrc_get_level($target_user_row, $target_planet_row, $unit_id, false, true)); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | $spy_detected = $spy_probes * $target_unit_list / 4 * pow(2, $TargetSpyLvl - $CurrentSpyLvl); |
| 114 | 114 | |
| 115 | - if(mt_rand(0, 99) > $spy_detected) { |
|
| 115 | + if (mt_rand(0, 99) > $spy_detected) { |
|
| 116 | 116 | $spy_outcome_str = sprintf($lang['sys_mess_spy_detect_chance'], $spy_detected); |
| 117 | 117 | $spy_detected = false; |
| 118 | 118 | } else { |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | $target_message = "{$lang['sys_mess_spy_ennemyfleet']} {$spying_planet_row['name']} " . uni_render_coordinates_href($spying_planet_row, '', 3); |
| 133 | 133 | $target_message .= " {$lang['sys_mess_spy_seen_at']} {$target_planet_row['name']} " . uni_render_coordinates($target_planet_row); |
| 134 | 134 | |
| 135 | - if($spy_detected) { |
|
| 135 | + if ($spy_detected) { |
|
| 136 | 136 | $debris_planet_id = $target_planet_row['planet_type'] == PT_PLANET ? $target_planet_row['id'] : $target_planet_row['parent_planet']; |
| 137 | 137 | |
| 138 | 138 | $spy_cost = get_unit_param(SHIP_SPY, P_COST); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | msg_send_simple_message($objFleet->target_owner_id, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, $lang['sys_mess_spy_control'], $lang['sys_mess_spy_activity'], $target_message); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - if($spy_detected) { |
|
| 152 | + if ($spy_detected) { |
|
| 153 | 153 | $objFleet->db_delete_this_fleet(); |
| 154 | 154 | } else { |
| 155 | 155 | $objFleet->mark_fleet_as_returned_and_save(); |
@@ -26,6 +26,10 @@ |
||
| 26 | 26 | return true; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | +/** |
|
| 30 | + * @param integer $mode |
|
| 31 | + * @param integer $mercenary_id |
|
| 32 | + */ |
|
| 29 | 33 | function mrc_mercenary_hire($mode, $user, $mercenary_id) { |
| 30 | 34 | global $config, $lang, $sn_powerup_buy_discounts; |
| 31 | 35 | |
@@ -62,8 +62,8 @@ |
||
| 62 | 62 | if($mercenary_level) { |
| 63 | 63 | $darkmater_cost = eco_get_total_cost($mercenary_id, $mercenary_level); |
| 64 | 64 | if(!$config->empire_mercenary_temporary && $mercenary_level_old) { |
| 65 | - $darkmater_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level_old); |
|
| 66 | - $darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] -= $darkmater_cost_old[BUILD_CREATE][RES_DARK_MATTER]; |
|
| 65 | + $darkmater_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level_old); |
|
| 66 | + $darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] -= $darkmater_cost_old[BUILD_CREATE][RES_DARK_MATTER]; |
|
| 67 | 67 | } |
| 68 | 68 | $darkmater_cost = ceil($darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] * $mercenary_period * $sn_powerup_buy_discounts[$mercenary_period] / $config->empire_mercenary_base_period); |
| 69 | 69 | } else { |
@@ -7,16 +7,16 @@ discard block |
||
| 7 | 7 | global $config; |
| 8 | 8 | |
| 9 | 9 | $mercenary_info = get_unit_param($mercenary_id); |
| 10 | - if($config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) |
|
| 10 | + if ($config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) |
|
| 11 | 11 | { |
| 12 | 12 | return true; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - if(isset($mercenary_info[P_REQUIRE])) |
|
| 15 | + if (isset($mercenary_info[P_REQUIRE])) |
|
| 16 | 16 | { |
| 17 | - foreach($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) |
|
| 17 | + foreach ($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) |
|
| 18 | 18 | { |
| 19 | - if(mrc_get_level($user, null, $unit_id) < $unit_level) |
|
| 19 | + if (mrc_get_level($user, null, $unit_id) < $unit_level) |
|
| 20 | 20 | { |
| 21 | 21 | return false; |
| 22 | 22 | } |
@@ -33,35 +33,35 @@ discard block |
||
| 33 | 33 | $is_permanent = $mode == UNIT_PLANS || !$config->empire_mercenary_temporary; |
| 34 | 34 | $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? $config->ali_bonus_members : 1); |
| 35 | 35 | $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1; |
| 36 | - if(!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) { |
|
| 36 | + if (!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) { |
|
| 37 | 37 | throw new Exception($lang['mrc_msg_error_wrong_mercenary'], ERR_ERROR); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if(!mrc_officer_accessible($user, $mercenary_id)) { |
|
| 40 | + if (!mrc_officer_accessible($user, $mercenary_id)) { |
|
| 41 | 41 | throw new Exception($lang['mrc_msg_error_requirements'], ERR_ERROR); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | $mercenary_level = sys_get_param_int('mercenary_level'); |
| 45 | - if($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) { |
|
| 45 | + if ($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) { |
|
| 46 | 46 | throw new Exception($lang['mrc_msg_error_wrong_level'], ERR_ERROR); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) { |
|
| 49 | + if ($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) { |
|
| 50 | 50 | throw new Exception($lang['mrc_msg_error_wrong_period'], ERR_ERROR); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | sn_db_transaction_start(); |
| 54 | 54 | |
| 55 | 55 | $mercenary_level_old = mrc_get_level($user, $planetrow, $mercenary_id, true, true); |
| 56 | - if($config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) { |
|
| 56 | + if ($config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) { |
|
| 57 | 57 | throw new Exception($lang['mrc_msg_error_already_hired'], ERR_ERROR); // Can't hire already hired temp mercenary - dismiss first |
| 58 | - } elseif($config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) { |
|
| 58 | + } elseif ($config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) { |
|
| 59 | 59 | throw new Exception('', ERR_NONE); // Can't dismiss (!$mercenary_level) not hired (!$mercenary_level_old) temp mercenary. But no error |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if($mercenary_level) { |
|
| 62 | + if ($mercenary_level) { |
|
| 63 | 63 | $darkmater_cost = eco_get_total_cost($mercenary_id, $mercenary_level); |
| 64 | - if(!$config->empire_mercenary_temporary && $mercenary_level_old) { |
|
| 64 | + if (!$config->empire_mercenary_temporary && $mercenary_level_old) { |
|
| 65 | 65 | $darkmater_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level_old); |
| 66 | 66 | $darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] -= $darkmater_cost_old[BUILD_CREATE][RES_DARK_MATTER]; |
| 67 | 67 | } |
@@ -71,13 +71,13 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | $darkmater_cost *= $cost_alliance_multiplyer; |
| 73 | 73 | |
| 74 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) { |
|
| 74 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) { |
|
| 75 | 75 | throw new Exception($lang['mrc_msg_error_no_resource'], ERR_ERROR); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if(($darkmater_cost && $mercenary_level) || !$is_permanent) { |
|
| 78 | + if (($darkmater_cost && $mercenary_level) || !$is_permanent) { |
|
| 79 | 79 | $unit_row = db_unit_by_location($user['id'], LOC_USER, $user['id'], $mercenary_id); |
| 80 | - if(is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) { |
|
| 80 | + if (is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) { |
|
| 81 | 81 | $dismiss_full_cost = eco_get_total_cost($mercenary_id, $unit_row['unit_level']); |
| 82 | 82 | $dismiss_full_cost = $dismiss_full_cost[BUILD_CREATE][RES_DARK_MATTER]; |
| 83 | 83 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | db_unit_list_delete($user['id'], LOC_USER, $user['id'], $mercenary_id); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if($darkmater_cost && $mercenary_level) { |
|
| 98 | + if ($darkmater_cost && $mercenary_level) { |
|
| 99 | 99 | db_unit_set_insert( |
| 100 | 100 | "unit_player_id = {$user['id']}, |
| 101 | 101 | unit_location_type = " . LOC_USER . ", |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | $mode = in_array($mode, array(UNIT_MERCENARIES, UNIT_PLANS)) ? $mode : UNIT_MERCENARIES; |
| 131 | 131 | $is_permanent = $mode == UNIT_PLANS || !$config->empire_mercenary_temporary; |
| 132 | 132 | |
| 133 | - if($mercenary_id = sys_get_param_int('mercenary_id')) |
|
| 133 | + if ($mercenary_id = sys_get_param_int('mercenary_id')) |
|
| 134 | 134 | { |
| 135 | 135 | $operation_result = mrc_mercenary_hire($mode, $user, $mercenary_id); |
| 136 | 136 | } |
@@ -139,12 +139,12 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | $template = gettemplate('mrc_mercenary_hire', true); |
| 141 | 141 | |
| 142 | - if(!empty($operation_result)) |
|
| 142 | + if (!empty($operation_result)) |
|
| 143 | 143 | { |
| 144 | 144 | $template->assign_block_vars('result', $operation_result); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - foreach($sn_powerup_buy_discounts as $hire_period => $hire_discount) |
|
| 147 | + foreach ($sn_powerup_buy_discounts as $hire_period => $hire_discount) |
|
| 148 | 148 | { |
| 149 | 149 | $template->assign_block_vars('period', array( |
| 150 | 150 | 'LENGTH' => $hire_period, |
@@ -157,13 +157,13 @@ discard block |
||
| 157 | 157 | $user_dark_matter = mrc_get_level($user, '', RES_DARK_MATTER); |
| 158 | 158 | $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? $config->ali_bonus_members : 1); |
| 159 | 159 | $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1; |
| 160 | - foreach(sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) |
|
| 160 | + foreach (sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) |
|
| 161 | 161 | { |
| 162 | 162 | { |
| 163 | 163 | $mercenary = get_unit_param($mercenary_id); |
| 164 | 164 | $mercenary_bonus = $mercenary['bonus']; |
| 165 | 165 | $mercenary_bonus = $mercenary_bonus >= 0 ? "+{$mercenary_bonus}" : "{$mercenary_bonus}"; |
| 166 | - switch($mercenary['bonus_type']) |
|
| 166 | + switch ($mercenary['bonus_type']) |
|
| 167 | 167 | { |
| 168 | 168 | case BONUS_PERCENT: |
| 169 | 169 | $mercenary_bonus = "{$mercenary_bonus}% "; |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | $mercenary_level = mrc_get_level($user, null, $mercenary_id, false, true); |
| 182 | 182 | $mercenary_level_bonus = max(0, mrc_get_level($user, null, $mercenary_id) - $mercenary_level); |
| 183 | 183 | $total_cost_old = 0; |
| 184 | - if($is_permanent) |
|
| 184 | + if ($is_permanent) |
|
| 185 | 185 | { |
| 186 | 186 | $total_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level); |
| 187 | 187 | $total_cost_old = $total_cost_old[BUILD_CREATE][RES_DARK_MATTER] * $cost_alliance_multiplyer; |
@@ -205,13 +205,13 @@ discard block |
||
| 205 | 205 | 'BONUS_TYPE' => $mercenary['bonus_type'], |
| 206 | 206 | 'HIRE_END' => $mercenary_time_finish && $mercenary_time_finish >= SN_TIME_NOW ? date(FMT_DATE_TIME, $mercenary_time_finish) : '', |
| 207 | 207 | 'HIRE_LEFT_PERCENT' => $mercenary_time_finish && $mercenary_time_finish >= SN_TIME_NOW |
| 208 | - ? round(($mercenary_time_finish - SN_TIME_NOW)/($mercenary_time_finish - $mercenary_time_start) * 100, 1) |
|
| 208 | + ? round(($mercenary_time_finish - SN_TIME_NOW) / ($mercenary_time_finish - $mercenary_time_start) * 100, 1) |
|
| 209 | 209 | : 0, |
| 210 | 210 | 'CAN_BUY' => mrc_officer_accessible($user, $mercenary_id), |
| 211 | 211 | )); |
| 212 | 212 | |
| 213 | 213 | $upgrade_cost = 1; |
| 214 | - for($i = $config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) |
|
| 214 | + for ($i = $config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) |
|
| 215 | 215 | { |
| 216 | 216 | $total_cost = eco_get_total_cost($mercenary_id, $i); |
| 217 | 217 | $total_cost[BUILD_CREATE][RES_DARK_MATTER] *= $cost_alliance_multiplyer; |
@@ -46,11 +46,11 @@ discard block |
||
| 46 | 46 | )); |
| 47 | 47 | }; |
| 48 | 48 | |
| 49 | -$ValidList['percent'] = array ( 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 ); |
|
| 49 | +$ValidList['percent'] = array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100); |
|
| 50 | 50 | $template = gettemplate('resources', true); |
| 51 | 51 | |
| 52 | 52 | $transmutation_result = sn_sys_planet_core_transmute($user, $planetrow); |
| 53 | -if(!empty($transmutation_result)) |
|
| 53 | +if (!empty($transmutation_result)) |
|
| 54 | 54 | { |
| 55 | 55 | $template->assign_block_vars('result', $transmutation_result); // array('STATUS' => $transmutation_result['STATUS'], 'MESSAGE' => $transmutation_result['MESSAGE'])); |
| 56 | 56 | } |
@@ -59,20 +59,20 @@ discard block |
||
| 59 | 59 | $production = $_POST['production']; |
| 60 | 60 | //$SubQry = ''; |
| 61 | 61 | $SubQry = array(); |
| 62 | -if(is_array($production)) { |
|
| 63 | - foreach($production as $prod_id => $percent) { |
|
| 64 | - if($percent > 100 || $percent < 0) { |
|
| 62 | +if (is_array($production)) { |
|
| 63 | + foreach ($production as $prod_id => $percent) { |
|
| 64 | + if ($percent > 100 || $percent < 0) { |
|
| 65 | 65 | $debug->warning('Supplying wrong production percent (less then 0 or greater then 100)', 'Hack attempt', 302, array('base_dump' => true)); |
| 66 | 66 | die(); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | $prod_id = intval($prod_id); |
| 70 | - if(in_array($prod_id, $sn_group_factories) && get_unit_param($prod_id, P_MINING_IS_MANAGED)) { |
|
| 70 | + if (in_array($prod_id, $sn_group_factories) && get_unit_param($prod_id, P_MINING_IS_MANAGED)) { |
|
| 71 | 71 | $field_name = pname_factory_production_field_name($prod_id); |
| 72 | 72 | $percent = floor($percent / 10); |
| 73 | 73 | $planetrow[$field_name] = $percent; |
| 74 | 74 | //$SubQry .= "`{$field_name}` = '{$percent}',"; |
| 75 | - $SubQry[] = "`{$field_name}` = '{$percent}'"; |
|
| 75 | + $SubQry[] = "`{$field_name}` = '{$percent}'"; |
|
| 76 | 76 | } else { |
| 77 | 77 | $debug->warning('Supplying wrong ID in production array - attempt to change some field - ID' . $prod_id, 'Resource Page', 301); |
| 78 | 78 | continue; |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | 'ENERGY_TYPE' => pretty_number($caps_real['production'][RES_ENERGY][0], true, true), |
| 109 | 109 | )); |
| 110 | 110 | |
| 111 | -foreach($sn_group_factories as $unit_id) |
|
| 111 | +foreach ($sn_group_factories as $unit_id) |
|
| 112 | 112 | { |
| 113 | - if(mrc_get_level($user, $planetrow, $unit_id) > 0 && get_unit_param($unit_id)) |
|
| 113 | + if (mrc_get_level($user, $planetrow, $unit_id) > 0 && get_unit_param($unit_id)) |
|
| 114 | 114 | { |
| 115 | 115 | $level_plain = mrc_get_level($user, $planetrow, $unit_id, false, true); |
| 116 | 116 | $template->assign_block_vars('production', array( |
@@ -92,9 +92,9 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | for ($Option = 10; $Option >= 0; $Option--) |
| 94 | 94 | { |
| 95 | - $template->assign_block_vars('option', array( |
|
| 96 | - 'VALUE' => $Option * 10, |
|
| 97 | - )); |
|
| 95 | + $template->assign_block_vars('option', array( |
|
| 96 | + 'VALUE' => $Option * 10, |
|
| 97 | + )); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | $caps_real = eco_get_planet_caps($user, $planetrow, 3600); |
@@ -163,14 +163,14 @@ discard block |
||
| 163 | 163 | int_calc_storage_bar(RES_DEUTERIUM); |
| 164 | 164 | |
| 165 | 165 | $template->assign_vars(array( |
| 166 | - 'PLANET_NAME' => $planetrow['name'], |
|
| 167 | - 'PLANET_TYPE' => $planetrow['planet_type'], |
|
| 168 | - 'PLANET_DENSITY_INDEX' => $planet_density_index, |
|
| 169 | - 'PLANET_CORE_TEXT' => classLocale::$lang['uni_planet_density_types'][$planet_density_index], |
|
| 166 | + 'PLANET_NAME' => $planetrow['name'], |
|
| 167 | + 'PLANET_TYPE' => $planetrow['planet_type'], |
|
| 168 | + 'PLANET_DENSITY_INDEX' => $planet_density_index, |
|
| 169 | + 'PLANET_CORE_TEXT' => classLocale::$lang['uni_planet_density_types'][$planet_density_index], |
|
| 170 | 170 | |
| 171 | - 'PRODUCTION_LEVEL' => floor($caps_real['efficiency'] * 100), |
|
| 171 | + 'PRODUCTION_LEVEL' => floor($caps_real['efficiency'] * 100), |
|
| 172 | 172 | |
| 173 | - 'PAGE_HINT' => classLocale::$lang['res_hint'], |
|
| 173 | + 'PAGE_HINT' => classLocale::$lang['res_hint'], |
|
| 174 | 174 | )); |
| 175 | 175 | |
| 176 | 176 | display($template, classLocale::$lang['res_planet_production']); |
@@ -39,8 +39,8 @@ |
||
| 39 | 39 | 0 => $row['visit_time'], // start |
| 40 | 40 | 1 => $row['visit_time'], // end |
| 41 | 41 | ) |
| 42 | - //: false |
|
| 43 | - ; |
|
| 42 | + //: false |
|
| 43 | + ; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | $session_list = array(); |
@@ -12,20 +12,20 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
| 14 | 14 | |
| 15 | -if($user['authlevel'] < 3) { |
|
| 15 | +if ($user['authlevel'] < 3) { |
|
| 16 | 16 | AdminMessage($lang['adm_err_denied']); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | // define('SESSION_INTERRUPT', 15*60); // Можно увеличить до 4 часов - никито не может сидеть 2 суток с перерывом менее 4 часов |
| 20 | 20 | // define('SUSPICIOUS_LONG', 2 * 60*60); // Тогда это увеличиваем до, скажем суток - и там смотрим |
| 21 | 21 | |
| 22 | -define('SESSION_INTERRUPT', 1 * 60*60); // Можно увеличить до 4 часов - никито не может сидеть 2 суток с перерывом менее 4 часов |
|
| 23 | -define('SUSPICIOUS_LONG', 16 * 60*60); // Тогда это увеличиваем до, скажем суток - и там смотрим |
|
| 22 | +define('SESSION_INTERRUPT', 1 * 60 * 60); // Можно увеличить до 4 часов - никито не может сидеть 2 суток с перерывом менее 4 часов |
|
| 23 | +define('SUSPICIOUS_LONG', 16 * 60 * 60); // Тогда это увеличиваем до, скажем суток - и там смотрим |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | function check_suspicious(&$session, &$session_list_last_id, &$row) { |
| 27 | 27 | $session[2] = $session[1] - $session[0]; |
| 28 | - if($session[2] > SUSPICIOUS_LONG) |
|
| 28 | + if ($session[2] > SUSPICIOUS_LONG) |
|
| 29 | 29 | { |
| 30 | 30 | $session[2] = pretty_time($session[2]); |
| 31 | 31 | $session[0] = date(FMT_DATE_TIME_SQL, $session[0]); |
@@ -46,24 +46,24 @@ discard block |
||
| 46 | 46 | $session_list = array(); |
| 47 | 47 | $query = doquery("SELECT `visit_time`, user_id FROM {{counter}} where user_id <> 0 and visit_time > UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 7 DAY)) order by user_id, visit_time;"); |
| 48 | 48 | $session = array(); |
| 49 | -if($row = db_fetch($query)) { |
|
| 49 | +if ($row = db_fetch($query)) { |
|
| 50 | 50 | $session = array( |
| 51 | 51 | 0 => strtotime($row['visit_time']), // start |
| 52 | 52 | 1 => strtotime($row['visit_time']), // end |
| 53 | 53 | ); |
| 54 | 54 | $last_id = $row['user_id']; |
| 55 | 55 | } |
| 56 | -while($row = db_fetch($query)) { |
|
| 56 | +while ($row = db_fetch($query)) { |
|
| 57 | 57 | $row['visit_time'] = strtotime($row['visit_time']); |
| 58 | - if($last_id == $row['user_id']) { |
|
| 58 | + if ($last_id == $row['user_id']) { |
|
| 59 | 59 | // Тот же юзер |
| 60 | - if($row['visit_time'] - $session[1] <= SESSION_INTERRUPT) { // Та же сессия |
|
| 60 | + if ($row['visit_time'] - $session[1] <= SESSION_INTERRUPT) { // Та же сессия |
|
| 61 | 61 | $session[1] = $row['visit_time']; |
| 62 | 62 | } else { |
| 63 | 63 | // Новая сессия |
| 64 | 64 | // check_suspicious($session, $session_list[$last_id], $row); |
| 65 | 65 | $session[2] = $session[1] - $session[0]; |
| 66 | - if($session[2] > SUSPICIOUS_LONG) |
|
| 66 | + if ($session[2] > SUSPICIOUS_LONG) |
|
| 67 | 67 | { |
| 68 | 68 | $session[2] = pretty_time($session[2]); |
| 69 | 69 | $session[0] = date(FMT_DATE_TIME_SQL, $session[0]); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | } else { |
| 79 | 79 | // check_suspicious($session, $session_list[$last_id], $row); |
| 80 | 80 | $session[2] = $session[1] - $session[0]; |
| 81 | - if($session[2] > SUSPICIOUS_LONG) |
|
| 81 | + if ($session[2] > SUSPICIOUS_LONG) |
|
| 82 | 82 | { |
| 83 | 83 | $session[2] = pretty_time($session[2]); |
| 84 | 84 | $session[0] = date(FMT_DATE_TIME_SQL, $session[0]); |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | -if($last_id) { |
|
| 96 | +if ($last_id) { |
|
| 97 | 97 | // check_suspicious($session, $session_list[$last_id], $row = array('time' => 0)); |
| 98 | 98 | $session[2] = $session[1] - $session[0]; |
| 99 | 99 | |
| 100 | - if($session[2] > SUSPICIOUS_LONG) |
|
| 100 | + if ($session[2] > SUSPICIOUS_LONG) |
|
| 101 | 101 | { |
| 102 | 102 | $session[2] = pretty_time($session[2]); |
| 103 | 103 | $session[0] = date(FMT_DATE_TIME_SQL, $session[0]); |
@@ -111,9 +111,9 @@ discard block |
||
| 111 | 111 | print("<td>ID</td><td>Username</td><td>Start</td><td>End</td><td>Length</td>"); |
| 112 | 112 | print("<td>Last online</td>"); |
| 113 | 113 | print("</tr>"); |
| 114 | -foreach($session_list as $user_id => $value) { |
|
| 114 | +foreach ($session_list as $user_id => $value) { |
|
| 115 | 115 | $user_record = doquery("SELECT `username`, onlinetime FROM {{users}} WHERE id = {$user_id};", true); |
| 116 | - foreach($value as $interval_data) { |
|
| 116 | + foreach ($value as $interval_data) { |
|
| 117 | 117 | print("<tr>"); |
| 118 | 118 | print("<td>{$user_id}</td><td>{$user_record['username']}</td><td>{$interval_data[0]}</td><td>{$interval_data[1]}</td><td>{$interval_data[2]}</td>"); |
| 119 | 119 | print("<td>" . date(FMT_DATE_TIME_SQL, $user_record['onlinetime']) . "</td>"); |
@@ -14,14 +14,14 @@ |
||
| 14 | 14 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
| 15 | 15 | |
| 16 | 16 | // if ($user['authlevel'] < 2) |
| 17 | -if($user['authlevel'] < 3) |
|
| 17 | +if ($user['authlevel'] < 3) |
|
| 18 | 18 | { |
| 19 | 19 | AdminMessage($lang['adm_err_denied']); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | $template = gettemplate("admin/add_moon", true); |
| 23 | 23 | |
| 24 | -if(sys_get_param_str('mode') == 'addit') |
|
| 24 | +if (sys_get_param_str('mode') == 'addit') |
|
| 25 | 25 | { |
| 26 | 26 | $PlanetID = sys_get_param_id('user'); |
| 27 | 27 | $MoonName = sys_get_param_str('name'); |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
| 8 | 8 | |
| 9 | 9 | // if($user['authlevel'] < 2) |
| 10 | -if($user['authlevel'] < 3) |
|
| 10 | +if ($user['authlevel'] < 3) |
|
| 11 | 11 | { |
| 12 | 12 | AdminMessage($lang['adm_err_denied']); |
| 13 | 13 | } |
@@ -21,30 +21,30 @@ discard block |
||
| 21 | 21 | $planet_id = sys_get_param_id('planet_id'); |
| 22 | 22 | |
| 23 | 23 | $unit_list = sys_get_param('unit_list'); |
| 24 | -if(sys_get_param('change_data') && !empty($unit_list)) |
|
| 24 | +if (sys_get_param('change_data') && !empty($unit_list)) |
|
| 25 | 25 | { |
| 26 | 26 | $query_string = array(); |
| 27 | - foreach($unit_list as $unit_id => $unit_amount) |
|
| 27 | + foreach ($unit_list as $unit_id => $unit_amount) |
|
| 28 | 28 | { |
| 29 | - if($unit_query_string = admin_planet_edit_query_string($unit_id, $unit_amount, $mode)) |
|
| 29 | + if ($unit_query_string = admin_planet_edit_query_string($unit_id, $unit_amount, $mode)) |
|
| 30 | 30 | { |
| 31 | 31 | $query_string[] = $unit_query_string; |
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if(!empty($query_string)) |
|
| 35 | + if (!empty($query_string)) |
|
| 36 | 36 | { |
| 37 | 37 | db_planet_set_by_id($planet_id, implode(', ', $query_string)); |
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | -if($planet_id) |
|
| 41 | +if ($planet_id) |
|
| 42 | 42 | { |
| 43 | 43 | $edit_planet_row = db_planet_by_id($planet_id); |
| 44 | 44 | admin_planet_edit_template($template, $edit_planet_row, $mode); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | -foreach($admin_planet_edit_mode_list as $page_mode => $mode_locale) |
|
| 47 | +foreach ($admin_planet_edit_mode_list as $page_mode => $mode_locale) |
|
| 48 | 48 | { |
| 49 | 49 | $template->assign_block_vars('page_menu', array( |
| 50 | 50 | 'ID' => $page_mode, |
@@ -7,13 +7,13 @@ |
||
| 7 | 7 | * |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -define('INSIDE' , true); |
|
| 11 | -define('INSTALL' , false); |
|
| 12 | -define('IN_ADMIN' , true); |
|
| 10 | +define('INSIDE', true); |
|
| 11 | +define('INSTALL', false); |
|
| 12 | +define('IN_ADMIN', true); |
|
| 13 | 13 | |
| 14 | 14 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
| 15 | 15 | |
| 16 | -if($user['authlevel'] < 2) |
|
| 16 | +if ($user['authlevel'] < 2) |
|
| 17 | 17 | { |
| 18 | 18 | AdminMessage($lang['adm_err_denied']); |
| 19 | 19 | } |