@@ -1,26 +1,26 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * chat.php |
|
4 | - * Main chat window |
|
5 | - * |
|
6 | - * Changelog: |
|
7 | - * 4.0 copyright © 2009-2012 Gorlum for http://supernova.ws |
|
8 | - * [!] Another rewrite |
|
9 | - * [+] preMVC-compatible |
|
10 | - * 3.0 copyright © 2009-2011 Gorlum for http://supernova.ws |
|
11 | - * [!] Almost full rewrote |
|
12 | - * [+] Complies with PCG1 |
|
13 | - * 2.0 copyright © 2009-2010 Gorlum for http://supernova.ws |
|
14 | - * [+] Rewrote to remove unnecessary code dupes |
|
15 | - * 1.5 copyright © 2009-2010 Gorlum for http://supernova.ws |
|
16 | - * [~] More DDoS-realted fixes |
|
17 | - * 1.4 copyright © 2009-2010 Gorlum for http://supernova.ws |
|
18 | - * [~] DDoS-realted fixes |
|
19 | - * 1.3 copyright © 2009-2010 Gorlum for http://supernova.ws |
|
20 | - * [~] Security checks for SQL-injection |
|
21 | - * 1.2 by Ihor |
|
22 | - * 1.0 Shoutbox copyright © 2008 by e-Zobar for XNova |
|
23 | - **/ |
|
3 | + * chat.php |
|
4 | + * Main chat window |
|
5 | + * |
|
6 | + * Changelog: |
|
7 | + * 4.0 copyright © 2009-2012 Gorlum for http://supernova.ws |
|
8 | + * [!] Another rewrite |
|
9 | + * [+] preMVC-compatible |
|
10 | + * 3.0 copyright © 2009-2011 Gorlum for http://supernova.ws |
|
11 | + * [!] Almost full rewrote |
|
12 | + * [+] Complies with PCG1 |
|
13 | + * 2.0 copyright © 2009-2010 Gorlum for http://supernova.ws |
|
14 | + * [+] Rewrote to remove unnecessary code dupes |
|
15 | + * 1.5 copyright © 2009-2010 Gorlum for http://supernova.ws |
|
16 | + * [~] More DDoS-realted fixes |
|
17 | + * 1.4 copyright © 2009-2010 Gorlum for http://supernova.ws |
|
18 | + * [~] DDoS-realted fixes |
|
19 | + * 1.3 copyright © 2009-2010 Gorlum for http://supernova.ws |
|
20 | + * [~] Security checks for SQL-injection |
|
21 | + * 1.2 by Ihor |
|
22 | + * 1.0 Shoutbox copyright © 2008 by e-Zobar for XNova |
|
23 | + **/ |
|
24 | 24 | /* |
25 | 25 | $sn_mvc['model']['chat'][] = 'sn_chat_model'; |
26 | 26 | $sn_mvc['model']['chat_add'][] = 'sn_chat_add_model'; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $user_auth_level = isset($user['authlevel']) ? $user['authlevel'] : AUTH_LEVEL_ANONYMOUS; |
37 | 37 | |
38 | 38 | $mode = sys_get_param_int('mode'); |
39 | - switch($mode) { |
|
39 | + switch ($mode) { |
|
40 | 40 | case CHAT_MODE_ALLY: |
41 | 41 | $template_result['ALLY'] = intval($user['ally_id']); |
42 | 42 | $page_title = classLocale::$lang['chat_ally']; |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | $template_result['.']['smiles'] = array(); |
52 | - foreach($supernova->design['smiles'] as $auth_level => $replaces) { |
|
53 | - if($auth_level > $user_auth_level) { |
|
52 | + foreach ($supernova->design['smiles'] as $auth_level => $replaces) { |
|
53 | + if ($auth_level > $user_auth_level) { |
|
54 | 54 | continue; |
55 | 55 | } |
56 | 56 | |
57 | - foreach($replaces as $bbcode => $filename) { |
|
57 | + foreach ($replaces as $bbcode => $filename) { |
|
58 | 58 | $template_result['.']['smiles'][] = array( |
59 | 59 | 'BBCODE' => $bbcode, |
60 | 60 | 'FILENAME' => $filename, |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | define('IN_AJAX', true); |
78 | 78 | $skip_fleet_update = true; |
79 | 79 | |
80 | - if(classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) { |
|
80 | + if (classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) { |
|
81 | 81 | die(); |
82 | 82 | } |
83 | 83 | |
84 | - if(($message = sys_get_param_str('message')) && $user['username']) { |
|
84 | + if (($message = sys_get_param_str('message')) && $user['username']) { |
|
85 | 85 | $ally_id = sys_get_param('ally') && $user['ally_id'] ? $user['ally_id'] : 0; |
86 | 86 | $nick = db_escape(player_nick_compact(player_nick_render_current_to_array($user, array('color' => true, 'icons' => true, 'ally' => !$ally_id)))); |
87 | 87 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $skip_fleet_update = true; |
104 | 104 | |
105 | 105 | $history = sys_get_param_str('history'); |
106 | - if(!$history) { |
|
106 | + if (!$history) { |
|
107 | 107 | classSupernova::$config->array_set('users', $user['id'], 'chat_last_refresh', SN_TIME_MICRO); |
108 | 108 | } |
109 | 109 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $last_message = ''; |
112 | 112 | $alliance = 0; |
113 | 113 | $template_result['.']['chat'] = array(); |
114 | - if(!$history && classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) { |
|
114 | + if (!$history && classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) { |
|
115 | 115 | $result['disable'] = true; |
116 | 116 | $template_result['.']['chat'][] = array( |
117 | 117 | 'TIME' => date(FMT_DATE_TIME, htmlentities(SN_CLIENT_TIME_LOCAL, ENT_QUOTES, 'utf-8')), |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | |
125 | 125 | $where_add = ''; |
126 | 126 | $last_message = 0; |
127 | - if($history) { |
|
127 | + if ($history) { |
|
128 | 128 | $rows = db_chat_message_count_by_ally($alliance); |
129 | 129 | $page_count = ceil($rows['CNT'] / $page_limit); |
130 | 130 | |
131 | - for($i = 0; $i < $page_count; $i++) { |
|
131 | + for ($i = 0; $i < $page_count; $i++) { |
|
132 | 132 | $template_result['.']['page'][] = array( |
133 | 133 | 'NUMBER' => $i |
134 | 134 | ); |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | |
143 | 143 | $start_row = $page * $page_limit; |
144 | 144 | $query = db_chat_message_get_page($alliance, $where_add, $start_row, $page_limit); |
145 | - while($chat_row = db_fetch($query)) { |
|
145 | + while ($chat_row = db_fetch($query)) { |
|
146 | 146 | // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick |
147 | 147 | $chat_row['user'] = player_nick_render_to_html($chat_row['user']); |
148 | 148 | $nick_stripped = htmlentities(strip_tags($chat_row['user']), ENT_QUOTES, 'utf-8'); |
149 | 149 | $nick = str_replace(strip_tags($chat_row['user']), $nick_stripped, $chat_row['user']); |
150 | - if(!$history) { |
|
150 | + if (!$history) { |
|
151 | 151 | $nick = "<span style=\"cursor: pointer;\" onclick=\"addSmiley('({$nick_stripped})');\">{$nick}</span>"; |
152 | 152 | } |
153 | 153 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $template = gettemplate('chat_messages', $template); |
173 | 173 | $template->assign_recursive($template_result); |
174 | 174 | |
175 | - if($history) { |
|
175 | + if ($history) { |
|
176 | 176 | display($template, "{$classLocale['chat_history']} - {$classLocale[$alliance ? 'chat_ally' : 'chat_common']}", true, '', false, true); |
177 | 177 | } else { |
178 | 178 | $result['last_message'] = $last_message; |
@@ -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'], |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | // Pretty Safe |
3 | 3 | // TODO: Add ally_tag to usertable |
4 | 4 | |
5 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
5 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
6 | 6 | $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
7 | 7 | } |
8 | 8 | |
@@ -11,13 +11,13 @@ discard block |
||
11 | 11 | $ally_name_raw = sys_get_param_str_unsafe('name'); |
12 | 12 | $ally_name = db_escape($ally_name_raw); |
13 | 13 | |
14 | -if($ally_tag) { |
|
15 | - if(!$ally_name_raw || !$ally_tag_raw) { |
|
14 | +if ($ally_tag) { |
|
15 | + if (!$ally_name_raw || !$ally_tag_raw) { |
|
16 | 16 | message($lang['have_not_name'], $lang['make_alliance']); |
17 | 17 | } |
18 | 18 | |
19 | 19 | $query = db_ally_get_by_name_or_tag($ally_tag, $ally_name); |
20 | - if($query) { |
|
20 | + if ($query) { |
|
21 | 21 | message(str_replace('%s', $query['ally_tag'] == $ally_tag_raw ? $ally_tag_raw : $ally_name_raw, $lang['always_exist']), $lang['make_alliance']); |
22 | 22 | } |
23 | 23 |
@@ -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']], |
@@ -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_admin) { |
|
7 | +if (!$user_admin) { |
|
8 | 8 | message($lang['Denied_access'], $lang['ally_admin']); |
9 | 9 | } |
10 | 10 | |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $allyTextID = ($allyTextID < 1 || $allyTextID > 3) ? 1 : $allyTextID; |
23 | 23 | |
24 | 24 | |
25 | -if(sys_get_param_str('isSaveOptions')) { |
|
25 | +if (sys_get_param_str('isSaveOptions')) { |
|
26 | 26 | require_once('includes/includes/sys_avatar.php'); |
27 | 27 | |
28 | 28 | $new_image = $ally['ally_image']; |
@@ -34,46 +34,46 @@ discard block |
||
34 | 34 | // $template->assign_block_vars('result', $avatar_upload_result); |
35 | 35 | |
36 | 36 | $ally_changeset = array(); |
37 | - if(($new_tag = sys_get_param_str_unsafe('tag', $ally['ally_tag'])) && $new_tag != $ally['ally_tag']) { |
|
37 | + if (($new_tag = sys_get_param_str_unsafe('tag', $ally['ally_tag'])) && $new_tag != $ally['ally_tag']) { |
|
38 | 38 | $new_tag = db_escape($new_tag); |
39 | 39 | $ally_changeset[] = "`ally_tag`='{$new_tag}'"; |
40 | 40 | db_user_set_by_id($ally['ally_user_id'], "`username`='[{$new_tag}]'"); |
41 | 41 | } |
42 | - if(($new_name = sys_get_param_str_unsafe('name', $ally['ally_name'])) && $new_name != $ally['ally_name']) { |
|
42 | + if (($new_name = sys_get_param_str_unsafe('name', $ally['ally_name'])) && $new_name != $ally['ally_name']) { |
|
43 | 43 | $new_name = db_escape($new_name); |
44 | 44 | $ally_changeset[] = "`ally_name`='{$new_name}'"; |
45 | 45 | } |
46 | 46 | |
47 | - if(($new_owner_rank = sys_get_param_str_unsafe('owner_range', $ally['ally_owner_range'])) && $new_owner_rank != $ally['ally_owner_range']) { |
|
47 | + if (($new_owner_rank = sys_get_param_str_unsafe('owner_range', $ally['ally_owner_range'])) && $new_owner_rank != $ally['ally_owner_range']) { |
|
48 | 48 | $new_owner_rank = db_escape($new_owner_rank); |
49 | 49 | $ally_changeset[] = "`ally_owner_range` = '{$new_owner_rank}'"; |
50 | 50 | } |
51 | - if(($new_web = sys_get_param_str_unsafe('web', $ally['ally_web'])) && $new_web != $ally['ally_web']) { |
|
51 | + if (($new_web = sys_get_param_str_unsafe('web', $ally['ally_web'])) && $new_web != $ally['ally_web']) { |
|
52 | 52 | $new_web = db_escape($new_web); |
53 | 53 | $ally_changeset[] = "`ally_web` = '{$new_web}'"; |
54 | 54 | } |
55 | 55 | $new_request = sys_get_param_int('request_notallow', $ally['ally_request_notallow']); |
56 | 56 | $ally_changeset[] = "`ally_request_notallow` = '{$new_request}'"; |
57 | - if($new_image != $ally['ally_image']) { |
|
57 | + if ($new_image != $ally['ally_image']) { |
|
58 | 58 | $new_image = intval($new_image); |
59 | 59 | $ally_changeset[] = "`ally_image` = '{$new_image}'"; |
60 | 60 | } |
61 | 61 | |
62 | - if(!empty($ally_changeset)) { |
|
62 | + if (!empty($ally_changeset)) { |
|
63 | 63 | db_ally_update_by_changeset($ally_changeset, $ally); |
64 | 64 | sys_redirect('alliance.php?mode=admin&edit=ally'); |
65 | 65 | } |
66 | -} elseif(sys_get_param_str('isSaveText')) { |
|
66 | +} elseif (sys_get_param_str('isSaveText')) { |
|
67 | 67 | $text = sys_get_param_str_both('text'); |
68 | 68 | db_ally_update_texts($text_list, $allyTextID, $text, $ally); |
69 | 69 | $ally[$text_list[$allyTextID]['db_field']] = $text['unsafe']; |
70 | -} elseif(sys_get_param_str('isTransfer') && $idNewLeader = sys_get_param_id('idNewLeader')) { |
|
71 | - if(!$isAllyOwner) { |
|
70 | +} elseif (sys_get_param_str('isTransfer') && $idNewLeader = sys_get_param_id('idNewLeader')) { |
|
71 | + if (!$isAllyOwner) { |
|
72 | 72 | message($lang['Denied_access'], $lang['ally_admin']); |
73 | 73 | } |
74 | 74 | |
75 | 75 | $newLeader = db_user_by_id($idNewLeader, false, `ally_id`); |
76 | - if($newLeader['ally_id'] == $user['ally_id']) { |
|
76 | + if ($newLeader['ally_id'] == $user['ally_id']) { |
|
77 | 77 | sn_db_transaction_start(); |
78 | 78 | db_user_set_by_id($user['id'], "`ally_rank_id`='0'"); |
79 | 79 | db_ally_update_owner($idNewLeader, $user); |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | sn_db_transaction_commit(); |
82 | 82 | sys_redirect('alliance.php'); |
83 | 83 | } |
84 | -} elseif(sys_get_param_str('isDisband') && sys_get_param_str('isConfirmDisband')) { |
|
85 | - if(!$isAllyOwner) { |
|
84 | +} elseif (sys_get_param_str('isDisband') && sys_get_param_str('isConfirmDisband')) { |
|
85 | + if (!$isAllyOwner) { |
|
86 | 86 | message($lang['Denied_access'], $lang['ally_admin']); |
87 | 87 | } |
88 | 88 | sn_db_transaction_start(); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $userAllyAdmins = db_user_list("`ally_id`= {$ally['id']}", false, '`id`, `username`'); |
129 | 129 | unset($tmp); |
130 | 130 | // while ($userAllyAdmin = db_fetch($userAllyAdmins)) |
131 | - foreach($userAllyAdmins as $userAllyAdmin) { |
|
131 | + foreach ($userAllyAdmins as $userAllyAdmin) { |
|
132 | 132 | // pdump($userAllyAdmin); |
133 | 133 | $tmp .= "<option value={$userAllyAdmin['id']}>{$userAllyAdmin['username']}</option>"; |
134 | 134 | } |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | $template->assign_var('adminMembers', $tmp); |
137 | 137 | } |
138 | 138 | |
139 | -foreach($sn_ali_admin_internal as $sn_ali_admin_action => $sn_ali_admin_action_locale) { |
|
140 | - if(!$sn_ali_admin_action_locale['title']) { |
|
139 | +foreach ($sn_ali_admin_internal as $sn_ali_admin_action => $sn_ali_admin_action_locale) { |
|
140 | + if (!$sn_ali_admin_action_locale['title']) { |
|
141 | 141 | continue; |
142 | 142 | } |
143 | 143 | $template->assign_block_vars('admin_actions', array( |
@@ -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 | } |