@@ -2,28 +2,28 @@ discard block |
||
2 | 2 | |
3 | 3 | $classLocale = classLocale::$lang; |
4 | 4 | |
5 | -if(SN_IN_FLEET !== true) { |
|
5 | +if (SN_IN_FLEET !== true) { |
|
6 | 6 | classSupernova::$debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
7 | 7 | } |
8 | 8 | |
9 | 9 | $fleetid = sys_get_param_id('fleetid'); |
10 | 10 | |
11 | -if(!is_numeric($fleetid) || empty($fleetid)) { |
|
11 | +if (!is_numeric($fleetid) || empty($fleetid)) { |
|
12 | 12 | header("Location: fleet.php"); |
13 | 13 | exit(); |
14 | 14 | } |
15 | 15 | |
16 | 16 | $objFleet = new Fleet(); |
17 | 17 | $objFleet->dbLoad($fleetid); |
18 | -if(!$objFleet->dbId) { |
|
18 | +if (!$objFleet->dbId) { |
|
19 | 19 | message(classLocale::$lang['fl_fleet_not_exists'], classLocale::$lang['fl_error']); |
20 | 20 | } |
21 | 21 | |
22 | -if($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) { |
|
22 | +if ($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) { |
|
23 | 23 | message(classLocale::$lang['fl_isback'], classLocale::$lang['fl_error']); |
24 | 24 | } |
25 | 25 | |
26 | -if($objFleet->playerOwnerId != $user['id']) { |
|
26 | +if ($objFleet->playerOwnerId != $user['id']) { |
|
27 | 27 | classSupernova::$debug->warning(classLocale::$lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301); |
28 | 28 | message(classLocale::$lang['fl_aks_hack_wrong_fleet'], classLocale::$lang['fl_error']); |
29 | 29 | } |
@@ -34,19 +34,19 @@ discard block |
||
34 | 34 | |
35 | 35 | !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false; |
36 | 36 | |
37 | -if($userToAdd_unsafe) { |
|
37 | +if ($userToAdd_unsafe) { |
|
38 | 38 | $userToAdd = db_escape($userToAdd_unsafe); |
39 | 39 | $userToAddID = DBStaticUser::db_user_by_username($userToAdd_unsafe, false, 'id', true, true); |
40 | 40 | $userToAddID = $userToAddID['id']; |
41 | 41 | |
42 | - if($objFleet->target_owner_id == $userToAddID) { |
|
42 | + if ($objFleet->target_owner_id == $userToAddID) { |
|
43 | 43 | message(classLocale::$lang['flt_aks_player_same'], classLocale::$lang['fl_error']); |
44 | 44 | } |
45 | 45 | |
46 | - if($userToAddID) { |
|
47 | - if(!$aks) { |
|
46 | + if ($userToAddID) { |
|
47 | + if (!$aks) { |
|
48 | 48 | // No AСS exists - making one |
49 | - if(!$objFleet->group_id) { |
|
49 | + if (!$objFleet->group_id) { |
|
50 | 50 | DBStaticFleetACS::db_acs_insert($fleetid, $user, $objFleet); |
51 | 51 | |
52 | 52 | $aks = DBStaticFleetACS::db_acs_get_by_fleet($fleetid); |
@@ -61,22 +61,22 @@ discard block |
||
61 | 61 | |
62 | 62 | $isUserExists = false; |
63 | 63 | $invited_ar = explode(",", $aks['eingeladen']); |
64 | - foreach($invited_ar as $inv) { |
|
65 | - if($userToAddID == $inv) { |
|
64 | + foreach ($invited_ar as $inv) { |
|
65 | + if ($userToAddID == $inv) { |
|
66 | 66 | $isUserExists = true; |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | - if(count($invited_ar) >= 5) { |
|
70 | + if (count($invited_ar) >= 5) { |
|
71 | 71 | message(classLocale::$lang['flt_aks_error_too_much_players'], classLocale::$lang['fl_error']); |
72 | 72 | } |
73 | 73 | |
74 | - if($isUserExists) { |
|
74 | + if ($isUserExists) { |
|
75 | 75 | $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited_already'], $userToAdd) : false; |
76 | 76 | } else { |
77 | 77 | $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited'], $userToAdd); |
78 | 78 | !(DBStaticFleetACS::db_acs_update($userToAddID, $fleetid)) ? die(sprintf(classLocale::$lang['fl_aks_adding_error'], classSupernova::$db->db_error())) : false; |
79 | - $aks['eingeladen'] .= ',' . $userToAddID; |
|
79 | + $aks['eingeladen'] .= ','.$userToAddID; |
|
80 | 80 | } |
81 | 81 | DBStaticMessages::msg_send_simple_message($userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'], |
82 | 82 | classLocale::$lang['fl_aks_invite_message_header'], sprintf(classLocale::$lang['fl_aks_invite_message'], $user['username'])); |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | 'MISSION_NAME' => classLocale::$lang['type_mission'][MT_ACS], |
94 | 94 | )); |
95 | 95 | |
96 | -if($aks['eingeladen'] && is_array($members = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) { |
|
97 | - foreach($members as $row) { |
|
96 | +if ($aks['eingeladen'] && is_array($members = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) { |
|
97 | + foreach ($members as $row) { |
|
98 | 98 | $template->assign_block_vars('invited', array( |
99 | 99 | 'NAME' => $row['username'], |
100 | 100 | )); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $fleet_data = tplParseFleetObject($objFleet, $i, $user); |
120 | 120 | |
121 | 121 | $template->assign_block_vars('fleets', $fleet_data['fleet']); |
122 | -foreach($fleet_data['ships'] as $ship_data) { |
|
122 | +foreach ($fleet_data['ships'] as $ship_data) { |
|
123 | 123 | $template->assign_block_vars('fleets.ships', $ship_data); |
124 | 124 | } |
125 | 125 |
@@ -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 | classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
7 | 7 | } |
8 | 8 | |
@@ -11,21 +11,21 @@ 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(classLocale::$lang['have_not_name'], classLocale::$lang['make_alliance']); |
17 | 17 | } |
18 | 18 | |
19 | 19 | $query = DBStaticAlly::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, classLocale::$lang['always_exist']), classLocale::$lang['make_alliance']); |
22 | 22 | } |
23 | 23 | |
24 | 24 | DBStaticAlly::db_ally_insert($ally_name, $ally_tag, $user); |
25 | 25 | $ally_id = classSupernova::$db->db_insert_id(); |
26 | - DBStaticUser::db_user_set_by_id($user['id'], "`ally_tag` = '{$ally_tag}', `ally_id`= {$ally_id}, `ally_name`='{$ally_name}', `ally_register_time`= " . SN_TIME_NOW . ""); |
|
26 | + DBStaticUser::db_user_set_by_id($user['id'], "`ally_tag` = '{$ally_tag}', `ally_id`= {$ally_id}, `ally_name`='{$ally_name}', `ally_register_time`= ".SN_TIME_NOW.""); |
|
27 | 27 | |
28 | - $ally_user = classSupernova::$gc->cacheOperator->db_ins_record(LOC_USER, "`username` = '[{$ally_tag}]', `register_time` = " . SN_TIME_NOW . ", `user_as_ally` = {$ally_id}"); |
|
28 | + $ally_user = classSupernova::$gc->cacheOperator->db_ins_record(LOC_USER, "`username` = '[{$ally_tag}]', `register_time` = ".SN_TIME_NOW.", `user_as_ally` = {$ally_id}"); |
|
29 | 29 | // $ally_user_id = db_insert_id(); |
30 | 30 | $ally_user_id = is_array($ally_user) ? $ally_user['id'] : 'NULL'; |
31 | 31 | DBStaticAlly::db_ally_update_ally_user($ally_user_id, $ally_id); |
@@ -55,11 +55,10 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | public static function db_planet_by_vector($vector, $prefix = '', $for_update = false, $fields = '*') { |
58 | - $galaxy = isset($vector[$prefix . 'galaxy']) ? intval($vector[$prefix . 'galaxy']) : 0; |
|
59 | - $system = isset($vector[$prefix . 'system']) ? intval($vector[$prefix . 'system']) : 0; |
|
60 | - $planet = isset($vector[$prefix . 'planet']) ? intval($vector[$prefix . 'planet']) : 0; |
|
61 | - $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) : |
|
62 | - (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0); |
|
58 | + $galaxy = isset($vector[$prefix.'galaxy']) ? intval($vector[$prefix.'galaxy']) : 0; |
|
59 | + $system = isset($vector[$prefix.'system']) ? intval($vector[$prefix.'system']) : 0; |
|
60 | + $planet = isset($vector[$prefix.'planet']) ? intval($vector[$prefix.'planet']) : 0; |
|
61 | + $planet_type = isset($vector[$prefix.'planet_type']) ? intval($vector[$prefix.'planet_type']) : (isset($vector[$prefix.'type']) ? intval($vector[$prefix.'type']) : 0); |
|
63 | 62 | $planet_type = $planet_type == PT_DEBRIS ? PT_PLANET : $planet_type; |
64 | 63 | |
65 | 64 | return DBStaticPlanet::db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update, $fields); |
@@ -85,7 +84,7 @@ discard block |
||
85 | 84 | } |
86 | 85 | |
87 | 86 | return classSupernova::$gc->cacheOperator->db_get_record_list(LOC_PLANET, |
88 | - "`parent_planet` = {$parent_id} AND `planet_type` = " . PT_MOON, true); |
|
87 | + "`parent_planet` = {$parent_id} AND `planet_type` = ".PT_MOON, true); |
|
89 | 88 | } |
90 | 89 | |
91 | 90 | public static function db_planet_by_id_and_owner($planet_id, $owner_id, $for_update = false, $fields = '*') { |
@@ -106,7 +105,7 @@ discard block |
||
106 | 105 | } |
107 | 106 | |
108 | 107 | return classSupernova::$gc->cacheOperator->db_get_record_list(LOC_PLANET, |
109 | - "`planet_type` = " . PT_MOON . " AND `id_owner` = {$user_id} AND `id` != {$this_moon_id}"); |
|
108 | + "`planet_type` = ".PT_MOON." AND `id_owner` = {$user_id} AND `id` != {$this_moon_id}"); |
|
110 | 109 | } |
111 | 110 | |
112 | 111 | public static function db_planet_list_in_system($galaxy, $system) { |
@@ -132,7 +131,7 @@ discard block |
||
132 | 131 | ); |
133 | 132 | $order_by = classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT]; |
134 | 133 | empty($sort_orders[$order_by]) ? $order_by = SORT_ID : false; |
135 | - $order_by = $sort_orders[$order_by] . ' ' . (classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE] == SORT_ASCENDING ? 'ASC' : 'DESC'); |
|
134 | + $order_by = $sort_orders[$order_by].' '.(classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE] == SORT_ASCENDING ? 'ASC' : 'DESC'); |
|
136 | 135 | |
137 | 136 | // Compilating query |
138 | 137 | return classSupernova::$gc->cacheOperator->db_get_record_list(LOC_PLANET, |
@@ -157,7 +156,7 @@ discard block |
||
157 | 156 | $fieldName = pname_resource_name($resourceId); |
158 | 157 | $value = "{$fieldName} = {$fieldName} + ('{$value}')"; |
159 | 158 | } |
160 | - if($query = implode(',', $planetRowFieldChanges)) { |
|
159 | + if ($query = implode(',', $planetRowFieldChanges)) { |
|
161 | 160 | classSupernova::$gc->db->doUpdate("UPDATE `{{planets}}` SET {$query} WHERE id = {$planetId}"); |
162 | 161 | } |
163 | 162 | } |
@@ -208,7 +207,7 @@ discard block |
||
208 | 207 | return false; |
209 | 208 | } |
210 | 209 | classSupernova::$gc->cacheOperator->db_del_record_by_id(LOC_PLANET, $planet_id); |
211 | - classSupernova::$gc->cacheOperator->db_del_record_list(LOC_UNIT, "`unit_location_type` = " . LOC_PLANET . " AND `unit_location_id` = " . $planet_id); |
|
210 | + classSupernova::$gc->cacheOperator->db_del_record_list(LOC_UNIT, "`unit_location_type` = ".LOC_PLANET." AND `unit_location_id` = ".$planet_id); |
|
212 | 211 | |
213 | 212 | // Очереди очистятся автоматически по FOREIGN KEY |
214 | 213 | return true; |
@@ -220,7 +219,7 @@ discard block |
||
220 | 219 | return false; |
221 | 220 | } |
222 | 221 | classSupernova::$gc->cacheOperator->db_del_record_list(LOC_PLANET, "`id_owner` = {$si_owner_id}"); |
223 | - classSupernova::$gc->cacheOperator->db_del_record_list(LOC_UNIT, "`unit_location_type` = " . LOC_PLANET . " AND `unit_player_id` = " . $si_owner_id); |
|
222 | + classSupernova::$gc->cacheOperator->db_del_record_list(LOC_UNIT, "`unit_location_type` = ".LOC_PLANET." AND `unit_player_id` = ".$si_owner_id); |
|
224 | 223 | |
225 | 224 | // Очереди очистятся автоматически по FOREIGN KEY |
226 | 225 | return true; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | if (SnCache::isUnitLocatorNotSet($location_type, $location_id)) { |
27 | - $got_data = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . DBStaticUnit::db_unit_time_restrictions()); |
|
27 | + $got_data = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND ".DBStaticUnit::db_unit_time_restrictions()); |
|
28 | 28 | if (!empty($got_data) && is_array($got_data)) { |
29 | 29 | foreach ($got_data as $unit_id => $unit_data) { |
30 | 30 | SnCache::setUnitLocatorByLocationAndIDs($location_type, $location_id, $unit_data); |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | |
60 | 60 | public static function db_unit_count_by_user_and_type_and_snid($user_id, $unit_type = 0, $unit_snid = 0) { |
61 | 61 | $query = classSupernova::$db->doSelect( |
62 | - "SELECT unit_snid, sum(unit_level) as `qty` FROM {{unit}} WHERE `unit_player_id` = {$user_id} " . |
|
63 | - ($unit_type ? "AND `unit_type` = {$unit_type} " : '') . |
|
64 | - ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : '') . |
|
62 | + "SELECT unit_snid, sum(unit_level) as `qty` FROM {{unit}} WHERE `unit_player_id` = {$user_id} ". |
|
63 | + ($unit_type ? "AND `unit_type` = {$unit_type} " : ''). |
|
64 | + ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : ''). |
|
65 | 65 | 'GROUP BY `unit_snid`' |
66 | 66 | ); |
67 | 67 | $result = array(); |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | WHERE |
82 | 82 | f.fleet_owner = {$user_id} AND |
83 | 83 | (f.fleet_start_planet_id = {$location_id} OR f.fleet_end_planet_id = {$location_id}) |
84 | - AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = " . LOC_FLEET . " AND " . self::db_unit_time_restrictions() . |
|
85 | - " LIMIT 1" . |
|
84 | + AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = ".LOC_FLEET." AND ".self::db_unit_time_restrictions(). |
|
85 | + " LIMIT 1". |
|
86 | 86 | ($for_update ? ' FOR UPDATE' : '')); |
87 | 87 | } |
88 | 88 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | public static function db_unit_list_laboratories($user_id) { |
91 | 91 | return classSupernova::$db->doSelect("SELECT DISTINCT unit_location_id AS `id` |
92 | 92 | FROM {{unit}} |
93 | - WHERE unit_player_id = {$user_id} AND unit_location_type = " . LOC_PLANET . " AND unit_level > 0 AND unit_snid IN (" . STRUC_LABORATORY . ", " . STRUC_LABORATORY_NANO . ");"); |
|
93 | + WHERE unit_player_id = {$user_id} AND unit_location_type = ".LOC_PLANET." AND unit_level > 0 AND unit_snid IN (".STRUC_LABORATORY.", ".STRUC_LABORATORY_NANO.");"); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | public static function db_unit_set_by_id($unit_id, $set) { |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | |
109 | 109 | public static function db_unit_list_delete($user_id = 0, $unit_location_type, $unit_location_id = 0, $unit_snid = 0) { |
110 | 110 | return classSupernova::$gc->cacheOperator->db_del_record_list(LOC_UNIT, |
111 | - "`unit_location_type` = {$unit_location_type}" . |
|
112 | - ($unit_location_id = idval($unit_location_id) ? " AND `unit_location_id` = {$unit_location_id}" : '') . |
|
113 | - ($user_id = idval($user_id) ? " AND `unit_player_id` = {$user_id}" : '') . |
|
111 | + "`unit_location_type` = {$unit_location_type}". |
|
112 | + ($unit_location_id = idval($unit_location_id) ? " AND `unit_location_id` = {$unit_location_id}" : ''). |
|
113 | + ($user_id = idval($user_id) ? " AND `unit_player_id` = {$user_id}" : ''). |
|
114 | 114 | ($unit_snid = idval($unit_snid) ? " AND `unit_snid` = {$unit_snid}" : '')); |
115 | 115 | } |
116 | 116 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | return classSupernova::$db->doSelect( |
119 | 119 | "SELECT unit_player_id, unit_type, unit_snid, unit_level, count(*) AS unit_amount |
120 | 120 | FROM `{{unit}}` |
121 | - WHERE unit_level > 0 AND " . self::db_unit_time_restrictions() . |
|
121 | + WHERE unit_level > 0 AND " . self::db_unit_time_restrictions(). |
|
122 | 122 | " GROUP BY unit_player_id, unit_type, unit_snid, unit_level" |
123 | 123 | ); |
124 | 124 | } |
@@ -130,15 +130,15 @@ discard block |
||
130 | 130 | |
131 | 131 | |
132 | 132 | public static function db_unit_list_admin_delete_mercenaries_finished() { |
133 | - return classSupernova::$db->doDelete("DELETE FROM `{{unit}}` WHERE unit_time_finish IS NOT NULL AND unit_time_finish < FROM_UNIXTIME(" . SN_TIME_NOW . ") AND unit_type = " . UNIT_MERCENARIES); |
|
133 | + return classSupernova::$db->doDelete("DELETE FROM `{{unit}}` WHERE unit_time_finish IS NOT NULL AND unit_time_finish < FROM_UNIXTIME(".SN_TIME_NOW.") AND unit_type = ".UNIT_MERCENARIES); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | public static function db_unit_list_admin_set_mercenaries_expire_time($default_length) { |
137 | 137 | return classSupernova::$db->doUpdate( |
138 | 138 | "UPDATE `{{unit}}` |
139 | 139 | SET |
140 | - unit_time_start = FROM_UNIXTIME(" . SN_TIME_NOW . "), |
|
141 | - unit_time_finish = FROM_UNIXTIME(" . (SN_TIME_NOW + $default_length) . ") |
|
140 | + unit_time_start = FROM_UNIXTIME(" . SN_TIME_NOW."), |
|
141 | + unit_time_finish = FROM_UNIXTIME(" . (SN_TIME_NOW + $default_length).") |
|
142 | 142 | WHERE unit_type = " . UNIT_MERCENARIES |
143 | 143 | ); |
144 | 144 | } |
@@ -163,13 +163,13 @@ discard block |
||
163 | 163 | |
164 | 164 | $temp = DBStaticUnit::db_get_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id'); |
165 | 165 | if (!empty($temp['unit_id'])) { |
166 | - $result = (bool)classSupernova::$gc->cacheOperator->db_upd_record_list( |
|
166 | + $result = (bool) classSupernova::$gc->cacheOperator->db_upd_record_list( |
|
167 | 167 | LOC_UNIT, "`unit_level` = `unit_level` + ($unit_value)", "`unit_id` = {$temp['unit_id']}" |
168 | 168 | ); |
169 | 169 | } else { |
170 | 170 | $locationIdRendered = $unit_location == LOC_USER ? $user['id'] : $planet_id; |
171 | 171 | $unitType = get_unit_param($unit_id, P_UNIT_TYPE); |
172 | - $result = (bool)classSupernova::$gc->cacheOperator->db_ins_record( |
|
172 | + $result = (bool) classSupernova::$gc->cacheOperator->db_ins_record( |
|
173 | 173 | LOC_UNIT, |
174 | 174 | "unit_player_id = {$user['id']}, |
175 | 175 | unit_location_type = {$unit_location}, |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | ->where('`user_as_ally` IS NULL') |
24 | 24 | ->orderBy(array('`id` DESC')); |
25 | 25 | |
26 | - return (string)$query->selectValue(); |
|
26 | + return (string) $query->selectValue(); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -48,15 +48,15 @@ discard block |
||
48 | 48 | static::buildDBQ() |
49 | 49 | ->field('id') |
50 | 50 | ->where("`user_as_ally` IS NULL") |
51 | - ->where("`user_bot` = " . USER_BOT_PLAYER) |
|
51 | + ->where("`user_bot` = ".USER_BOT_PLAYER) |
|
52 | 52 | ->setForUpdate(); |
53 | 53 | |
54 | 54 | return $query->selectIterator(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | public static function db_user_lock_with_target_owner_and_acs($user, $planet = array()) { |
58 | - $query = "SELECT 1 FROM `{{users}}` WHERE `id` = " . idval($user['id']) . |
|
59 | - (!empty($planet['id_owner']) ? ' OR `id` = ' . idval($planet['id_owner']) : '') |
|
58 | + $query = "SELECT 1 FROM `{{users}}` WHERE `id` = ".idval($user['id']). |
|
59 | + (!empty($planet['id_owner']) ? ' OR `id` = '.idval($planet['id_owner']) : '') |
|
60 | 60 | . " FOR UPDATE"; |
61 | 61 | |
62 | 62 | static::getDb()->doSelect($query); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | FROM `{{users}}` |
74 | 74 | WHERE |
75 | 75 | `user_as_ally` IS NULL" . |
76 | - ($online ? ' AND `onlinetime` > ' . (SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '') |
|
76 | + ($online ? ' AND `onlinetime` > '.(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '') |
|
77 | 77 | )); |
78 | 78 | } |
79 | 79 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | ->fieldCount('r.id', 'referral_count') |
96 | 96 | ->fieldSingleFunction('sum', 'r.dark_matter', 'referral_dm') |
97 | 97 | ->join('LEFT JOIN {{referrals}} as r on r.id_partner = u.id') |
98 | - ->where($online ? "`onlinetime` >= " . intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL') |
|
98 | + ->where($online ? "`onlinetime` >= ".intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL') |
|
99 | 99 | ->groupBy('u.id') |
100 | 100 | ->orderBy("user_as_ally, {$sort} ASC"); |
101 | 101 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | ->where('(`user_birthday_celebrated` IS NULL OR DATE_ADD(`user_birthday_celebrated`, INTERVAL 1 YEAR) < CURRENT_DATE)') |
114 | 114 | ->where('`user_as_ally` IS NULL') |
115 | 115 | ->having('`days_after_birthday` >= 0') |
116 | - ->having('`days_after_birthday` < ' . intval($config_user_birthday_range)) |
|
116 | + ->having('`days_after_birthday` < '.intval($config_user_birthday_range)) |
|
117 | 117 | ->setForUpdate(); |
118 | 118 | |
119 | 119 | $result = $query->selectIterator(); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет |
208 | 208 | |
209 | 209 | $user = classSupernova::$db->doSelectFetch( |
210 | - "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'" |
|
210 | + "SELECT * FROM {{users}} WHERE `username` ".($like ? 'LIKE' : '=')." '{$username_safe}'" |
|
211 | 211 | . " FOR UPDATE" |
212 | 212 | ); |
213 | 213 | SnCache::cache_set(LOC_USER, $user); // В кэш-юзер так же заполнять индексы |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | |
258 | 258 | |
259 | 259 | public static function db_user_list_set_mass_mail(&$owners_list, $set) { |
260 | - return classSupernova::$gc->cacheOperator->db_upd_record_list(LOC_USER, $set, !empty($owners_list) ? '`id` IN (' . implode(',', $owners_list) . ');' : ''); |
|
260 | + return classSupernova::$gc->cacheOperator->db_upd_record_list(LOC_USER, $set, !empty($owners_list) ? '`id` IN ('.implode(',', $owners_list).');' : ''); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | public static function db_user_list_set_by_ally_and_rank($ally_id, $ally_rank_id, $set) { |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @param array $playerArray |
273 | 273 | */ |
274 | 274 | public static function renderNameAndCoordinates($playerArray) { |
275 | - return "{$playerArray['username']} " . uni_render_coordinates($playerArray); |
|
275 | + return "{$playerArray['username']} ".uni_render_coordinates($playerArray); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | $fieldName = pname_resource_name($resourceId); |
304 | 304 | $value = "{$fieldName} = {$fieldName} + ('{$value}')"; |
305 | 305 | } |
306 | - if($query = implode(',', $playerRowFieldChanges)) { |
|
306 | + if ($query = implode(',', $playerRowFieldChanges)) { |
|
307 | 307 | classSupernova::$gc->db->doUpdate("UPDATE `{{users}}` SET {$query} WHERE id = {$userId}"); |
308 | 308 | } |
309 | 309 | } |
@@ -182,8 +182,8 @@ discard block |
||
182 | 182 | $query = $this->db->doSelect( |
183 | 183 | "SELECT |
184 | 184 | distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id |
185 | - FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
186 | - ($filter ? ' WHERE ' . $filter : '') . |
|
185 | + FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
186 | + ($filter ? ' WHERE '.$filter : ''). |
|
187 | 187 | ($fetch ? ' LIMIT 1' : '')); |
188 | 188 | while ($row = db_fetch($query)) { |
189 | 189 | // Исключаем из списка родительских ИД уже заблокированные записи |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | if ($indexes_str = implode(',', $parent_id_list)) { |
197 | 197 | $parent_id_field = static::$location_info[$owner_location_type][P_ID]; |
198 | 198 | classSupernova::$gc->cacheOperator->db_get_record_list($owner_location_type, |
199 | - $parent_id_field . (count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
199 | + $parent_id_field.(count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | 204 | $query = $this->db->doSelect( |
205 | - "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
205 | + "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
206 | 206 | (($filter = trim($filter)) ? " WHERE {$filter}" : '') |
207 | 207 | . " FOR UPDATE" |
208 | 208 | ); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $condition = trim($condition); |
277 | 277 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
278 | 278 | |
279 | - if ($result = $this->db->doUpdate("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) { |
|
279 | + if ($result = $this->db->doUpdate("UPDATE {{{$table_name}}} SET ".$set.($condition ? ' WHERE '.$condition : ''))) { |
|
280 | 280 | |
281 | 281 | if ($this->db->db_affected_rows()) { // Обновляем данные только если ряд был затронут |
282 | 282 | // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | public function db_lock_tables($tables) { |
347 | 347 | $tables = is_array($tables) ? $tables : array($tables => ''); |
348 | 348 | foreach ($tables as $table_name => $condition) { |
349 | - $this->db->doSelect("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : '')); |
|
349 | + $this->db->doSelect("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : '')); |
|
350 | 350 | } |
351 | 351 | } |
352 | 352 | } |