@@ -4,9 +4,9 @@ discard block |
||
4 | 4 | |
5 | 5 | global $debug, $lang, $user, $planetrow; |
6 | 6 | |
7 | -if(!empty($_POST['return']) && is_array($_POST['return'])) { |
|
8 | - foreach($_POST['return'] as $fleet_id) { |
|
9 | - if($fleet_id = idval($fleet_id)) { |
|
7 | +if (!empty($_POST['return']) && is_array($_POST['return'])) { |
|
8 | + foreach ($_POST['return'] as $fleet_id) { |
|
9 | + if ($fleet_id = idval($fleet_id)) { |
|
10 | 10 | sn_db_transaction_start(); |
11 | 11 | $objFleet = new Fleet(); |
12 | 12 | $objFleet->dbLoad($fleet_id); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | lng_include('overview'); |
31 | 31 | lng_include('fleet'); |
32 | 32 | |
33 | -if(!$planetrow) { |
|
33 | +if (!$planetrow) { |
|
34 | 34 | message($lang['fl_noplanetrow'], $lang['fl_error']); |
35 | 35 | } |
36 | 36 | |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | |
39 | 39 | $i = 0; |
40 | 40 | $objFleetList = FleetList::dbGetFleetListByOwnerId($user['id']); |
41 | -if(!empty($objFleetList)) { |
|
42 | - foreach($objFleetList->_container as $fleet_id => $objFleet) { |
|
41 | +if (!empty($objFleetList)) { |
|
42 | + foreach ($objFleetList->_container as $fleet_id => $objFleet) { |
|
43 | 43 | $i++; |
44 | 44 | $fleet_data = tplParseFleetObject($objFleet, $i, $user); |
45 | 45 | |
46 | 46 | $template->assign_block_vars('fleets', $fleet_data['fleet']); |
47 | 47 | |
48 | - foreach($fleet_data['ships'] as $ship_data) { |
|
48 | + foreach ($fleet_data['ships'] as $ship_data) { |
|
49 | 49 | $template->assign_block_vars('fleets.ships', $ship_data); |
50 | 50 | } |
51 | 51 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
16 | 16 | |
17 | -if($user['authlevel'] < 3) { |
|
17 | +if ($user['authlevel'] < 3) { |
|
18 | 18 | AdminMessage($lang['adm_err_denied']); |
19 | 19 | } |
20 | 20 | |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | ), |
29 | 29 | ); |
30 | 30 | $template->assign_block_vars('int_type_selected', $allowed_types[-1]); |
31 | -foreach($sn_message_class_list as $key => $value) { |
|
32 | - if($key == MSG_TYPE_NEW || $key == MSG_TYPE_OUTBOX) { |
|
31 | +foreach ($sn_message_class_list as $key => $value) { |
|
32 | + if ($key == MSG_TYPE_NEW || $key == MSG_TYPE_OUTBOX) { |
|
33 | 33 | continue; |
34 | 34 | } |
35 | 35 | |
@@ -41,17 +41,17 @@ discard block |
||
41 | 41 | |
42 | 42 | |
43 | 43 | $message_delete = sys_get_param_id('msg_del'); |
44 | -if(sys_get_param('str_delete_selected') && is_array($message_delete = sys_get_param('selected')) && !empty($message_delete)) { |
|
44 | +if (sys_get_param('str_delete_selected') && is_array($message_delete = sys_get_param('selected')) && !empty($message_delete)) { |
|
45 | 45 | $message_delete = implode(', ', $message_delete); |
46 | 46 | } |
47 | 47 | |
48 | -if($message_delete) { |
|
48 | +if ($message_delete) { |
|
49 | 49 | db_message_list_delete_set($message_delete); |
50 | 50 | $template->assign_block_vars('result', array('MESSAGE' => sprintf($lang['mlst_messages_deleted'], $message_delete))); |
51 | 51 | } |
52 | 52 | |
53 | 53 | |
54 | -if(sys_get_param('str_delete_date') && checkdate($month = sys_get_param_id('delete_month'), $day = sys_get_param_id('delete_day'), $year = sys_get_param_id('delete_year'))) { |
|
54 | +if (sys_get_param('str_delete_date') && checkdate($month = sys_get_param_id('delete_month'), $day = sys_get_param_id('delete_day'), $year = sys_get_param_id('delete_year'))) { |
|
55 | 55 | $delete_date = "{$year}-{$month}-{$day}"; |
56 | 56 | db_message_list_delete_by_date($delete_date, $int_type_selected); |
57 | 57 | $template->assign_block_vars('result', array('MESSAGE' => sprintf($lang['mlst_messages_deleted_date'], $allowed_types[$int_type_selected]['TEXT'], $delete_date))); |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | |
64 | 64 | $int_page_current = min(sys_get_param_id('int_page_current', 1), $page_max); |
65 | 65 | |
66 | -if(sys_get_param('page_prev') && $int_page_current > 1) { |
|
66 | +if (sys_get_param('page_prev') && $int_page_current > 1) { |
|
67 | 67 | $int_page_current--; |
68 | -} elseif(sys_get_param('page_next') && $int_page_current < $page_max) { |
|
68 | +} elseif (sys_get_param('page_next') && $int_page_current < $page_max) { |
|
69 | 69 | $int_page_current++; |
70 | 70 | } |
71 | 71 | |
72 | -for($i = 1; $i <= $page_max; $i++) { |
|
72 | +for ($i = 1; $i <= $page_max; $i++) { |
|
73 | 73 | $template->assign_block_vars('page', array('NUMBER' => $i)); |
74 | 74 | } |
75 | 75 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $StartRec = ($int_page_current - 1) * 25; |
78 | 78 | |
79 | 79 | $Messages = db_message_list_admin_by_type($int_type_selected, $StartRec); |
80 | -while($row = db_fetch($Messages)) { |
|
80 | +while ($row = db_fetch($Messages)) { |
|
81 | 81 | $row['FROM'] = htmlentities($row['FROM'], ENT_COMPAT, 'UTF-8'); |
82 | 82 | $row['OWNER_NAME'] = htmlentities($row['OWNER_NAME'], ENT_COMPAT, 'UTF-8'); |
83 | 83 | $row['TEXT'] = nl2br($row['TEXT']); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
13 | 13 | |
14 | 14 | // if ($user['authlevel'] < 2) |
15 | -if($user['authlevel'] < 3) { |
|
15 | +if ($user['authlevel'] < 3) { |
|
16 | 16 | AdminMessage($lang['adm_err_denied']); |
17 | 17 | } |
18 | 18 | |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | //while($CurrentFleet = db_fetch($FlyingFleets)) |
23 | 23 | |
24 | 24 | $all_flying_fleets = FleetList::dbGetFleetList(); |
25 | -foreach($all_flying_fleets->_container as $fleet_id => $objFleet) { |
|
25 | +foreach ($all_flying_fleets->_container as $fleet_id => $objFleet) { |
|
26 | 26 | $FleetOwner = db_user_by_id($objFleet->playerOwnerId); |
27 | 27 | $TargetOwner = db_user_by_id($objFleet->target_owner_id); |
28 | 28 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $fleet_data['fleet']['STAY_TIME_INT'] = $objFleet->time_mission_job_complete; |
34 | 34 | |
35 | 35 | $template->assign_block_vars('fleets', $fleet_data['fleet']); |
36 | - foreach($fleet_data['ships'] as $ship_data) { |
|
36 | + foreach ($fleet_data['ships'] as $ship_data) { |
|
37 | 37 | $template->assign_block_vars('fleets.ships', $ship_data); |
38 | 38 | } |
39 | 39 | } |
@@ -14,25 +14,25 @@ discard block |
||
14 | 14 | |
15 | 15 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
16 | 16 | |
17 | -if($user['authlevel'] < 3) { |
|
17 | +if ($user['authlevel'] < 3) { |
|
18 | 18 | AdminMessage($lang['adm_err_denied']); |
19 | 19 | } |
20 | 20 | |
21 | -if($delete = sys_get_param_id('delete')) { |
|
21 | +if ($delete = sys_get_param_id('delete')) { |
|
22 | 22 | db_log_delete_by_id($delete); |
23 | -} elseif(sys_get_param_str('delete_update_info')) { |
|
23 | +} elseif (sys_get_param_str('delete_update_info')) { |
|
24 | 24 | db_log_delete_update_and_stat_calc(); |
25 | -} elseif(sys_get_param_str('deleteall') == 'yes') { |
|
25 | +} elseif (sys_get_param_str('deleteall') == 'yes') { |
|
26 | 26 | // doquery("TRUNCATE TABLE `{{logs}}`"); |
27 | 27 | } |
28 | 28 | |
29 | -if($detail = sys_get_param_id('detail')) { |
|
29 | +if ($detail = sys_get_param_id('detail')) { |
|
30 | 30 | $template = gettemplate('admin/adm_log_main_detail', true); |
31 | 31 | |
32 | 32 | $errorInfo = db_log_get_by_id($detail); |
33 | 33 | $error_dump = unserialize($errorInfo['log_dump']); |
34 | - if(is_array($error_dump)) { |
|
35 | - foreach($error_dump as $key => $value) { |
|
34 | + if (is_array($error_dump)) { |
|
35 | + foreach ($error_dump as $key => $value) { |
|
36 | 36 | $v = array( |
37 | 37 | 'VAR_NAME' => $key, |
38 | 38 | 'VAR_VALUE' => $key == 'query_log' ? $value : dump($value, $key) |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | |
48 | 48 | $i = 0; |
49 | 49 | $query = db_log_list_get_last_100(); |
50 | - while($u = db_fetch($query)) { |
|
50 | + while ($u = db_fetch($query)) { |
|
51 | 51 | $i++; |
52 | 52 | $v = array(); |
53 | - foreach($u as $key => $value) { |
|
53 | + foreach ($u as $key => $value) { |
|
54 | 54 | $v[strtoupper($key)] = $value; |
55 | 55 | } |
56 | 56 | $template->assign_block_vars('error', $v); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | require('../includes/init.' . substr(strrchr(__FILE__, '.'), 1)); |
6 | 6 | |
7 | -if($user['authlevel'] < 3) |
|
7 | +if ($user['authlevel'] < 3) |
|
8 | 8 | { |
9 | 9 | message($lang['sys_noalloaw'], $lang['sys_noaccess']); |
10 | 10 | die(); |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | // [#] info_best_battles 1b0 |
21 | 21 | $best_reports = array(); |
22 | 22 | |
23 | -if(defined('MODULE_INFO_BEST_BATTLES_QUERY')) { |
|
23 | +if (defined('MODULE_INFO_BEST_BATTLES_QUERY')) { |
|
24 | 24 | $query = db_ube_report_get_best_battles(); |
25 | - while($row = db_fetch($query)) { |
|
25 | + while ($row = db_fetch($query)) { |
|
26 | 26 | $best_reports[] = $row['ube_report_id']; |
27 | 27 | } |
28 | 28 | } |
@@ -186,16 +186,16 @@ discard block |
||
186 | 186 | |
187 | 187 | function sn_maintenance_pack_user_list($user_list) { |
188 | 188 | $user_list = explode(',', $user_list); |
189 | - foreach($user_list as $key => $user_id) { |
|
190 | - if(!ceil(floatval($user_id))) { |
|
189 | + foreach ($user_list as $key => $user_id) { |
|
190 | + if (!ceil(floatval($user_id))) { |
|
191 | 191 | unset($user_list[$key]); |
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | 195 | $result = array(); |
196 | - if(!empty($user_list)) { |
|
196 | + if (!empty($user_list)) { |
|
197 | 197 | $query = db_user_list_get_by_id_array($user_list); |
198 | - while($row = db_fetch($query)) { |
|
198 | + while ($row = db_fetch($query)) { |
|
199 | 199 | $result[] = $row['id']; |
200 | 200 | } |
201 | 201 | } |
@@ -210,13 +210,13 @@ discard block |
||
210 | 210 | $old_server_status == GAME_DISABLE_NONE ? $config->db_saveItem('game_disable', GAME_DISABLE_MAINTENANCE) : false; |
211 | 211 | sn_db_transaction_commit(); |
212 | 212 | |
213 | -foreach($ques as $que_transaction) { |
|
213 | +foreach ($ques as $que_transaction) { |
|
214 | 214 | sn_db_transaction_start(); |
215 | 215 | |
216 | 216 | !is_array($que_transaction) ? $que_transaction = array($que_transaction) : false; |
217 | - foreach($que_transaction as $que) { |
|
217 | + foreach ($que_transaction as $que) { |
|
218 | 218 | set_time_limit(120); |
219 | - if(is_callable($que)) { |
|
219 | + if (is_callable($que)) { |
|
220 | 220 | $QryResult = call_user_func($que); |
221 | 221 | } else { |
222 | 222 | $QryResult = doquery($que); |
@@ -12,19 +12,19 @@ discard block |
||
12 | 12 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
13 | 13 | |
14 | 14 | // if($user['authlevel'] < 1) |
15 | -if($user['authlevel'] < 3) { |
|
15 | +if ($user['authlevel'] < 3) { |
|
16 | 16 | AdminMessage($lang['adm_err_denied']); |
17 | 17 | } |
18 | 18 | |
19 | 19 | $mode = sys_get_param_int('mode'); |
20 | 20 | |
21 | -switch($mode) { |
|
21 | +switch ($mode) { |
|
22 | 22 | case ADM_TOOL_CONFIG_RELOAD: |
23 | 23 | $config->db_loadAll(); |
24 | 24 | sys_refresh_tablelist(); |
25 | 25 | |
26 | 26 | $config->db_loadItem('game_watchlist'); |
27 | - if($config->game_watchlist) { |
|
27 | + if ($config->game_watchlist) { |
|
28 | 28 | $config->game_watchlist_array = explode(';', $config->game_watchlist); |
29 | 29 | } else { |
30 | 30 | unset($config->game_watchlist_array); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $lang['adm_tool_sql_client_version'] => db_get_client_info(), |
70 | 70 | $lang['adm_tool_sql_host_info'] => db_get_host_info(), |
71 | 71 | ); |
72 | - foreach($status as $key => $value) { |
|
72 | + foreach ($status as $key => $value) { |
|
73 | 73 | $template->assign_block_vars('table.row', array( |
74 | 74 | 'VALUE_1' => $key, |
75 | 75 | 'VALUE_2' => $value, |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $template->assign_block_vars('table', $lang['adm_tool_sql_table']['status']); |
80 | 80 | $status = explode(' ', db_server_stat()); |
81 | - foreach($status as $value) { |
|
81 | + foreach ($status as $value) { |
|
82 | 82 | $row = explode(': ', $value); |
83 | 83 | $template->assign_block_vars('table.row', array( |
84 | 84 | 'VALUE_1' => $row[0], |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | $template->assign_block_vars('table', $lang['adm_tool_sql_table']['params']); |
91 | 91 | $result = db_core_show_status(); |
92 | - while($row = db_fetch($result)) { |
|
92 | + while ($row = db_fetch($result)) { |
|
93 | 93 | $template->assign_block_vars('table.row', array( |
94 | 94 | 'VALUE_1' => $row['Variable_name'], |
95 | 95 | 'VALUE_2' => $row['Value'], |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
16 | 16 | |
17 | -if($user['authlevel'] < 3) { |
|
17 | +if ($user['authlevel'] < 3) { |
|
18 | 18 | AdminMessage($lang['adm_err_denied']); |
19 | 19 | } |
20 | 20 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | ); |
26 | 26 | |
27 | 27 | $query = db_payment_list_payers(); |
28 | -while($row = db_fetch($query)) { |
|
28 | +while ($row = db_fetch($query)) { |
|
29 | 29 | $payer_list[$row['payment_user_id']] = '[' . $row['payment_user_id'] . '] ' . $row['payment_user_name']; |
30 | 30 | } |
31 | 31 | tpl_assign_select($template, 'payer', $payer_list); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | ); |
36 | 36 | |
37 | 37 | $query = db_payment_list_modules(); |
38 | -while($row = db_fetch($query)) { |
|
38 | +while ($row = db_fetch($query)) { |
|
39 | 39 | $module_list[$row['payment_module_name']] = $row['payment_module_name']; |
40 | 40 | } |
41 | 41 | tpl_assign_select($template, 'module', $module_list); |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | |
51 | 51 | $query = db_payment_list_get($flt_payer, $flt_status, $flt_test, $flt_module); |
52 | 52 | |
53 | -while($row = db_fetch($query)) { |
|
53 | +while ($row = db_fetch($query)) { |
|
54 | 54 | $row2 = array(); |
55 | - foreach($row as $key => $value) { |
|
55 | + foreach ($row as $key => $value) { |
|
56 | 56 | $row2[strtoupper($key)] = $value; |
57 | 57 | } |
58 | 58 | $template->assign_block_vars('payment', $row2); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | $target_mission = sys_get_param_int('mission'); |
38 | 38 | $sn_group_missions = sn_get_groups('missions'); |
39 | - if(empty($sn_group_missions[$target_mission]['AJAX'])) { |
|
39 | + if (empty($sn_group_missions[$target_mission]['AJAX'])) { |
|
40 | 40 | die($lang['gs_c00']); |
41 | 41 | } |
42 | 42 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | ); |
52 | 52 | // fleet_ajax now can send fleets only to existing planets/moons |
53 | 53 | // TODO - sending colonization and expeditions in 1 click |
54 | - if(!uni_coordinates_valid($target_coord)) { |
|
54 | + if (!uni_coordinates_valid($target_coord)) { |
|
55 | 55 | die($lang['gs_c02']); |
56 | 56 | } |
57 | 57 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | // TODO - DEADLOCK CAN BE HERE!!!! We should lock SOURCE and TARGET owners in one query |
64 | 64 | $target_row = db_planet_by_vector($target_coord); |
65 | - if(empty($target_row)) { |
|
65 | + if (empty($target_row)) { |
|
66 | 66 | $target_row = $target_coord; |
67 | 67 | $target_row['id_owner'] = 0; |
68 | 68 | // If fleet destination is PT_DEBRIS - then it's actually destination is PT_PLANET // TODO - REMOVE! Debris should be valid DESTINATION planet_type! |
@@ -73,15 +73,15 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | $fleet_array = array(); |
76 | - switch($target_mission) { |
|
76 | + switch ($target_mission) { |
|
77 | 77 | case MT_SPY: |
78 | 78 | $fleet_array[SHIP_SPY] = min(mrc_get_level($user, $planetrow, SHIP_SPY), abs(classSupernova::$user_options[PLAYER_OPTION_FLEET_SPY_DEFAULT])); |
79 | 79 | $unit_group = 'flt_spies'; |
80 | 80 | break; |
81 | 81 | |
82 | 82 | case MT_RECYCLE: |
83 | - foreach(sn_get_groups('flt_recyclers') as $unit_id) { |
|
84 | - if($unit_count = mrc_get_level($user, $planetrow, $unit_id)) { |
|
83 | + foreach (sn_get_groups('flt_recyclers') as $unit_id) { |
|
84 | + if ($unit_count = mrc_get_level($user, $planetrow, $unit_id)) { |
|
85 | 85 | $fleet_array[$unit_id] = $unit_count; |
86 | 86 | } |
87 | 87 | } |
@@ -106,16 +106,16 @@ discard block |
||
106 | 106 | 'target_structure' => $target_structure = sys_get_param_int('structures'), |
107 | 107 | ) |
108 | 108 | ); |
109 | - if($isAttackAllowed != ATTACK_ALLOWED) { |
|
109 | + if ($isAttackAllowed != ATTACK_ALLOWED) { |
|
110 | 110 | die($lang['fl_attack_error'][$isAttackAllowed]); |
111 | 111 | } |
112 | 112 | |
113 | 113 | $db_changeset = array(); |
114 | - foreach($fleet_array as $unit_id => $unit_count) { |
|
114 | + foreach ($fleet_array as $unit_id => $unit_count) { |
|
115 | 115 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, -$unit_count, $user, $planetrow); |
116 | 116 | } |
117 | 117 | |
118 | - if($target_mission == MT_MISSILE) { |
|
118 | + if ($target_mission == MT_MISSILE) { |
|
119 | 119 | $distance = abs($target_coord['system'] - $planetrow['system']); |
120 | 120 | $duration = round((30 + (60 * $distance)) / flt_server_flight_speed_multiplier()); |
121 | 121 | $arrival = SN_TIME_NOW + $duration; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | } else { |
126 | 126 | $travel_data = flt_travel_data($user, $planetrow, $target_coord, $fleet_array, 10); |
127 | 127 | |
128 | - if($planetrow['deuterium'] < $travel_data['consumption']) { |
|
128 | + if ($planetrow['deuterium'] < $travel_data['consumption']) { |
|
129 | 129 | die($lang['gs_c13']); |
130 | 130 | } |
131 | 131 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | |
147 | 147 | $ships_sent = array(); |
148 | 148 | $ships_sent_js = 0; |
149 | - foreach($fleet_array as $unit_id => $unit_count) { |
|
149 | + foreach ($fleet_array as $unit_id => $unit_count) { |
|
150 | 150 | $ships_sent[] = "{$unit_count} {$lang['tech'][$unit_id]}"; |
151 | 151 | $ships_sent_js += mrc_get_level($user, $planetrow, $unit_id, false, true); |
152 | 152 | } |
@@ -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 = $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($config->_MODE != CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) { |
|
80 | + if ($config->_MODE != CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $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 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $skip_fleet_update = true; |
103 | 103 | |
104 | 104 | $history = sys_get_param_str('history'); |
105 | - if(!$history) { |
|
105 | + if (!$history) { |
|
106 | 106 | $config->array_set('users', $user['id'], 'chat_last_refresh', SN_TIME_MICRO); |
107 | 107 | } |
108 | 108 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $last_message = ''; |
111 | 111 | $alliance = 0; |
112 | 112 | $template_result['.']['chat'] = array(); |
113 | - if(!$history && $config->_MODE != CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) { |
|
113 | + if (!$history && $config->_MODE != CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) { |
|
114 | 114 | $result['disable'] = true; |
115 | 115 | $template_result['.']['chat'][] = array( |
116 | 116 | 'TIME' => date(FMT_DATE_TIME, htmlentities(SN_CLIENT_TIME_LOCAL, ENT_QUOTES, 'utf-8')), |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | |
124 | 124 | $where_add = ''; |
125 | 125 | $last_message = 0; |
126 | - if($history) { |
|
126 | + if ($history) { |
|
127 | 127 | $rows = db_chat_message_count_by_ally($alliance); |
128 | 128 | $page_count = ceil($rows['CNT'] / $page_limit); |
129 | 129 | |
130 | - for($i = 0; $i < $page_count; $i++) { |
|
130 | + for ($i = 0; $i < $page_count; $i++) { |
|
131 | 131 | $template_result['.']['page'][] = array( |
132 | 132 | 'NUMBER' => $i |
133 | 133 | ); |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | |
142 | 142 | $start_row = $page * $page_limit; |
143 | 143 | $query = db_chat_message_get_page($alliance, $where_add, $start_row, $page_limit); |
144 | - while($chat_row = db_fetch($query)) { |
|
144 | + while ($chat_row = db_fetch($query)) { |
|
145 | 145 | // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick |
146 | 146 | $chat_row['user'] = player_nick_render_to_html($chat_row['user']); |
147 | 147 | $nick_stripped = htmlentities(strip_tags($chat_row['user']), ENT_QUOTES, 'utf-8'); |
148 | 148 | $nick = str_replace(strip_tags($chat_row['user']), $nick_stripped, $chat_row['user']); |
149 | - if(!$history) { |
|
149 | + if (!$history) { |
|
150 | 150 | $nick = "<span style=\"cursor: pointer;\" onclick=\"addSmiley('({$nick_stripped})');\">{$nick}</span>"; |
151 | 151 | } |
152 | 152 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $template = gettemplate('chat_messages', $template); |
172 | 172 | $template->assign_recursive($template_result); |
173 | 173 | |
174 | - if($history) { |
|
174 | + if ($history) { |
|
175 | 175 | display($template, "{$lang['chat_history']} - {$lang[$alliance ? 'chat_ally' : 'chat_common']}", true, '', false, true); |
176 | 176 | } else { |
177 | 177 | $result['last_message'] = $last_message; |