@@ -1,17 +1,17 @@ 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 | 7 | $template = gettemplate('ali_info', true); |
8 | 8 | |
9 | -if($mode == 'exit') { |
|
10 | - if($ally['ally_owner'] == $user['id']) { |
|
9 | +if ($mode == 'exit') { |
|
10 | + if ($ally['ally_owner'] == $user['id']) { |
|
11 | 11 | message($lang['Owner_cant_go_out'], $lang['Alliance']); |
12 | 12 | } |
13 | 13 | |
14 | - if(sys_get_param_int('ali_info_leave_confirm')) { |
|
14 | + if (sys_get_param_int('ali_info_leave_confirm')) { |
|
15 | 15 | sn_db_transaction_start(); |
16 | 16 | db_user_set_by_id($user['id'], "`ally_id` = null, `ally_name` = null, `ally_tag` = null, `ally_register_time` = 0, `ally_rank_id` = 0"); |
17 | 17 | db_ally_list_recalc_counts(); |
@@ -19,20 +19,20 @@ discard block |
||
19 | 19 | $lang['Go_out_welldone'] = str_replace("%s", $ally_name, $lang['Go_out_welldone']); |
20 | 20 | message(sprintf($lang['ali_info_leave_success'], $ally['ally_name']), $lang['sys_alliance']); |
21 | 21 | } |
22 | -} elseif($mode == 'ainfo') { |
|
22 | +} elseif ($mode == 'ainfo') { |
|
23 | 23 | $tag = sys_get_param_str('tag'); |
24 | 24 | $id_ally = sys_get_param_id('a'); |
25 | - if($tag) { |
|
25 | + if ($tag) { |
|
26 | 26 | $ally = db_ally_get_by_tag($tag); |
27 | - } elseif($id_ally) { |
|
27 | + } elseif ($id_ally) { |
|
28 | 28 | $ally = db_ally_get_by_id($id_ally); |
29 | 29 | } |
30 | 30 | |
31 | - if(!$ally) { |
|
31 | + if (!$ally) { |
|
32 | 32 | message($lang['ali_sys_notFound'], $lang['Ally_info_1']); |
33 | 33 | } |
34 | 34 | |
35 | - if(!$ally['ally_description']) { |
|
35 | + if (!$ally['ally_description']) { |
|
36 | 36 | $ally['ally_description'] = $lang['Ally_nodescription']; |
37 | 37 | } |
38 | 38 | |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | } else { |
45 | 45 | $page_header = $lang['your_alliance']; |
46 | 46 | |
47 | - if($ally['ally_owner'] == $user['id']) { |
|
47 | + if ($ally['ally_owner'] == $user['id']) { |
|
48 | 48 | $range = $ally['ally_owner_range'] ? $ally['ally_owner_range'] : $lang['Founder']; |
49 | - } elseif($user['ally_rank_id'] != 0 && isset($ranks[$user['ally_rank_id']]['name'])) { |
|
49 | + } elseif ($user['ally_rank_id'] != 0 && isset($ranks[$user['ally_rank_id']]['name'])) { |
|
50 | 50 | $range = $ranks[$user['ally_rank_id']]['name']; |
51 | 51 | } else { |
52 | 52 | $range = $lang['member']; |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | )); |
88 | 88 | |
89 | 89 | $relations = ali_relations($ally['id']); |
90 | -foreach($relations as $relation) { |
|
91 | - if($relation['alliance_diplomacy_contr_ally_id'] && $relation['alliance_diplomacy_ally_id']) { |
|
90 | +foreach ($relations as $relation) { |
|
91 | + if ($relation['alliance_diplomacy_contr_ally_id'] && $relation['alliance_diplomacy_ally_id']) { |
|
92 | 92 | $template->assign_block_vars('relation', array( |
93 | 93 | 'NAME' => $relation['alliance_diplomacy_contr_ally_name'], |
94 | 94 | 'RELATION' => $lang['ali_dip_relations'][$relation['alliance_diplomacy_relation']], |
@@ -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 | } |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | ), |
25 | 25 | ); |
26 | 26 | |
27 | - foreach($queries as &$query) { |
|
28 | - if(!empty($query['query'])) { |
|
27 | + foreach ($queries as &$query) { |
|
28 | + if (!empty($query['query'])) { |
|
29 | 29 | $query['result'] = doquery($query['query']); |
30 | - } elseif(!empty($query['callable']) && is_callable($query['callable'])) { |
|
30 | + } elseif (!empty($query['callable']) && is_callable($query['callable'])) { |
|
31 | 31 | call_user_func($query['callable']); |
32 | 32 | } |
33 | 33 | $query['error'] = classSupernova::$db->db_error(); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $today_array = array($today_array['seconds'], $today_array['minutes'], $today_array['hours'], $today_array['mday'], $today_array['mon'], $today_array['year']); |
72 | 72 | // pdump($prev_run_array); |
73 | 73 | $scheduleList = explode(',', $scheduleList); |
74 | - array_walk($scheduleList, function (&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) { |
|
74 | + array_walk($scheduleList, function(&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) { |
|
75 | 75 | // pdump($schedule); |
76 | 76 | $schedule = array('schedule_array' => array_reverse(explode(':', trim($schedule)))); |
77 | 77 | |
@@ -83,21 +83,21 @@ discard block |
||
83 | 83 | */ |
84 | 84 | // pdump($schedule); |
85 | 85 | |
86 | - foreach($prev_run_array as $index => $date_part) { |
|
86 | + foreach ($prev_run_array as $index => $date_part) { |
|
87 | 87 | $schedule['array']['recorded'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $date_part; |
88 | 88 | $schedule['array']['now'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $today_array[$index]; |
89 | 89 | } |
90 | - if($schedule['array']['recorded'] == $schedule['array']['now']) { |
|
90 | + if ($schedule['array']['recorded'] == $schedule['array']['now']) { |
|
91 | 91 | unset($schedule['array']['now']); |
92 | 92 | } |
93 | 93 | |
94 | - foreach($schedule['array'] as $name => $array) { |
|
94 | + foreach ($schedule['array'] as $name => $array) { |
|
95 | 95 | $schedule['string'][$name] = "{$array[5]}-{$array[4]}-{$array[3]} {$array[2]}:{$array[1]}:{$array[0]}"; |
96 | 96 | $schedule['string'][$name . '_next'] = $schedule['string'][$name] . ' +1 ' . $interval; |
97 | 97 | $schedule['string'][$name . '_prev'] = $schedule['string'][$name] . ' -1 ' . $interval; |
98 | 98 | } |
99 | 99 | |
100 | - foreach($schedule['string'] as $string) { |
|
100 | + foreach ($schedule['string'] as $string) { |
|
101 | 101 | $timestamp = strtotime($string); |
102 | 102 | $schedule['timestamp'][$timestamp] = $possible_schedules[$timestamp] = date(FMT_DATE_TIME_SQL, strtotime($string)); |
103 | 103 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | |
130 | 130 | $prev_run = 0; |
131 | 131 | $next_run = 0; |
132 | - foreach($possible_schedules as $timestamp => $string_date) { |
|
132 | + foreach ($possible_schedules as $timestamp => $string_date) { |
|
133 | 133 | $prev_run = SN_TIME_NOW >= $timestamp ? $timestamp : $prev_run; |
134 | 134 | $next_run = SN_TIME_NOW < $timestamp && !$next_run ? $timestamp : $next_run; |
135 | 135 | // pdump($schedule, '$schedule ' . date(FMT_DATE_TIME_SQL, $schedule)); |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function geoip_status(){return sn_function_call(__FUNCTION__, array(&$result));} |
|
3 | +function geoip_status() {return sn_function_call(__FUNCTION__, array(&$result)); } |
|
4 | 4 | function sn_geoip_status(&$result) { |
5 | 5 | return $result = false; |
6 | 6 | } |
7 | 7 | |
8 | -function geoip_ip_info($ip){return sn_function_call(__FUNCTION__, array($ip, &$result));} |
|
8 | +function geoip_ip_info($ip) {return sn_function_call(__FUNCTION__, array($ip, &$result)); } |
|
9 | 9 | function sn_geoip_ip_info($ip, &$result) { |
10 | 10 | return $result = false; |
11 | 11 | } |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | function ali_rank_list_save($ranks) { |
4 | 4 | global $user; |
5 | 5 | |
6 | - if(!empty($ranks)) { |
|
7 | - foreach($ranks as $rank => $rights) { |
|
6 | + if (!empty($ranks)) { |
|
7 | + foreach ($ranks as $rank => $rights) { |
|
8 | 8 | $rights = implode(',', $rights); |
9 | 9 | $ranklist .= $rights . ';'; |
10 | 10 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $temp_array = array(); |
23 | 23 | $query = db_ally_diplomacy_get_relations($ally_from, $ally_to); |
24 | 24 | |
25 | - while($record = db_fetch($query)) { |
|
25 | + while ($record = db_fetch($query)) { |
|
26 | 26 | $temp_array[$record['alliance_diplomacy_contr_ally_id']] = $record; |
27 | 27 | } |
28 | 28 |
@@ -27,19 +27,19 @@ |
||
27 | 27 | */ |
28 | 28 | function db_set_make_safe_string($set, $delta = false) { |
29 | 29 | $set_safe = array(); |
30 | - foreach($set as $field => $value) { |
|
31 | - if(empty($field)) { |
|
30 | + foreach ($set as $field => $value) { |
|
31 | + if (empty($field)) { |
|
32 | 32 | continue; |
33 | 33 | } |
34 | 34 | |
35 | 35 | $field = '`' . db_escape($field) . '`'; |
36 | 36 | $new_value = $value; |
37 | - if($value === null) { |
|
37 | + if ($value === null) { |
|
38 | 38 | $new_value = 'NULL'; |
39 | - } elseif(is_string($value) && (string)($new_value = floatval($value)) != (string)$value) { |
|
39 | + } elseif (is_string($value) && (string) ($new_value = floatval($value)) != (string) $value) { |
|
40 | 40 | // non-float |
41 | 41 | $new_value = '"' . db_escape($value) . '"'; |
42 | - } elseif($delta) { |
|
42 | + } elseif ($delta) { |
|
43 | 43 | // float and DELTA-set |
44 | 44 | $new_value = "{$field} + ({$new_value})"; |
45 | 45 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | * @copyright 2008 by Gorlum for Project "SuperNova.WS" |
11 | 11 | */ |
12 | 12 | function flt_mission_hold($mission_data) { |
13 | - if($mission_data->fleet->time_mission_job_complete < SN_TIME_NOW) { |
|
13 | + if ($mission_data->fleet->time_mission_job_complete < SN_TIME_NOW) { |
|
14 | 14 | $mission_data->fleet->mark_fleet_as_returned_and_save(); |
15 | 15 | |
16 | 16 | return CACHE_FLEET; |
@@ -4,9 +4,9 @@ discard block |
||
4 | 4 | { |
5 | 5 | $strPacked = "{$type}!"; |
6 | 6 | |
7 | - foreach($combat as $fleetID => $fleetCompress) |
|
7 | + foreach ($combat as $fleetID => $fleetCompress) |
|
8 | 8 | { |
9 | - foreach($fleetCompress as $key => $value) |
|
9 | + foreach ($fleetCompress as $key => $value) |
|
10 | 10 | { |
11 | 11 | $value = intval($value); |
12 | 12 | $strPacked .= "{$key},{$value};"; |
@@ -22,29 +22,29 @@ discard block |
||
22 | 22 | $fleet_id = 0; |
23 | 23 | |
24 | 24 | $arr_data_unpacked = explode('!', $str_data); |
25 | - foreach($arr_data_unpacked as $data_piece) |
|
25 | + foreach ($arr_data_unpacked as $data_piece) |
|
26 | 26 | { |
27 | - if(!$data_piece) |
|
27 | + if (!$data_piece) |
|
28 | 28 | { |
29 | 29 | continue; |
30 | 30 | } |
31 | 31 | |
32 | - if($data_piece == 'A' || $data_piece == 'D') |
|
32 | + if ($data_piece == 'A' || $data_piece == 'D') |
|
33 | 33 | { |
34 | 34 | $fleet_type = $data_piece; |
35 | 35 | continue; |
36 | 36 | } |
37 | 37 | |
38 | 38 | $arr_unit_strings = explode(';', $data_piece); |
39 | - foreach($arr_unit_strings as $str_unit_string) |
|
39 | + foreach ($arr_unit_strings as $str_unit_string) |
|
40 | 40 | { |
41 | - if(!$str_unit_string) |
|
41 | + if (!$str_unit_string) |
|
42 | 42 | { |
43 | 43 | continue; |
44 | 44 | } |
45 | 45 | |
46 | 46 | $arr_unit_data = explode(',', $str_unit_string); |
47 | - if($arr_unit_data[1]) |
|
47 | + if ($arr_unit_data[1]) |
|
48 | 48 | { |
49 | 49 | $unpacked[$fleet_type][$fleet_id][$arr_unit_data[0]] = intval($arr_unit_data[1]); |
50 | 50 | } |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | $TargetAddress = sprintf($lang['sys_adress_planet'], $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet']); |
21 | 21 | |
22 | 22 | $TheMessage = $lang['sys_colo_no_colonizer']; |
23 | - if($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) { |
|
23 | + if ($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) { |
|
24 | 24 | $TheMessage = $lang['sys_colo_notfree']; |
25 | - if(empty($mission_data->dst_planet)) { |
|
25 | + if (empty($mission_data->dst_planet)) { |
|
26 | 26 | $iPlanetCount = get_player_current_colonies($src_user_row); |
27 | 27 | |
28 | 28 | // Can we colonize more planets? |
29 | 29 | $TheMessage = $lang['sys_colo_maxcolo']; |
30 | - if($iPlanetCount < get_player_max_colonies($src_user_row)) { |
|
30 | + if ($iPlanetCount < get_player_max_colonies($src_user_row)) { |
|
31 | 31 | // Yes, we can colonize |
32 | 32 | $TheMessage = $lang['sys_colo_badpos']; |
33 | 33 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet'], |
36 | 36 | $objFleet->playerOwnerId, "{$lang['sys_colo_defaultname']} {$iPlanetCount}", false, |
37 | 37 | array('user_row' => $src_user_row)); |
38 | - if($NewOwnerPlanet) { |
|
38 | + if ($NewOwnerPlanet) { |
|
39 | 39 | $TheMessage = $lang['sys_colo_arrival'] . $TargetAddress . $lang['sys_colo_allisok']; |
40 | 40 | msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, $lang['sys_colo_mess_from'], $lang['sys_colo_mess_report'], $TheMessage); |
41 | 41 |