@@ -24,11 +24,11 @@ |
||
24 | 24 | |
25 | 25 | // require_once('includes/includes/scheduler_process.php'); |
26 | 26 | |
27 | -if(($result = scheduler_process()) && !defined('IN_ADMIN')) { |
|
27 | +if (($result = scheduler_process()) && !defined('IN_ADMIN')) { |
|
28 | 28 | $result = htmlspecialchars($result, ENT_QUOTES, 'UTF-8'); |
29 | 29 | print(json_encode($result)); |
30 | 30 | } |
31 | 31 | |
32 | -if(!defined('IN_ADMIN')) { |
|
32 | +if (!defined('IN_ADMIN')) { |
|
33 | 33 | die(); |
34 | 34 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
4 | 4 | { |
5 | 5 | $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
6 | 6 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | header('Location: alliance.php'); |
21 | 21 | } |
22 | 22 | |
23 | - if($user_request['request_denied']) |
|
23 | + if ($user_request['request_denied']) |
|
24 | 24 | { |
25 | 25 | $lang['request_text'] = sprintf($lang['ali_req_deny_msg'], $ally['ally_tag'], $user_request['request_text']); |
26 | 26 | } |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | |
43 | 43 | $ally = doquery("SELECT * FROM {{alliance}} WHERE `id` ='{$id_ally}'", true); |
44 | 44 | |
45 | -if(!$ally) |
|
45 | +if (!$ally) |
|
46 | 46 | { |
47 | 47 | message($lang['ali_sys_notFound'], $lang['ali_req_title']); |
48 | 48 | } |
49 | 49 | |
50 | -if($ally['ally_request_notallow']) |
|
50 | +if ($ally['ally_request_notallow']) |
|
51 | 51 | { |
52 | 52 | message($lang['ali_req_not_allowed'], $lang['ali_req_title']); |
53 | 53 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | // $same_user = false; |
54 | 54 | // } |
55 | 55 | |
56 | - if(!$user_data) { |
|
56 | + if (!$user_data) { |
|
57 | 57 | message($lang['imp_imperator_none'], $lang['sys_error'], 'index.php', 10); |
58 | 58 | die(); |
59 | 59 | } |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | $stat_array = array(); |
65 | 65 | $query = doquery("SELECT * FROM {{statpoints}} WHERE `stat_type` = 1 AND `id_owner` = {$user_id} ORDER BY `stat_code` DESC;"); |
66 | 66 | $stat_count = classSupernova::$db->db_affected_rows(); |
67 | - while($row = db_fetch($query)) { |
|
68 | - foreach($stat_fields as $field_db_name => $field_template_name) { |
|
67 | + while ($row = db_fetch($query)) { |
|
68 | + foreach ($stat_fields as $field_db_name => $field_template_name) { |
|
69 | 69 | // $stat_count - $row['stat_code'] - для реверсирования ID статы в JS |
70 | 70 | $stat_array[$field_template_name]['DATA'][$stat_count - $row['stat_code']] = $row[$field_db_name]; |
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | 74 | $stat_array_date = $stat_array['STAT_DATE']; |
75 | - foreach($stat_array_date['DATA'] as $key => $value) { |
|
75 | + foreach ($stat_array_date['DATA'] as $key => $value) { |
|
76 | 76 | $template->assign_block_vars('stat_date', array( |
77 | 77 | 'ID' => $key, |
78 | 78 | 'VALUE' => $value, |
@@ -85,17 +85,17 @@ discard block |
||
85 | 85 | |
86 | 86 | unset($stat_array['STAT_DATE']); |
87 | 87 | $template_data = array(); |
88 | - foreach($stat_array as $stat_type => &$stat_type_data) { |
|
88 | + foreach ($stat_array as $stat_type => &$stat_type_data) { |
|
89 | 89 | $reverse_min_max = strpos($stat_type, '_RANK') !== false; |
90 | 90 | $stat_type_data['MIN'] = $reverse_min_max ? max($stat_type_data['DATA']) : min($stat_type_data['DATA']); |
91 | 91 | $stat_type_data['MAX'] = $reverse_min_max ? min($stat_type_data['DATA']) : max($stat_type_data['DATA']); |
92 | 92 | $stat_type_data['AVG'] = average($stat_type_data['DATA']); |
93 | - foreach($stat_type_data['DATA'] as $key => $value) { |
|
93 | + foreach ($stat_type_data['DATA'] as $key => $value) { |
|
94 | 94 | // $stat_type_data['PERCENT'][$key] = $stat_type_data['MAX'] - $value ? ($stat_type_data['MAX'] - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $value) : 100; |
95 | 95 | $stat_type_data['PERCENT'][$key] = ($stat_type_data['MAX'] - $value ? ($value - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $stat_type_data['MIN']) : 1) * 100; |
96 | 96 | $template_data[$stat_type][$key]['ID'] = $key; |
97 | 97 | $template_data[$stat_type][$key]['VALUE'] = $value; |
98 | - $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']); |
|
98 | + $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']); |
|
99 | 99 | $template_data[$stat_type][$key]['PERCENT'] = $stat_type_data['PERCENT'][$key]; |
100 | 100 | |
101 | 101 | //$template_data[$stat_type][$key]['PERCENT'] = $key ? $stat_type_data['PERCENT'][$key] : 50; // TODO DEBUG |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | } |
104 | 104 | // pdump($stat_array['RES_POINTS']); |
105 | 105 | |
106 | - foreach($template_data as $stat_type => $stat_type_data) { |
|
106 | + foreach ($template_data as $stat_type => $stat_type_data) { |
|
107 | 107 | $template->assign_block_vars('stat', array( |
108 | 108 | 'TYPE' => $stat_type, |
109 | 109 | 'TEXT' => $lang['imp_stat_types'][$stat_type], |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | 'MAX' => $stat_array[$stat_type]['MAX'], |
112 | 112 | 'AVG' => $stat_array[$stat_type]['AVG'], |
113 | 113 | )); |
114 | - foreach($stat_type_data as $stat_entry) { |
|
114 | + foreach ($stat_type_data as $stat_entry) { |
|
115 | 115 | $template->assign_block_vars('stat.entry', $stat_entry); |
116 | 116 | } |
117 | 117 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | // pdump($template_data); |
121 | 121 | |
122 | - if($same_user) { |
|
122 | + if ($same_user) { |
|
123 | 123 | rpg_level_up($user, RPG_STRUCTURE); |
124 | 124 | rpg_level_up($user, RPG_RAID); |
125 | 125 | rpg_level_up($user, RPG_TECH); |
@@ -153,29 +153,29 @@ discard block |
||
153 | 153 | 'builder_xp' => pretty_number($user_data['xpminier']), |
154 | 154 | 'builder_lvl' => pretty_number($user_data['lvl_minier']), |
155 | 155 | 'builder_lvl_st' => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'])), |
156 | - 'builder_lvl_up' => pretty_number(rpg_get_miner_xp($user_data['lvl_minier']+1)), |
|
156 | + 'builder_lvl_up' => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'] + 1)), |
|
157 | 157 | 'raid_xp' => pretty_number($user_data['xpraid']), |
158 | 158 | 'raid_lvl' => pretty_number($user_data['lvl_raid']), |
159 | - 'raid_lvl_up' => pretty_number(rpg_get_raider_xp($user_data['lvl_raid']+1)), |
|
159 | + 'raid_lvl_up' => pretty_number(rpg_get_raider_xp($user_data['lvl_raid'] + 1)), |
|
160 | 160 | 'raids' => pretty_number($user_data['raids']), |
161 | 161 | 'raidswin' => pretty_number($user_data['raidswin']), |
162 | 162 | 'raidsloose' => pretty_number($user_data['raidsloose']), |
163 | 163 | 'tech_xp' => pretty_number($user_data['player_rpg_tech_xp']), |
164 | 164 | 'tech_lvl' => pretty_number($user_data['player_rpg_tech_level']), |
165 | 165 | 'tech_lvl_st' => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'])), |
166 | - 'tech_lvl_up' => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level']+1)), |
|
166 | + 'tech_lvl_up' => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'] + 1)), |
|
167 | 167 | |
168 | 168 | 'explore_xp' => pretty_number($user_data['player_rpg_explore_xp']), |
169 | 169 | 'explore_lvl' => pretty_number($user_data['player_rpg_explore_level']), |
170 | 170 | 'explore_lvl_st' => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'])), |
171 | - 'explore_lvl_up' => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level']+1)), |
|
172 | - |
|
173 | - 'build_points' => pretty_number( $StatRecord['build_points'] ), |
|
174 | - 'tech_points' => pretty_number( $StatRecord['tech_points'] ), |
|
175 | - 'fleet_points' => pretty_number( $StatRecord['fleet_points'] ), |
|
176 | - 'defs_points' => pretty_number( $StatRecord['defs_points'] ), |
|
177 | - 'res_points' => pretty_number( $StatRecord['res_points'] ), |
|
178 | - 'total_points' => pretty_number( $StatRecord['total_points'] ), |
|
171 | + 'explore_lvl_up' => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'] + 1)), |
|
172 | + |
|
173 | + 'build_points' => pretty_number($StatRecord['build_points']), |
|
174 | + 'tech_points' => pretty_number($StatRecord['tech_points']), |
|
175 | + 'fleet_points' => pretty_number($StatRecord['fleet_points']), |
|
176 | + 'defs_points' => pretty_number($StatRecord['defs_points']), |
|
177 | + 'res_points' => pretty_number($StatRecord['res_points']), |
|
178 | + 'total_points' => pretty_number($StatRecord['total_points']), |
|
179 | 179 | 'user_rank' => $StatRecord['total_rank'], |
180 | 180 | 'RANK_DIFF' => $StatRecord['total_old_rank'] - $StatRecord['total_rank'], |
181 | 181 |
@@ -14,14 +14,14 @@ |
||
14 | 14 | global $lang, $user, $planetrow; |
15 | 15 | |
16 | 16 | $tech_tree = array(); |
17 | - foreach(get_unit_param('techtree') as $unit_group_id => $unit_list) |
|
17 | + foreach (get_unit_param('techtree') as $unit_group_id => $unit_list) |
|
18 | 18 | { |
19 | 19 | $tech_tree[] = array( |
20 | 20 | 'NAME' => $lang['tech'][$unit_group_id], |
21 | 21 | 'GROUP_ID' => $unit_group_id, |
22 | 22 | ); |
23 | 23 | |
24 | - foreach($unit_list as $unit_id) |
|
24 | + foreach ($unit_list as $unit_id) |
|
25 | 25 | { |
26 | 26 | $sn_data_unit = get_unit_param($unit_id); |
27 | 27 | $level_basic = $sn_data_unit[P_STACKABLE] ? 0 : mrc_get_level($user, $planetrow, $unit_id, false, true); |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | function eco_get_planet_caps_modify_production(&$item, $key, $data) { |
4 | 4 | static $modifiers; |
5 | 5 | |
6 | - if(!$modifiers) { |
|
6 | + if (!$modifiers) { |
|
7 | 7 | $modifiers = sn_get_groups('modifiers'); |
8 | 8 | } |
9 | 9 | $item = floor(mrc_modify_value($data['user'], $data['planet'], $modifiers[MODIFIER_RESOURCE_PRODUCTION], $item)); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | static $sn_group_modifiers, $config_resource_multiplier, $config_resource_multiplier_plain, $config_eco_scale_storage; |
17 | 17 | |
18 | - if(!$sn_group_modifiers) { |
|
18 | + if (!$sn_group_modifiers) { |
|
19 | 19 | $sn_group_modifiers = sn_get_groups('modifiers'); |
20 | 20 | $config_resource_multiplier = game_resource_multiplier(); |
21 | 21 | $config_resource_multiplier_plain = game_resource_multiplier(true); |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | $caps['storage'][RES_METAL][0] = $config->eco_planet_storage_metal; |
27 | 27 | $caps['storage'][RES_CRYSTAL][0] = $config->eco_planet_storage_crystal; |
28 | 28 | $caps['storage'][RES_DEUTERIUM][0] = $config->eco_planet_storage_deuterium; |
29 | - foreach(sn_get_groups('storages') as $unit_id) { |
|
30 | - foreach(get_unit_param($unit_id, P_STORAGE) as $resource_id => $function) { |
|
29 | + foreach (sn_get_groups('storages') as $unit_id) { |
|
30 | + foreach (get_unit_param($unit_id, P_STORAGE) as $resource_id => $function) { |
|
31 | 31 | $caps['storage'][$resource_id][$unit_id] = floor($config_eco_scale_storage * |
32 | 32 | mrc_modify_value($user, $planet_row, $sn_group_modifiers[MODIFIER_RESOURCE_CAPACITY], $function(mrc_get_level($user, $planet_row, $unit_id))) |
33 | 33 | ); |
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
37 | - if($planet_row['planet_type'] == PT_MOON) { |
|
37 | + if ($planet_row['planet_type'] == PT_MOON) { |
|
38 | 38 | return $caps; |
39 | 39 | } |
40 | 40 | |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | $caps['production_full'][RES_DEUTERIUM][0] = floor($config->deuterium_basic_income * $config_resource_multiplier * (isset($planet_density[RES_DEUTERIUM]) ? $planet_density[RES_DEUTERIUM] : 1)); |
47 | 47 | $caps['production_full'][RES_ENERGY][0] = floor($config->energy_basic_income * $config_resource_multiplier_plain * (isset($planet_density[RES_ENERGY]) ? $planet_density[RES_ENERGY] : 1)); |
48 | 48 | |
49 | - foreach(sn_get_groups('factories') as $unit_id) { |
|
49 | + foreach (sn_get_groups('factories') as $unit_id) { |
|
50 | 50 | $unit_data = get_unit_param($unit_id); |
51 | 51 | $unit_level = mrc_get_level($user, $planet_row, $unit_id); |
52 | 52 | $unit_load = $planet_row[pname_factory_production_field_name($unit_id)]; |
53 | 53 | |
54 | - foreach($unit_data[P_UNIT_PRODUCTION] as $resource_id => $function) { |
|
54 | + foreach ($unit_data[P_UNIT_PRODUCTION] as $resource_id => $function) { |
|
55 | 55 | $caps['production_full'][$resource_id][$unit_id] = $function($unit_level, $unit_load, $user, $planet_row) |
56 | 56 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier) |
57 | 57 | * (isset($planet_density[$resource_id]) ? $planet_density[$resource_id] : 1); |
@@ -60,21 +60,21 @@ discard block |
||
60 | 60 | |
61 | 61 | array_walk_recursive($caps['production_full'], 'eco_get_planet_caps_modify_production', array('user' => $user, 'planet' => $planet_row)); |
62 | 62 | |
63 | - foreach($caps['production_full'] as $resource_id => $resource_data) { |
|
63 | + foreach ($caps['production_full'] as $resource_id => $resource_data) { |
|
64 | 64 | $caps['total_production_full'][$resource_id] = array_sum($resource_data); |
65 | 65 | } |
66 | 66 | |
67 | 67 | $caps['production'] = $caps['production_full']; |
68 | 68 | |
69 | - if($caps['production'][RES_ENERGY][STRUC_MINE_FUSION]) { |
|
69 | + if ($caps['production'][RES_ENERGY][STRUC_MINE_FUSION]) { |
|
70 | 70 | $deuterium_balance = array_sum($caps['production'][RES_DEUTERIUM]); |
71 | 71 | $energy_balance = array_sum($caps['production'][RES_ENERGY]); |
72 | - if($deuterium_balance < 0 || $energy_balance < 0) { |
|
72 | + if ($deuterium_balance < 0 || $energy_balance < 0) { |
|
73 | 73 | $caps['production'][RES_DEUTERIUM][STRUC_MINE_FUSION] = $caps['production'][RES_ENERGY][STRUC_MINE_FUSION] = 0; |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | - foreach($caps['production'][RES_ENERGY] as $energy) { |
|
77 | + foreach ($caps['production'][RES_ENERGY] as $energy) { |
|
78 | 78 | $caps[RES_ENERGY][$energy >= 0 ? BUILD_CREATE : BUILD_DESTROY] += $energy; |
79 | 79 | } |
80 | 80 | |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | ? $caps[RES_ENERGY][BUILD_CREATE] / $caps[RES_ENERGY][BUILD_DESTROY] |
85 | 85 | : 1; |
86 | 86 | |
87 | - foreach($caps['production'] as $resource_id => &$resource_data) { |
|
88 | - if($caps['efficiency'] != 1) { |
|
89 | - foreach($resource_data as $unit_id => &$resource_production) { |
|
90 | - if(!($unit_id == STRUC_MINE_FUSION && $resource_id == RES_DEUTERIUM) && $unit_id != 0 && !($resource_id == RES_ENERGY && $resource_production >= 0)) { |
|
87 | + foreach ($caps['production'] as $resource_id => &$resource_data) { |
|
88 | + if ($caps['efficiency'] != 1) { |
|
89 | + foreach ($resource_data as $unit_id => &$resource_production) { |
|
90 | + if (!($unit_id == STRUC_MINE_FUSION && $resource_id == RES_DEUTERIUM) && $unit_id != 0 && !($resource_id == RES_ENERGY && $resource_production >= 0)) { |
|
91 | 91 | $resource_production = $resource_production * $caps['efficiency']; |
92 | 92 | } |
93 | 93 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $caps['total'][$resource_id] = $caps['total'][$resource_id] >= 0 ? floor($caps['total'][$resource_id]) : ceil($caps['total'][$resource_id]); |
97 | 97 | } |
98 | 98 | |
99 | - foreach($caps['storage'] as $resource_id => &$resource_data) { |
|
99 | + foreach ($caps['storage'] as $resource_id => &$resource_data) { |
|
100 | 100 | $caps['total_storage'][$resource_id] = array_sum($resource_data); |
101 | 101 | } |
102 | 102 |
@@ -2,16 +2,16 @@ |
||
2 | 2 | // Captcha code for registration - really didn't work alot :( |
3 | 3 | |
4 | 4 | session_start(); |
5 | -$en=100; |
|
6 | -$boy=25; |
|
7 | -$sayi = mt_rand(0,9999999); |
|
5 | +$en = 100; |
|
6 | +$boy = 25; |
|
7 | +$sayi = mt_rand(0, 9999999); |
|
8 | 8 | $_SESSION['captcha'] = $sayi; |
9 | -$tuval = imagecreatetruecolor($en,$boy); |
|
10 | -$b = imagecolorallocate($tuval,175,238,238); |
|
11 | -$s = imagecolorallocate($tuval,0,0,0); |
|
12 | -imagefill($tuval,0,0,$s); |
|
13 | -imageline($tuval,20,50,$en,$boy,$b); |
|
14 | -imagestring($tuval,3,27,7,$sayi,$b); |
|
9 | +$tuval = imagecreatetruecolor($en, $boy); |
|
10 | +$b = imagecolorallocate($tuval, 175, 238, 238); |
|
11 | +$s = imagecolorallocate($tuval, 0, 0, 0); |
|
12 | +imagefill($tuval, 0, 0, $s); |
|
13 | +imageline($tuval, 20, 50, $en, $boy, $b); |
|
14 | +imagestring($tuval, 3, 27, 7, $sayi, $b); |
|
15 | 15 | Header("content-type:image/gif"); |
16 | 16 | imagegif($tuval); |
17 | 17 | imagedestroy($tuval); |
@@ -12,25 +12,25 @@ discard block |
||
12 | 12 | global $debug, $sn_mvc, $template_result, $user; |
13 | 13 | |
14 | 14 | // Напоминание для Администрации, что игра отключена |
15 | -if($template_result[F_GAME_DISABLE]) { |
|
15 | +if ($template_result[F_GAME_DISABLE]) { |
|
16 | 16 | // $disable_reason = sys_bbcodeParse($config->game_disable_reason); // Должна быть инициализирована выше по коду - в init.php |
17 | 17 | echo '<div class="global_admin_warning">', $template_result[F_GAME_DISABLE_REASON], '</div>'; |
18 | 18 | } |
19 | 19 | unset($disable_reason); |
20 | 20 | |
21 | 21 | |
22 | -if(defined('IN_ADMIN') && IN_ADMIN === true) { |
|
22 | +if (defined('IN_ADMIN') && IN_ADMIN === true) { |
|
23 | 23 | lng_include('admin'); |
24 | -} elseif($sys_user_logged_in) { |
|
24 | +} elseif ($sys_user_logged_in) { |
|
25 | 25 | sys_user_vacation($user); |
26 | 26 | |
27 | 27 | $planet_id = SetSelectedPlanet($user); |
28 | 28 | |
29 | 29 | // TODO НЕ НУЖНО АЛЬЯНС КАЖДЫЙ РАЗ ОБНОВЛЯТЬ!!! |
30 | - if($user['ally_id']) { |
|
30 | + if ($user['ally_id']) { |
|
31 | 31 | sn_db_transaction_start(); |
32 | 32 | sn_ali_fill_user_ally($user); |
33 | - if(!$user['ally']['player']['id']) { |
|
33 | + if (!$user['ally']['player']['id']) { |
|
34 | 34 | // sn_sys_logout(false, true); |
35 | 35 | // core_auth::logout(false); |
36 | 36 | classSupernova::$auth->logout(false); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | sn_db_transaction_commit(); |
50 | 50 | |
51 | 51 | $planetrow = $global_data['planet']; |
52 | - if(!($planetrow && isset($planetrow['id']) && $planetrow['id'])) { |
|
52 | + if (!($planetrow && isset($planetrow['id']) && $planetrow['id'])) { |
|
53 | 53 | // sn_sys_logout(false, true); |
54 | 54 | // core_auth::logout(false); |
55 | 55 | classSupernova::$auth->logout(false); |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
4 | 4 | $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
5 | 5 | } |
6 | 6 | |
7 | -if(!$user_can_negotiate) { |
|
7 | +if (!$user_can_negotiate) { |
|
8 | 8 | message($lang['Denied_access'], $lang['ali_dip_title']); |
9 | 9 | } |
10 | 10 | |
@@ -15,24 +15,24 @@ discard block |
||
15 | 15 | |
16 | 16 | |
17 | 17 | |
18 | -if(sys_get_param_str('ali_dip_offer_make')) { |
|
18 | +if (sys_get_param_str('ali_dip_offer_make')) { |
|
19 | 19 | $alliance_negotiation_relation = sys_get_param_str('alliance_negotiation_relation'); |
20 | - if(!array_key_exists($alliance_negotiation_relation, $sn_diplomacy_relation_list)) { |
|
20 | + if (!array_key_exists($alliance_negotiation_relation, $sn_diplomacy_relation_list)) { |
|
21 | 21 | message($lang['ali_dip_err_wrong_offer'], $page_title); |
22 | 22 | } |
23 | 23 | |
24 | 24 | $alliance_negotiation_contr_ally_id = sys_get_param_id('alliance_negotiation_contr_ally_id'); |
25 | - if($alliance_negotiation_contr_ally_id == $user['ally_id']) { |
|
25 | + if ($alliance_negotiation_contr_ally_id == $user['ally_id']) { |
|
26 | 26 | message($lang['ali_dip_err_same_ally'], $page_title); |
27 | 27 | } |
28 | 28 | |
29 | 29 | $contr_ally_row = db_ally_get_by_id($alliance_negotiation_contr_ally_id); |
30 | - if(!$contr_ally_row) { |
|
30 | + if (!$contr_ally_row) { |
|
31 | 31 | message($lang['ali_dip_err_no_ally'], $page_title); |
32 | 32 | } |
33 | 33 | |
34 | 34 | $relation_current_id = ali_relation($user['ally_id'], $alliance_negotiation_contr_ally_id); |
35 | - if($alliance_negotiation_relation == $relation_current_id) { |
|
35 | + if ($alliance_negotiation_relation == $relation_current_id) { |
|
36 | 36 | message(sprintf($lang['ali_dip_err_offer_same'], $lang['ali_dip_relations'][$alliance_negotiation_relation]), $page_title); |
37 | 37 | } |
38 | 38 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | $relation_new = $sn_diplomacy_relation_list[$alliance_negotiation_relation]; |
45 | 45 | $relation_current = $sn_diplomacy_relation_list[$relation_current_id]; |
46 | - if($relation_new['enter_delay'] == -1 || $relation_current['exit_delay'] == -1) { |
|
46 | + if ($relation_new['enter_delay'] == -1 || $relation_current['exit_delay'] == -1) { |
|
47 | 47 | sn_db_perform('{{alliance_negotiation}}', |
48 | 48 | array( |
49 | 49 | 'alliance_negotiation_ally_id' => $user['ally_id'], |
@@ -70,33 +70,33 @@ discard block |
||
70 | 70 | } |
71 | 71 | } else { |
72 | 72 | $offer_id = sys_get_param_id('offer_id'); |
73 | - if($offer_id) { |
|
73 | + if ($offer_id) { |
|
74 | 74 | $offer_answer = sys_get_param_str('answer'); |
75 | 75 | |
76 | 76 | $negotiation = db_ally_negotiation_get_by_offer_id($offer_id); |
77 | - if(!$negotiation) { |
|
77 | + if (!$negotiation) { |
|
78 | 78 | message($lang['ali_dip_err_offer_none'], $page_title); |
79 | - } elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id']) { |
|
79 | + } elseif ($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id']) { |
|
80 | 80 | // TODO: Add log of hack attempt |
81 | 81 | message($lang['ali_dip_err_offer_alien'], $page_title); |
82 | - } elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id']) { |
|
83 | - if($offer_answer == 'accept') { |
|
82 | + } elseif ($negotiation['alliance_negotiation_ally_id'] == $user['ally_id']) { |
|
83 | + if ($offer_answer == 'accept') { |
|
84 | 84 | // TODO: Add log of hack attempt |
85 | 85 | message($lang['ali_dip_err_offer_accept_own'], $page_title); |
86 | - } elseif($offer_answer == 'deny') { |
|
86 | + } elseif ($offer_answer == 'deny') { |
|
87 | 87 | db_ally_negotiation_delete_by_offer_id($offer_id); |
88 | 88 | } |
89 | 89 | } else { |
90 | - if($offer_answer == 'accept') { |
|
90 | + if ($offer_answer == 'accept') { |
|
91 | 91 | $accept_offer = true; |
92 | - } elseif($offer_answer == 'deny') { |
|
92 | + } elseif ($offer_answer == 'deny') { |
|
93 | 93 | db_ally_negotiation_update_status_1($offer_id); |
94 | 94 | } |
95 | 95 | } |
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | -if($accept_offer) { |
|
99 | +if ($accept_offer) { |
|
100 | 100 | sn_db_transaction_start(); |
101 | 101 | |
102 | 102 | // TODO: Make sn_db_perform() multirow |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | sn_db_transaction_commit(); |
126 | 126 | } |
127 | 127 | |
128 | -foreach($sn_diplomacy_relation_list as $diplomacy_relation_id => $diplomacy_relation) { |
|
128 | +foreach ($sn_diplomacy_relation_list as $diplomacy_relation_id => $diplomacy_relation) { |
|
129 | 129 | $template->assign_block_vars('relation', array( |
130 | 130 | 'ID' => $diplomacy_relation_id, |
131 | 131 | 'TEXT' => $lang['ali_dip_relations'][$diplomacy_relation_id], |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | |
135 | 135 | |
136 | 136 | $query = db_ally_list_get_by_not_user_ally($user); |
137 | -while($alliance = db_fetch($query)) { |
|
137 | +while ($alliance = db_fetch($query)) { |
|
138 | 138 | $template->assign_block_vars('alliance', array( |
139 | 139 | 'ID' => $alliance['id'], |
140 | 140 | 'NAME' => js_safe_string($alliance['ally_name']), |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | $query = db_ally_negotiation_list($user); |
146 | -while($offer = db_fetch($query)) { |
|
146 | +while ($offer = db_fetch($query)) { |
|
147 | 147 | $template->assign_block_vars('offer', array( |
148 | 148 | 'ID' => $offer['alliance_negotiation_id'], |
149 | 149 | 'NAME' => $offer['ally_name'], |
@@ -11,15 +11,15 @@ discard block |
||
11 | 11 | $announce_list = db_news_list_get_by_query($template, $query_where, $query_limit); |
12 | 12 | |
13 | 13 | $users = array(); |
14 | - while($announce = db_fetch($announce_list)) { |
|
15 | - if($announce['user_id'] && !isset($users[$announce['user_id']])) { |
|
14 | + while ($announce = db_fetch($announce_list)) { |
|
15 | + if ($announce['user_id'] && !isset($users[$announce['user_id']])) { |
|
16 | 16 | $users[$announce['user_id']] = db_user_by_id($announce['user_id']); |
17 | 17 | } |
18 | 18 | |
19 | 19 | $survey_vote = array('survey_vote_id' => 1); |
20 | 20 | $survey_complete = strtotime($announce['survey_until']) < SN_TIME_NOW; |
21 | 21 | |
22 | - if($announce['survey_id'] && !empty($user['id'])) { |
|
22 | + if ($announce['survey_id'] && !empty($user['id'])) { |
|
23 | 23 | $survey_vote = !$survey_complete ? db_survey_get_vote($announce, $user) : array(); |
24 | 24 | } |
25 | 25 | |
@@ -31,8 +31,7 @@ discard block |
||
31 | 31 | 'ANNOUNCE' => cht_message_parse($announce['strAnnounce'], false, intval($announce['authlevel'])), |
32 | 32 | 'DETAIL_URL' => $announce['detail_url'], |
33 | 33 | 'USER_NAME' => |
34 | - isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) : |
|
35 | - js_safe_string($announce['user_name']), |
|
34 | + isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) : js_safe_string($announce['user_name']), |
|
36 | 35 | 'NEW' => $announce['unix_time'] + $config->game_news_actual >= SN_TIME_NOW, |
37 | 36 | 'FUTURE' => $announce['unix_time'] > SN_TIME_NOW, |
38 | 37 | 'SURVEY_ID' => $announce['survey_id'], |
@@ -42,25 +41,25 @@ discard block |
||
42 | 41 | 'SURVEY_UNTIL' => $announce['survey_until'], |
43 | 42 | )); |
44 | 43 | |
45 | - foreach($announce_exploded as $announce_paragraph) { |
|
44 | + foreach ($announce_exploded as $announce_paragraph) { |
|
46 | 45 | $template->assign_block_vars('announces.paragraph', array( |
47 | 46 | 'TEXT' => $announce_paragraph, |
48 | 47 | )); |
49 | 48 | } |
50 | 49 | |
51 | - if($announce['survey_id']) { |
|
50 | + if ($announce['survey_id']) { |
|
52 | 51 | $survey_query = db_survey_get_answer_texts($announce); |
53 | 52 | $survey_vote_result = array(); |
54 | 53 | $total_votes = 0; |
55 | - while($row = db_fetch($survey_query)) { |
|
54 | + while ($row = db_fetch($survey_query)) { |
|
56 | 55 | $survey_vote_result[] = $row; |
57 | 56 | $total_votes += $row['VOTES']; |
58 | 57 | } |
59 | 58 | |
60 | - if(empty($survey_vote) && !$survey_complete) { |
|
59 | + if (empty($survey_vote) && !$survey_complete) { |
|
61 | 60 | // Can vote |
62 | 61 | $survey_query = db_survey_answers_get_list_by_parent($announce); |
63 | - while($row = db_fetch($survey_query)) { |
|
62 | + while ($row = db_fetch($survey_query)) { |
|
64 | 63 | $template->assign_block_vars('announces.survey_answers', array( |
65 | 64 | 'ID' => $row['survey_answer_id'], |
66 | 65 | 'TEXT' => $row['survey_answer_text'], |
@@ -68,7 +67,7 @@ discard block |
||
68 | 67 | } |
69 | 68 | } else { |
70 | 69 | // Show result |
71 | - foreach($survey_vote_result as &$vote_result) { |
|
70 | + foreach ($survey_vote_result as &$vote_result) { |
|
72 | 71 | $vote_percent = $total_votes ? $vote_result['VOTES'] / $total_votes * 100 : 0; |
73 | 72 | $vote_result['PERCENT'] = $vote_percent; |
74 | 73 | $vote_result['PERCENT_TEXT'] = round($vote_percent, 1); |
@@ -85,7 +84,7 @@ discard block |
||
85 | 84 | } |
86 | 85 | |
87 | 86 | function nws_mark_read(&$user) { |
88 | - if(isset($user['id'])) { |
|
87 | + if (isset($user['id'])) { |
|
89 | 88 | db_user_set_by_id($user['id'], '`news_lastread` = ' . SN_TIME_NOW); |
90 | 89 | $user['news_lastread'] = SN_TIME_NOW; |
91 | 90 | } |
@@ -94,17 +93,17 @@ discard block |
||
94 | 93 | } |
95 | 94 | |
96 | 95 | function survey_vote(&$user) { |
97 | - if(empty($user['id'])) { |
|
96 | + if (empty($user['id'])) { |
|
98 | 97 | return true; |
99 | 98 | } |
100 | 99 | |
101 | 100 | sn_db_transaction_start(); |
102 | 101 | $survey_id = sys_get_param_id('survey_id'); |
103 | 102 | $is_voted = db_survey_vote_get($user, $survey_id); |
104 | - if(empty($is_voted)) { |
|
103 | + if (empty($is_voted)) { |
|
105 | 104 | $survey_vote_id = sys_get_param_id('survey_vote'); |
106 | 105 | $is_answer_exists = db_survey_answer_get($survey_id, $survey_vote_id); |
107 | - if(!empty($is_answer_exists)) { |
|
106 | + if (!empty($is_answer_exists)) { |
|
108 | 107 | $user_name_safe = db_escape($user['username']); |
109 | 108 | db_survey_vote_insert($user, $survey_id, $survey_vote_id, $user_name_safe); |
110 | 109 | } |