@@ -33,18 +33,18 @@ discard block |
||
33 | 33 | $fleets_added = array(); |
34 | 34 | |
35 | 35 | $query = doquery( |
36 | - "SELECT * FROM `{{fleets}}`" . |
|
37 | - (!empty($where_safe) ? " WHERE {$where_safe}" : '') . |
|
36 | + "SELECT * FROM `{{fleets}}`". |
|
37 | + (!empty($where_safe) ? " WHERE {$where_safe}" : ''). |
|
38 | 38 | " FOR UPDATE;" |
39 | 39 | ); |
40 | - while($row = db_fetch($query)) { |
|
40 | + while ($row = db_fetch($query)) { |
|
41 | 41 | /** |
42 | 42 | * @var Fleet $fleet |
43 | 43 | */ |
44 | 44 | $fleet = $this->_createElement(); |
45 | 45 | $fleet->dbRowParse($row); |
46 | 46 | |
47 | - if(isset($this[$fleet->dbId])) { |
|
47 | + if (isset($this[$fleet->dbId])) { |
|
48 | 48 | // Нужно ли ???? |
49 | 49 | classSupernova::$debug->error('Fleet list already set'); |
50 | 50 | } |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | public static function dbGetFleetListCurrentTick() { |
122 | 122 | return static::dbGetFleetList( |
123 | 123 | " |
124 | - (`fleet_start_time` <= " . SN_TIME_NOW . " AND `fleet_mess` = 0) |
|
124 | + (`fleet_start_time` <= " . SN_TIME_NOW." AND `fleet_mess` = 0) |
|
125 | 125 | OR |
126 | - (`fleet_end_stay` <= " . SN_TIME_NOW . " AND `fleet_end_stay` > 0 AND `fleet_mess` = 0) |
|
126 | + (`fleet_end_stay` <= " . SN_TIME_NOW." AND `fleet_end_stay` > 0 AND `fleet_mess` = 0) |
|
127 | 127 | OR |
128 | - (`fleet_end_time` <= " . SN_TIME_NOW . ")"); |
|
128 | + (`fleet_end_time` <= " . SN_TIME_NOW.")"); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | AND `fleet_end_planet` = {$planet_row['planet']} |
146 | 146 | AND `fleet_end_type` = {$planet_row['planet_type']} |
147 | 147 | AND `fleet_owner` = {$fleet_owner_id} |
148 | - AND `fleet_mission` IN (" . MT_ATTACK . "," . MT_ACS . "," . MT_DESTROY . ") |
|
148 | + AND `fleet_mission` IN (".MT_ATTACK.",".MT_ACS.",".MT_DESTROY.") |
|
149 | 149 | AND `fleet_mess` = 0" |
150 | 150 | ); |
151 | 151 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @return static |
171 | 171 | */ |
172 | 172 | public static function dbGetFleetListAndMissileByCoordinates($coordinates, $for_phalanx = false) { |
173 | - if(empty($coordinates) || !is_array($coordinates)) { |
|
173 | + if (empty($coordinates) || !is_array($coordinates)) { |
|
174 | 174 | return array(); |
175 | 175 | } |
176 | 176 | |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | * @var Fleet[] $array_of_Fleet |
200 | 200 | */ |
201 | 201 | $array_of_Fleet = array(); |
202 | - if(!empty($fleet_db_list) && $fleet_db_list->count()) { |
|
203 | - foreach($fleet_db_list->_container as $fleet_id => $objFleet) { |
|
202 | + if (!empty($fleet_db_list) && $fleet_db_list->count()) { |
|
203 | + foreach ($fleet_db_list->_container as $fleet_id => $objFleet) { |
|
204 | 204 | $array_of_Fleet[$fleet_id] = $objFleet; |
205 | 205 | } |
206 | 206 | $planet_fleets = flt_get_fleets_to_planet_by_array_of_Fleet($array_of_Fleet); |
@@ -225,16 +225,16 @@ discard block |
||
225 | 225 | return static::dbGetFleetList( |
226 | 226 | "( |
227 | 227 | fleet_start_galaxy = {$galaxy} |
228 | - AND fleet_start_system = {$system}" . |
|
229 | - ($planet ? " AND fleet_start_planet = {$planet}" : '') . |
|
230 | - ($planet_type != PT_ALL ? " AND fleet_start_type = {$planet_type}" : '') . |
|
231 | - ($for_phalanx ? '' : " AND fleet_mess = 1") . |
|
228 | + AND fleet_start_system = {$system}". |
|
229 | + ($planet ? " AND fleet_start_planet = {$planet}" : ''). |
|
230 | + ($planet_type != PT_ALL ? " AND fleet_start_type = {$planet_type}" : ''). |
|
231 | + ($for_phalanx ? '' : " AND fleet_mess = 1"). |
|
232 | 232 | ") OR ( |
233 | 233 | fleet_end_galaxy = {$galaxy} |
234 | - AND fleet_end_system = {$system}" . |
|
235 | - ($planet ? " AND fleet_end_planet = {$planet}" : '') . |
|
236 | - ($planet_type != PT_ALL ? " AND fleet_end_type = {$planet_type} " : '') . |
|
237 | - ($for_phalanx ? '' : " AND fleet_mess = 0") . |
|
234 | + AND fleet_end_system = {$system}". |
|
235 | + ($planet ? " AND fleet_end_planet = {$planet}" : ''). |
|
236 | + ($planet_type != PT_ALL ? " AND fleet_end_type = {$planet_type} " : ''). |
|
237 | + ($for_phalanx ? '' : " AND fleet_mess = 0"). |
|
238 | 238 | ")" |
239 | 239 | ); |
240 | 240 | } |
@@ -246,10 +246,10 @@ discard block |
||
246 | 246 | */ |
247 | 247 | public function dbMergeMissileList($where) { |
248 | 248 | $query = doquery( |
249 | - "SELECT * FROM `{{iraks}}`" . |
|
250 | - (!empty($where) ? " WHERE {$where}" : '') . |
|
249 | + "SELECT * FROM `{{iraks}}`". |
|
250 | + (!empty($where) ? " WHERE {$where}" : ''). |
|
251 | 251 | " FOR UPDATE;"); |
252 | - while($missile_db_row = db_fetch($query)) { |
|
252 | + while ($missile_db_row = db_fetch($query)) { |
|
253 | 253 | /** |
254 | 254 | * @var Fleet $objFleet |
255 | 255 | */ |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | */ |
272 | 272 | public static function dbGetFleetListAndMissileINCOMING($owner_id) { |
273 | 273 | $owner_id_safe = idval($owner_id); |
274 | - if(empty($owner_id_safe)) { |
|
274 | + if (empty($owner_id_safe)) { |
|
275 | 275 | return array(); |
276 | 276 | } |
277 | 277 | |
@@ -305,10 +305,10 @@ discard block |
||
305 | 305 | */ |
306 | 306 | public static function fleet_count_flying($player_id, $mission_id = 0) { |
307 | 307 | $player_id_safe = idval($player_id); |
308 | - if(!empty($player_id_safe)) { |
|
308 | + if (!empty($player_id_safe)) { |
|
309 | 309 | $mission_id_safe = intval($mission_id); |
310 | 310 | $result = static::db_fleet_count( |
311 | - "`fleet_owner` = {$player_id_safe}" . |
|
311 | + "`fleet_owner` = {$player_id_safe}". |
|
312 | 312 | ($mission_id_safe ? " AND `fleet_mission` = {$mission_id_safe}" : '') |
313 | 313 | ); |
314 | 314 | } else { |
@@ -2,25 +2,25 @@ discard block |
||
2 | 2 | |
3 | 3 | // ------------------------------------------------------------------------------------------------------------------------------ |
4 | 4 | function sn_sys_load_php_files($dir_name, $load_extension = 'php', $modules = false) { |
5 | - if(file_exists($dir_name)) { |
|
5 | + if (file_exists($dir_name)) { |
|
6 | 6 | $dir = opendir($dir_name); |
7 | - while(($file = readdir($dir)) !== false) { |
|
8 | - if($file == '..' || $file == '.') { |
|
7 | + while (($file = readdir($dir)) !== false) { |
|
8 | + if ($file == '..' || $file == '.') { |
|
9 | 9 | continue; |
10 | 10 | } |
11 | 11 | |
12 | - $full_filename = $dir_name . $file; |
|
13 | - if($modules && is_dir($full_filename)) { |
|
14 | - if(file_exists($full_filename = "{$full_filename}/{$file}.{$load_extension}")) { |
|
12 | + $full_filename = $dir_name.$file; |
|
13 | + if ($modules && is_dir($full_filename)) { |
|
14 | + if (file_exists($full_filename = "{$full_filename}/{$file}.{$load_extension}")) { |
|
15 | 15 | require_once($full_filename); |
16 | 16 | // Registering module |
17 | - if(class_exists($file)) { |
|
17 | + if (class_exists($file)) { |
|
18 | 18 | new $file($full_filename); |
19 | 19 | } |
20 | 20 | } |
21 | 21 | } else { |
22 | 22 | $extension = substr($full_filename, -strlen($load_extension)); |
23 | - if($extension == $load_extension) { |
|
23 | + if ($extension == $load_extension) { |
|
24 | 24 | require_once($full_filename); |
25 | 25 | } |
26 | 26 | } |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | * |
39 | 39 | */ |
40 | 40 | function init_update() { |
41 | - $update_file = SN_ROOT_PHYSICAL . "includes/update" . DOT_PHP_EX; |
|
42 | - if(file_exists($update_file)) { |
|
43 | - if(filemtime($update_file) > classSupernova::$config->db_loadItem('var_db_update') || classSupernova::$config->db_loadItem('db_version') < DB_VERSION) { |
|
44 | - if(defined('IN_ADMIN')) { |
|
41 | + $update_file = SN_ROOT_PHYSICAL."includes/update".DOT_PHP_EX; |
|
42 | + if (file_exists($update_file)) { |
|
43 | + if (filemtime($update_file) > classSupernova::$config->db_loadItem('var_db_update') || classSupernova::$config->db_loadItem('db_version') < DB_VERSION) { |
|
44 | + if (defined('IN_ADMIN')) { |
|
45 | 45 | sn_db_transaction_start(); // Для защиты от двойного запуска апдейта - начинаем транзакцию. Так запись в базе будет блокирована |
46 | - if(SN_TIME_NOW >= classSupernova::$config->db_loadItem('var_db_update_end')) { |
|
46 | + if (SN_TIME_NOW >= classSupernova::$config->db_loadItem('var_db_update_end')) { |
|
47 | 47 | classSupernova::$config->db_saveItem('var_db_update_end', SN_TIME_NOW + (classSupernova::$config->upd_lock_time ? classSupernova::$config->upd_lock_time : 300)); |
48 | 48 | sn_db_transaction_commit(); |
49 | 49 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $current_time = time(); |
54 | 54 | classSupernova::$config->db_saveItem('var_db_update', $current_time); |
55 | 55 | classSupernova::$config->db_saveItem('var_db_update_end', $current_time); |
56 | - } elseif(filemtime($update_file) > classSupernova::$config->var_db_update) { |
|
56 | + } elseif (filemtime($update_file) > classSupernova::$config->var_db_update) { |
|
57 | 57 | $timeout = classSupernova::$config->var_db_update_end - SN_TIME_NOW; |
58 | 58 | die( |
59 | 59 | "Обновляется база данных. Рассчетное время окончания - {$timeout} секунд (время обновления может увеличиваться). Пожалуйста, подождите...<br /> |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | function db_change_units_perform($query, $tablename, $object_id) { |
13 | 13 | $query = implode(',', $query); |
14 | - if($query && $object_id) { |
|
14 | + if ($query && $object_id) { |
|
15 | 15 | return classSupernova::db_upd_record_by_id($tablename == 'users' ? LOC_USER : LOC_PLANET, $object_id, $query); |
16 | 16 | // return doquery("UPDATE {{{$tablename}}} SET {$query} WHERE `id` = '{$object_id}' LIMIT 1;"); |
17 | 17 | } |
@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | |
29 | 29 | $group = sn_get_groups('resources_loot'); |
30 | 30 | |
31 | - foreach($unit_list as $unit_id => $unit_amount) { |
|
32 | - if(!in_array($unit_id, $group)) { |
|
31 | + foreach ($unit_list as $unit_id => $unit_amount) { |
|
32 | + if (!in_array($unit_id, $group)) { |
|
33 | 33 | // TODO - remove later |
34 | 34 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: db_change_units() вызван для не-ресурсов!</h1>'); |
35 | 35 | pdump(debug_backtrace()); |
36 | 36 | die('db_change_units() вызван для не-ресурсов!'); |
37 | 37 | } |
38 | 38 | |
39 | - if(!$unit_amount) { |
|
39 | + if (!$unit_amount) { |
|
40 | 40 | continue; |
41 | 41 | } |
42 | 42 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $unit_location = sys_get_unit_location($user, $planet, $unit_id); |
46 | 46 | |
47 | 47 | // Changing value in object |
48 | - switch($unit_location) { |
|
48 | + switch ($unit_location) { |
|
49 | 49 | case LOC_USER: |
50 | 50 | $user[$unit_db_name] += $unit_amount; |
51 | 51 | break; |
@@ -67,30 +67,30 @@ discard block |
||
67 | 67 | $field_set = ''; |
68 | 68 | $value_set = ''; |
69 | 69 | |
70 | - switch($type) { |
|
70 | + switch ($type) { |
|
71 | 71 | case 'delete': |
72 | 72 | $query = 'DELETE FROM'; |
73 | 73 | break; |
74 | 74 | |
75 | 75 | case 'insert': |
76 | 76 | $query = 'INSERT INTO'; |
77 | - if(isset($options['__multi'])) { |
|
77 | + if (isset($options['__multi'])) { |
|
78 | 78 | // Here we generate mass-insert set |
79 | 79 | break; |
80 | 80 | } |
81 | 81 | case 'update': |
82 | - if(!$query) { |
|
82 | + if (!$query) { |
|
83 | 83 | $query = 'UPDATE'; |
84 | 84 | } |
85 | 85 | |
86 | - foreach($values as $field => &$value) { |
|
86 | + foreach ($values as $field => &$value) { |
|
87 | 87 | $value_type = gettype($value); |
88 | 88 | if ($value_type == 'string') { |
89 | - $value = "'" . db_escape($value) . "'"; |
|
89 | + $value = "'".db_escape($value)."'"; |
|
90 | 90 | } |
91 | 91 | $value = "`{$field}` = {$value}"; |
92 | 92 | } |
93 | - $field_set = 'SET ' . implode(', ', $values); |
|
93 | + $field_set = 'SET '.implode(', ', $values); |
|
94 | 94 | break; |
95 | 95 | |
96 | 96 | }; |
@@ -111,12 +111,12 @@ discard block |
||
111 | 111 | $field_set['__IS_SAFE'] = true; |
112 | 112 | } |
113 | 113 | function sn_db_field_set_make_safe($field_set, $serialize = false) { |
114 | - if(!is_array($field_set)) { |
|
114 | + if (!is_array($field_set)) { |
|
115 | 115 | die('$field_set is not an array!'); |
116 | 116 | } |
117 | 117 | |
118 | 118 | $result = array(); |
119 | - foreach($field_set as $field => $value) { |
|
119 | + foreach ($field_set as $field => $value) { |
|
120 | 120 | $field = db_escape(trim($field)); |
121 | 121 | switch (true) { |
122 | 122 | case is_int($value): |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $serialize ? $value = serialize($value) : die('$value is object or array with no $serialize'); |
133 | 133 | |
134 | 134 | case is_string($value): |
135 | - $value = '"' . db_escape($value) . '"'; |
|
135 | + $value = '"'.db_escape($value).'"'; |
|
136 | 136 | break; |
137 | 137 | |
138 | 138 | case is_null($value): |
@@ -9,6 +9,9 @@ discard block |
||
9 | 9 | |
10 | 10 | require_once('db/db_queries.php'); |
11 | 11 | |
12 | +/** |
|
13 | + * @param string $tablename |
|
14 | + */ |
|
12 | 15 | function db_change_units_perform($query, $tablename, $object_id) { |
13 | 16 | $query = implode(',', $query); |
14 | 17 | if($query && $object_id) { |
@@ -60,6 +63,9 @@ discard block |
||
60 | 63 | db_change_units_perform($query[LOC_USER], 'users', $user['id']); |
61 | 64 | db_change_units_perform($query[LOC_PLANET], 'planets', $planet['id']); |
62 | 65 | } |
66 | +/** |
|
67 | + * @param string $table |
|
68 | + */ |
|
63 | 69 | function sn_db_perform($table, $values, $type = 'insert', $options = false) { |
64 | 70 | $field_set = ''; |
65 | 71 | |
@@ -153,6 +159,9 @@ discard block |
||
153 | 159 | |
154 | 160 | |
155 | 161 | |
162 | +/** |
|
163 | + * @param boolean $transaction_should_be_started |
|
164 | + */ |
|
156 | 165 | function sn_db_transaction_check($transaction_should_be_started = null) { |
157 | 166 | return classSupernova::$gc->db->getTransaction()->check($transaction_should_be_started); |
158 | 167 | } |
@@ -1,37 +1,37 @@ 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 | classSupernova::$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(classLocale::$lang['Owner_cant_go_out'], classLocale::$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(); |
18 | 18 | sn_db_transaction_commit(); |
19 | 19 | message(sprintf(classLocale::$lang['ali_info_leave_success'], $ally['ally_name']), classLocale::$lang['sys_alliance']); |
20 | 20 | } |
21 | -} elseif($mode == 'ainfo') { |
|
21 | +} elseif ($mode == 'ainfo') { |
|
22 | 22 | $tag = sys_get_param_str('tag'); |
23 | 23 | $id_ally = sys_get_param_id('a'); |
24 | - if($tag) { |
|
24 | + if ($tag) { |
|
25 | 25 | $ally = db_ally_get_by_tag($tag); |
26 | - } elseif($id_ally) { |
|
26 | + } elseif ($id_ally) { |
|
27 | 27 | $ally = db_ally_get_by_id($id_ally); |
28 | 28 | } |
29 | 29 | |
30 | - if(!$ally) { |
|
30 | + if (!$ally) { |
|
31 | 31 | message(classLocale::$lang['ali_sys_notFound'], classLocale::$lang['Ally_info_1']); |
32 | 32 | } |
33 | 33 | |
34 | - if(!$ally['ally_description']) { |
|
34 | + if (!$ally['ally_description']) { |
|
35 | 35 | $ally['ally_description'] = classLocale::$lang['Ally_nodescription']; |
36 | 36 | } |
37 | 37 | |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | } else { |
44 | 44 | $page_header = classLocale::$lang['your_alliance']; |
45 | 45 | |
46 | - if($ally['ally_owner'] == $user['id']) { |
|
46 | + if ($ally['ally_owner'] == $user['id']) { |
|
47 | 47 | $range = $ally['ally_owner_range'] ? $ally['ally_owner_range'] : classLocale::$lang['Founder']; |
48 | - } elseif($user['ally_rank_id'] != 0 && isset($ranks[$user['ally_rank_id']]['name'])) { |
|
48 | + } elseif ($user['ally_rank_id'] != 0 && isset($ranks[$user['ally_rank_id']]['name'])) { |
|
49 | 49 | $range = $ranks[$user['ally_rank_id']]['name']; |
50 | 50 | } else { |
51 | 51 | $range = classLocale::$lang['member']; |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | )); |
87 | 87 | |
88 | 88 | $relations = ali_relations($ally['id']); |
89 | -foreach($relations as $relation) { |
|
90 | - if($relation['alliance_diplomacy_contr_ally_id'] && $relation['alliance_diplomacy_ally_id']) { |
|
89 | +foreach ($relations as $relation) { |
|
90 | + if ($relation['alliance_diplomacy_contr_ally_id'] && $relation['alliance_diplomacy_ally_id']) { |
|
91 | 91 | $template->assign_block_vars('relation', array( |
92 | 92 | 'NAME' => $relation['alliance_diplomacy_contr_ally_name'], |
93 | 93 | 'RELATION' => classLocale::$lang['ali_dip_relations'][$relation['alliance_diplomacy_relation']], |
@@ -106,4 +106,4 @@ discard block |
||
106 | 106 | |
107 | 107 | ali_render(); |
108 | 108 | |
109 | -display($template, classLocale::$lang['your_alliance'] . ' [' . $ally['ally_name'] . ']'); |
|
109 | +display($template, classLocale::$lang['your_alliance'].' ['.$ally['ally_name'].']'); |
@@ -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 | classSupernova::$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(classLocale::$lang['Denied_access'], classLocale::$lang['ally_admin']); |
9 | 9 | } |
10 | 10 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | $allyTextID = ($allyTextID < 1 || $allyTextID > 3) ? 1 : $allyTextID; |
21 | 21 | |
22 | 22 | |
23 | -if(sys_get_param_str('isSaveOptions')) { |
|
23 | +if (sys_get_param_str('isSaveOptions')) { |
|
24 | 24 | require_once('includes/includes/sys_avatar.php'); |
25 | 25 | |
26 | 26 | $new_image = $ally['ally_image']; |
@@ -32,46 +32,46 @@ discard block |
||
32 | 32 | // $template->assign_block_vars('result', $avatar_upload_result); |
33 | 33 | |
34 | 34 | $ally_changeset = array(); |
35 | - if(($new_tag = sys_get_param_str_unsafe('tag', $ally['ally_tag'])) && $new_tag != $ally['ally_tag']) { |
|
35 | + if (($new_tag = sys_get_param_str_unsafe('tag', $ally['ally_tag'])) && $new_tag != $ally['ally_tag']) { |
|
36 | 36 | $new_tag = db_escape($new_tag); |
37 | 37 | $ally_changeset[] = "`ally_tag`='{$new_tag}'"; |
38 | 38 | db_user_set_by_id($ally['ally_user_id'], "`username`='[{$new_tag}]'"); |
39 | 39 | } |
40 | - if(($new_name = sys_get_param_str_unsafe('name', $ally['ally_name'])) && $new_name != $ally['ally_name']) { |
|
40 | + if (($new_name = sys_get_param_str_unsafe('name', $ally['ally_name'])) && $new_name != $ally['ally_name']) { |
|
41 | 41 | $new_name = db_escape($new_name); |
42 | 42 | $ally_changeset[] = "`ally_name`='{$new_name}'"; |
43 | 43 | } |
44 | 44 | |
45 | - if(($new_owner_rank = sys_get_param_str_unsafe('owner_range', $ally['ally_owner_range'])) && $new_owner_rank != $ally['ally_owner_range']) { |
|
45 | + if (($new_owner_rank = sys_get_param_str_unsafe('owner_range', $ally['ally_owner_range'])) && $new_owner_rank != $ally['ally_owner_range']) { |
|
46 | 46 | $new_owner_rank = db_escape($new_owner_rank); |
47 | 47 | $ally_changeset[] = "`ally_owner_range` = '{$new_owner_rank}'"; |
48 | 48 | } |
49 | - if(($new_web = sys_get_param_str_unsafe('web', $ally['ally_web'])) && $new_web != $ally['ally_web']) { |
|
49 | + if (($new_web = sys_get_param_str_unsafe('web', $ally['ally_web'])) && $new_web != $ally['ally_web']) { |
|
50 | 50 | $new_web = db_escape($new_web); |
51 | 51 | $ally_changeset[] = "`ally_web` = '{$new_web}'"; |
52 | 52 | } |
53 | 53 | $new_request = sys_get_param_int('request_notallow', $ally['ally_request_notallow']); |
54 | 54 | $ally_changeset[] = "`ally_request_notallow` = '{$new_request}'"; |
55 | - if($new_image != $ally['ally_image']) { |
|
55 | + if ($new_image != $ally['ally_image']) { |
|
56 | 56 | $new_image = intval($new_image); |
57 | 57 | $ally_changeset[] = "`ally_image` = '{$new_image}'"; |
58 | 58 | } |
59 | 59 | |
60 | - if(!empty($ally_changeset)) { |
|
60 | + if (!empty($ally_changeset)) { |
|
61 | 61 | db_ally_update_by_changeset($ally_changeset, $ally); |
62 | 62 | sys_redirect('alliance.php?mode=admin&edit=ally'); |
63 | 63 | } |
64 | -} elseif(sys_get_param_str('isSaveText')) { |
|
64 | +} elseif (sys_get_param_str('isSaveText')) { |
|
65 | 65 | $text = sys_get_param_str_both('text'); |
66 | 66 | db_ally_update_texts($text_list, $allyTextID, $text, $ally); |
67 | 67 | $ally[$text_list[$allyTextID]['db_field']] = $text['unsafe']; |
68 | -} elseif(sys_get_param_str('isTransfer') && $idNewLeader = sys_get_param_id('idNewLeader')) { |
|
69 | - if(!$isAllyOwner) { |
|
68 | +} elseif (sys_get_param_str('isTransfer') && $idNewLeader = sys_get_param_id('idNewLeader')) { |
|
69 | + if (!$isAllyOwner) { |
|
70 | 70 | message(classLocale::$lang['Denied_access'], classLocale::$lang['ally_admin']); |
71 | 71 | } |
72 | 72 | |
73 | 73 | $newLeader = db_user_by_id($idNewLeader, false, `ally_id`); |
74 | - if($newLeader['ally_id'] == $user['ally_id']) { |
|
74 | + if ($newLeader['ally_id'] == $user['ally_id']) { |
|
75 | 75 | sn_db_transaction_start(); |
76 | 76 | db_user_set_by_id($user['id'], "`ally_rank_id`='0'"); |
77 | 77 | db_ally_update_owner($idNewLeader, $user); |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | sn_db_transaction_commit(); |
80 | 80 | sys_redirect('alliance.php'); |
81 | 81 | } |
82 | -} elseif(sys_get_param_str('isDisband') && sys_get_param_str('isConfirmDisband')) { |
|
83 | - if(!$isAllyOwner) { |
|
82 | +} elseif (sys_get_param_str('isDisband') && sys_get_param_str('isConfirmDisband')) { |
|
83 | + if (!$isAllyOwner) { |
|
84 | 84 | message(classLocale::$lang['Denied_access'], classLocale::$lang['ally_admin']); |
85 | 85 | } |
86 | 86 | sn_db_transaction_start(); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $request = db_ally_request_count_by_id($ally); |
94 | 94 | |
95 | 95 | $template->assign_vars(array( |
96 | - 'request_count' => $request['request_count'] ? classLocale::$lang['ali_req_requestCount'] . ': ' . intval($request['request_count']) . '. ' . classLocale::$lang['ali_req_check'] : classLocale::$lang['ali_req_emptyList'], |
|
96 | + 'request_count' => $request['request_count'] ? classLocale::$lang['ali_req_requestCount'].': '.intval($request['request_count']).'. '.classLocale::$lang['ali_req_check'] : classLocale::$lang['ali_req_emptyList'], |
|
97 | 97 | 'text' => $ally[$text_list[$allyTextID]['db_field']], |
98 | 98 | 'request_type' => classLocale::$lang[$text_list[$allyTextID]['text_type']], |
99 | 99 | 't' => $allyTextID, |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $userAllyAdmins = db_user_list("`ally_id`= {$ally['id']}", false, '`id`, `username`'); |
127 | 127 | unset($tmp); |
128 | 128 | // while ($userAllyAdmin = db_fetch($userAllyAdmins)) |
129 | - foreach($userAllyAdmins as $userAllyAdmin) { |
|
129 | + foreach ($userAllyAdmins as $userAllyAdmin) { |
|
130 | 130 | // pdump($userAllyAdmin); |
131 | 131 | $tmp .= "<option value={$userAllyAdmin['id']}>{$userAllyAdmin['username']}</option>"; |
132 | 132 | } |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | $template->assign_var('adminMembers', $tmp); |
135 | 135 | } |
136 | 136 | |
137 | -foreach($sn_ali_admin_internal as $sn_ali_admin_action => $sn_ali_admin_action_locale) { |
|
138 | - if(!$sn_ali_admin_action_locale['title']) { |
|
137 | +foreach ($sn_ali_admin_internal as $sn_ali_admin_action => $sn_ali_admin_action_locale) { |
|
138 | + if (!$sn_ali_admin_action_locale['title']) { |
|
139 | 139 | continue; |
140 | 140 | } |
141 | 141 | $template->assign_block_vars('admin_actions', array( |
@@ -1,6 +1,6 @@ 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 | { |
5 | 5 | classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
6 | 6 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | $new_rank_name = sys_get_param_str('newRankName'); |
15 | 15 | if ($new_rank_name) |
16 | 16 | { |
17 | - foreach($ally_rights as $fieldName) |
|
17 | + foreach ($ally_rights as $fieldName) |
|
18 | 18 | { |
19 | 19 | $newRank[$fieldName] = 0; |
20 | 20 | } |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | { |
29 | 29 | unset($ranks); |
30 | 30 | |
31 | - foreach($rankListInput as $rankID => $rank) |
|
31 | + foreach ($rankListInput as $rankID => $rank) |
|
32 | 32 | { |
33 | - foreach($ally_rights as $rightName) |
|
33 | + foreach ($ally_rights as $rightName) |
|
34 | 34 | { |
35 | 35 | $ranks[$rankID][$rightName] = $rank[$rightName] ? 1 : 0; |
36 | 36 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $d = sys_get_param_int('d'); |
42 | 42 | if ($d && isset($ranks[$d])) |
43 | 43 | { |
44 | - if(count($ranks) == 1) |
|
44 | + if (count($ranks) == 1) |
|
45 | 45 | { |
46 | 46 | message(classLocale::$lang['ali_adm_lastRank'], classLocale::$lang['ali_adm_rights_title']); |
47 | 47 | } |
@@ -53,17 +53,17 @@ discard block |
||
53 | 53 | |
54 | 54 | if (count($ranks)) |
55 | 55 | { |
56 | - foreach($ranks as $rankID => $rank) |
|
56 | + foreach ($ranks as $rankID => $rank) |
|
57 | 57 | { |
58 | 58 | $rank_data = array( |
59 | 59 | 'ID' => $rankID, |
60 | 60 | 'NAME' => $rank['name'], |
61 | 61 | ); |
62 | 62 | |
63 | - for($i = 1; $i < count($rank); $i++) |
|
63 | + for ($i = 1; $i < count($rank); $i++) |
|
64 | 64 | { |
65 | - $rank_data['R' . $i] = (($rank[$ally_rights[$i]] == 1) ? ' checked' : '') ; |
|
66 | - $rank_data['N' . $i] = $ally_rights[$i]; |
|
65 | + $rank_data['R'.$i] = (($rank[$ally_rights[$i]] == 1) ? ' checked' : ''); |
|
66 | + $rank_data['N'.$i] = $ally_rights[$i]; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | $template->assign_block_vars('rank', $rank_data); |
@@ -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 | - $field = '`' . db_escape($field) . '`'; |
|
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 | - $new_value = '"' . db_escape($value) . '"'; |
|
42 | - } elseif($delta) { |
|
41 | + $new_value = '"'.db_escape($value).'"'; |
|
42 | + } elseif ($delta) { |
|
43 | 43 | // float and DELTA-set |
44 | 44 | $new_value = "{$field} + ({$new_value})"; |
45 | 45 | } |
@@ -2,19 +2,19 @@ discard block |
||
2 | 2 | |
3 | 3 | $classLocale = classLocale::$lang; |
4 | 4 | |
5 | -if(classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) { |
|
6 | - include(SN_ROOT_PHYSICAL . 'ajax_version_check' . DOT_PHP_EX); |
|
5 | +if (classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) { |
|
6 | + include(SN_ROOT_PHYSICAL.'ajax_version_check'.DOT_PHP_EX); |
|
7 | 7 | } |
8 | 8 | |
9 | -if(classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) { |
|
10 | - require_once(SN_ROOT_PHYSICAL . "includes/includes/user_birthday_celebrate" . DOT_PHP_EX); |
|
9 | +if (classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) { |
|
10 | + require_once(SN_ROOT_PHYSICAL."includes/includes/user_birthday_celebrate".DOT_PHP_EX); |
|
11 | 11 | sn_user_birthday_celebrate(); |
12 | 12 | } |
13 | 13 | |
14 | -if(!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) { |
|
14 | +if (!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) { |
|
15 | 15 | classSupernova::$config->db_saveItem('var_online_user_count', db_user_count(true)); |
16 | 16 | classSupernova::$config->db_saveItem('var_online_user_time', SN_TIME_NOW); |
17 | - if(classSupernova::$config->server_log_online) { |
|
17 | + if (classSupernova::$config->server_log_online) { |
|
18 | 18 | db_log_online_insert(); |
19 | 19 | } |
20 | 20 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $template_result[F_ACCOUNT_IS_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id']; |
42 | 42 | //pdump($template_result[F_ACCOUNT_IS_AUTHORIZED]);die(); |
43 | 43 | |
44 | -if(!empty($user['id'])) { |
|
44 | +if (!empty($user['id'])) { |
|
45 | 45 | classSupernova::$user_options->user_change($user['id']); |
46 | 46 | } |
47 | 47 | |
@@ -54,15 +54,15 @@ discard block |
||
54 | 54 | : false |
55 | 55 | ); |
56 | 56 | |
57 | -if($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
58 | - $prohibited_characters = array_map(function ($value) { |
|
59 | - return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
|
57 | +if ($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
58 | + $prohibited_characters = array_map(function($value) { |
|
59 | + return "'".htmlentities($value, ENT_QUOTES, 'UTF-8')."'"; |
|
60 | 60 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
61 | 61 | $template_result[F_LOGIN_MESSAGE] .= implode(', ', $prohibited_characters); |
62 | 62 | } |
63 | 63 | |
64 | 64 | |
65 | -if(defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) { |
|
65 | +if (defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) { |
|
66 | 66 | pdump("Отключи отладку перед продакшном!"); |
67 | 67 | } |
68 | 68 | |
@@ -76,17 +76,17 @@ discard block |
||
76 | 76 | ? define('INSTALL_MODE', GAME_DISABLE_INSTALL) |
77 | 77 | : false; |
78 | 78 | |
79 | -if($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) { |
|
79 | +if ($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) { |
|
80 | 80 | $template_result[F_GAME_DISABLE_REASON] = sys_bbcodeParse( |
81 | 81 | classSupernova::$config->game_disable == GAME_DISABLE_REASON |
82 | 82 | ? classSupernova::$config->game_disable_reason |
83 | 83 | : classLocale::$lang['sys_game_disable_reason'][classSupernova::$config->game_disable] |
84 | 84 | ); |
85 | - if(defined('IN_API')) { |
|
85 | + if (defined('IN_API')) { |
|
86 | 86 | return; |
87 | 87 | } |
88 | 88 | |
89 | - if( |
|
89 | + if ( |
|
90 | 90 | ($user['authlevel'] < 1 || !(defined('IN_ADMIN') && IN_ADMIN)) |
91 | 91 | && |
92 | 92 | !(defined('INSTALL_MODE') && defined('LOGIN_LOGOUT')) |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | |
101 | 101 | // TODO ban |
102 | 102 | // TODO $skip_ban_check |
103 | -if($template_result[F_BANNED_STATUS] && !$skip_ban_check) { |
|
104 | - if(defined('IN_API')) { |
|
103 | +if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) { |
|
104 | + if (defined('IN_API')) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
@@ -119,15 +119,15 @@ discard block |
||
119 | 119 | // pdump($allow_anonymous, '$allow_anonymous'); |
120 | 120 | // pdump($sys_user_logged_in, '$sys_user_logged_in'); |
121 | 121 | |
122 | -if($sys_user_logged_in && INITIAL_PAGE == 'login') { |
|
123 | - sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
|
124 | -} elseif($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id']) |
|
122 | +if ($sys_user_logged_in && INITIAL_PAGE == 'login') { |
|
123 | + sys_redirect(SN_ROOT_VIRTUAL.'overview.php'); |
|
124 | +} elseif ($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id']) |
|
125 | 125 | // pdump($sn_page_name); |
126 | 126 | // pdump(INITIAL_PAGE); |
127 | 127 | // die('{Тут должна быть ваша реклама. Точнее - ввод имени игрока}'); |
128 | -} elseif(!$allow_anonymous && !$sys_user_logged_in) { |
|
128 | +} elseif (!$allow_anonymous && !$sys_user_logged_in) { |
|
129 | 129 | // sn_setcookie(SN_COOKIE, '', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
130 | - sys_redirect(SN_ROOT_VIRTUAL . 'login.php'); |
|
130 | + sys_redirect(SN_ROOT_VIRTUAL.'login.php'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | $user_time_diff = playerTimeDiff::user_time_diff_get(); |
@@ -146,16 +146,16 @@ discard block |
||
146 | 146 | |
147 | 147 | global $skip_fleet_update; |
148 | 148 | $skip_fleet_update = $skip_fleet_update || $supernova->options['fleet_update_skip'] || defined('IN_ADMIN'); |
149 | -if( |
|
149 | +if ( |
|
150 | 150 | !$skip_fleet_update |
151 | 151 | && !(defined('IN_AJAX') && IN_AJAX === true) |
152 | 152 | && SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_last) > classSupernova::$config->fleet_update_interval |
153 | 153 | ) { |
154 | - require_once(SN_ROOT_PHYSICAL . "includes/includes/flt_flying_fleet_handler2" . DOT_PHP_EX); |
|
154 | + require_once(SN_ROOT_PHYSICAL."includes/includes/flt_flying_fleet_handler2".DOT_PHP_EX); |
|
155 | 155 | flt_flying_fleet_handler($skip_fleet_update); |
156 | 156 | } |
157 | 157 | |
158 | -if(!defined('IN_AJAX')) { |
|
158 | +if (!defined('IN_AJAX')) { |
|
159 | 159 | print("Scheduled processes is disabled<br />"); |
160 | 160 | } |
161 | 161 | // scheduler_process(); |
@@ -4,7 +4,7 @@ |
||
4 | 4 | |
5 | 5 | function pname_factory_production_field_name($factory_unit_id) |
6 | 6 | { |
7 | - return get_unit_param($factory_unit_id, P_NAME) . '_porcent'; |
|
7 | + return get_unit_param($factory_unit_id, P_NAME).'_porcent'; |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | /** |