@@ -1,18 +1,18 @@ |
||
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_search', true); |
8 | 8 | |
9 | 9 | $ali_search_text = sys_get_param_str('searchtext'); |
10 | -if($ali_search_text) { |
|
10 | +if ($ali_search_text) { |
|
11 | 11 | $template->assign_var('SEARCH_TEXT', $ali_search_text); |
12 | 12 | |
13 | 13 | $search = db_ally_search_by_name_or_tag($ali_search_text); |
14 | - if(db_num_rows($search)) { |
|
15 | - while($ally_row = db_fetch($search)) { |
|
14 | + if (db_num_rows($search)) { |
|
15 | + while ($ally_row = db_fetch($search)) { |
|
16 | 16 | $template->assign_block_vars('alliances', array( |
17 | 17 | 'ID' => $ally_row['id'], |
18 | 18 | 'TAG' => $ally_row['ally_tag'], |
@@ -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 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | function db_stat_list_statistic($who, $is_common_stat, $Rank, $start, $source = false) { |
87 | 87 | // pdump($source); |
88 | - if(!$source) { |
|
88 | + if (!$source) { |
|
89 | 89 | $source = array( |
90 | 90 | 'statpoints' => 'statpoints', |
91 | 91 | 'users' => 'users', |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | ); |
107 | 107 | } |
108 | 108 | // pdump($source); |
109 | - if($who == 1) { |
|
110 | - if($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
|
109 | + if ($who == 1) { |
|
110 | + if ($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
|
111 | 111 | $query_str = |
112 | 112 | "SELECT |
113 | 113 | @rownum:=@rownum+1 rownum, subject.{$source['id']} as `id`, sp.{$Rank}_rank as rank, sp.{$Rank}_old_rank as rank_old, sp.{$Rank}_points as points, subject.{$source['username']} as `name`, subject.* |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) { |
192 | 192 | $current_value_safe = db_escape($current_value_unsafe); |
193 | 193 | $value_id = doquery("SELECT `{$db_id_field_name}` AS id_field FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE", true); |
194 | - if(!isset($value_id['id_field']) || !$value_id['id_field']) { |
|
194 | + if (!isset($value_id['id_field']) || !$value_id['id_field']) { |
|
195 | 195 | doquery("INSERT INTO {{{$db_table_name}}} (`{$db_value_field_name}`) VALUES ('{$current_value_safe}');"); |
196 | 196 | $variable_id = db_insert_id(); |
197 | 197 | } else { |
@@ -161,7 +161,7 @@ |
||
161 | 161 | !is_array($user_id_list) ? $user_id_list = array($user_id_list) : false; |
162 | 162 | |
163 | 163 | $user_list = array(); |
164 | - foreach($user_id_list as $user_id_unsafe) { |
|
164 | + foreach ($user_id_list as $user_id_unsafe) { |
|
165 | 165 | $user = db_user_by_id($user_id_unsafe); |
166 | 166 | !empty($user) ? $user_list[$user_id_unsafe] = $user : false; |
167 | 167 | } |
@@ -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; |