@@ -18,7 +18,7 @@ |
||
18 | 18 | $query = db_user_list("`authlevel` > 0 ORDER BY `authlevel` ASC"); |
19 | 19 | |
20 | 20 | // while($row = db_fetch($query)) |
21 | - foreach($query as $row) |
|
21 | + foreach ($query as $row) |
|
22 | 22 | { |
23 | 23 | $template_result['.']['contact'][] = array( |
24 | 24 | 'NAME' => $row['username'], |
@@ -9,8 +9,7 @@ |
||
9 | 9 | //$sn_mvc['model']['chat'][] = 'sn_chat_model'; |
10 | 10 | $sn_mvc['view']['contact'][] = 'sn_contact_view'; |
11 | 11 | |
12 | -function sn_contact_view($template = null) |
|
13 | -{ |
|
12 | +function sn_contact_view($template = null) { |
|
14 | 13 | global $template_result, $lang; |
15 | 14 | |
16 | 15 | $template = gettemplate('contact', $template); |
@@ -399,7 +399,9 @@ discard block |
||
399 | 399 | $units_levels = array(); |
400 | 400 | foreach($planet_unit_list as $unit_id) { |
401 | 401 | $unit_name = &$units_info[$unit_id][P_NAME]; |
402 | - if(!isset($row[$unit_name]) || !$row[$unit_name]) continue; |
|
402 | + if(!isset($row[$unit_name]) || !$row[$unit_name]) { |
|
403 | + continue; |
|
404 | + } |
|
403 | 405 | $units_levels[$unit_id] = $row[$unit_name]; |
404 | 406 | $unit_data[] = "({$user_id}," . LOC_PLANET . ",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})"; |
405 | 407 | if(count($unit_data) > 30) { |
@@ -413,7 +415,9 @@ discard block |
||
413 | 415 | if($row['que']) { |
414 | 416 | $que = explode(';', $row['que']); |
415 | 417 | foreach($que as $que_item) { |
416 | - if(!$que_item) continue; |
|
418 | + if(!$que_item) { |
|
419 | + continue; |
|
420 | + } |
|
417 | 421 | |
418 | 422 | $que_item = explode(',', $que_item); |
419 | 423 | |
@@ -445,9 +449,13 @@ discard block |
||
445 | 449 | $return_resources = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0, ); |
446 | 450 | $hangar_units = sys_unit_str2arr($row['b_hangar_id']); |
447 | 451 | foreach($hangar_units as $unit_id => $unit_count) { |
448 | - if($unit_count <= 0) continue; |
|
452 | + if($unit_count <= 0) { |
|
453 | + continue; |
|
454 | + } |
|
449 | 455 | foreach($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) { |
450 | - if(!in_array($resource_id, $group_resource_loot)) continue; |
|
456 | + if(!in_array($resource_id, $group_resource_loot)) { |
|
457 | + continue; |
|
458 | + } |
|
451 | 459 | $return_resources[$resource_id] += $unit_count * $resource_amount; |
452 | 460 | } |
453 | 461 | } |
@@ -464,11 +472,13 @@ discard block |
||
464 | 472 | } |
465 | 473 | } |
466 | 474 | |
467 | - if(!empty($unit_data)) |
|
468 | - upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';'); |
|
475 | + if(!empty($unit_data)) { |
|
476 | + upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';'); |
|
477 | + } |
|
469 | 478 | |
470 | - if(!empty($que_data)) |
|
471 | - upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES ' . implode(',', $que_data) . ';'); |
|
479 | + if(!empty($que_data)) { |
|
480 | + upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES ' . implode(',', $que_data) . ';'); |
|
481 | + } |
|
472 | 482 | |
473 | 483 | upd_alter_table('planets', $drop, true); |
474 | 484 | } |
@@ -761,9 +771,11 @@ discard block |
||
761 | 771 | !empty($strings) ? doquery($query_string . implode(',', $strings)) : false; |
762 | 772 | } |
763 | 773 | |
764 | - if(isset($update_tables['counter']['page'])) // TODO REMOVE |
|
774 | + if(isset($update_tables['counter']['page'])) { |
|
775 | + // TODO REMOVE |
|
765 | 776 | { |
766 | 777 | update_security_url("SELECT DISTINCT `page` as url FROM {{counter}}"); |
778 | + } |
|
767 | 779 | update_security_url("SELECT DISTINCT `url` as url FROM {{counter}}"); |
768 | 780 | } |
769 | 781 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | [!] DB code updates |
22 | 22 | */ |
23 | 23 | |
24 | -if(!defined('INIT')) { |
|
24 | +if (!defined('INIT')) { |
|
25 | 25 | // include_once('init.php'); |
26 | 26 | die('Unauthorized access'); |
27 | 27 | } |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | |
41 | 41 | |
42 | 42 | //$config->db_loadItem('db_version'); |
43 | -if($config->db_version == DB_VERSION) { |
|
44 | -} elseif($config->db_version > DB_VERSION) { |
|
43 | +if ($config->db_version == DB_VERSION) { |
|
44 | +} elseif ($config->db_version > DB_VERSION) { |
|
45 | 45 | $config->db_saveItem('var_db_update_end', SN_TIME_NOW); |
46 | 46 | die( |
47 | 47 | 'Internal error! Auotupdater detects DB version greater then can be handled!<br /> |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | $upd_log = ''; |
54 | 54 | $new_version = floatval($config->db_version); |
55 | -if($new_version < 37) { |
|
55 | +if ($new_version < 37) { |
|
56 | 56 | die('This version does not supports upgrades from SN below v37. Please, use SN v40 to upgrade old database.<br /> |
57 | 57 | Эта версия игры не поддерживает обновление движка версий ниже 37й. Пожалуйста, используйте SN v40 для апгрейда со старых версий игры.'); |
58 | 58 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $update_tables = array(); |
71 | 71 | $update_indexes = array(); |
72 | 72 | $query = upd_do_query('SHOW TABLES;', true); |
73 | -while($row = db_fetch_row($query)) { |
|
73 | +while ($row = db_fetch_row($query)) { |
|
74 | 74 | upd_load_table_info($row[0]); |
75 | 75 | } |
76 | 76 | upd_log_message('Table info loaded. Now looking DB for upgrades...'); |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | |
81 | 81 | ini_set('memory_limit', '1024M'); |
82 | 82 | |
83 | -switch($new_version) { |
|
83 | +switch ($new_version) { |
|
84 | 84 | case 37: |
85 | 85 | upd_log_version_update(); |
86 | 86 | |
87 | 87 | upd_check_key('player_vacation_timeout', PERIOD_WEEK, $config->player_vacation_timeout != PERIOD_WEEK); |
88 | - upd_check_key('player_vacation_time', PERIOD_WEEK , $config->player_vacation_time != PERIOD_WEEK); |
|
88 | + upd_check_key('player_vacation_time', PERIOD_WEEK, $config->player_vacation_time != PERIOD_WEEK); |
|
89 | 89 | |
90 | 90 | upd_alter_table('users', "ADD `vacation_next` INT(11) NOT NULL DEFAULT 0 COMMENT 'Next datetime when player can go on vacation'", !$update_tables['users']['vacation_next']); |
91 | 91 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | upd_check_key('payment_currency_exchange_mm_', 2500, !$config->payment_currency_exchange_mm_); |
97 | 97 | |
98 | - if(!$update_tables['log_metamatter']) |
|
98 | + if (!$update_tables['log_metamatter']) |
|
99 | 99 | { |
100 | 100 | upd_create_table('log_metamatter', |
101 | 101 | "( |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | "ADD `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'", |
122 | 122 | ), !$update_tables['payment']['payment_test']); |
123 | 123 | |
124 | - if($update_tables['payment']['payment_test']['Default'] == 1) |
|
124 | + if ($update_tables['payment']['payment_test']['Default'] == 1) |
|
125 | 125 | { |
126 | 126 | upd_alter_table('payment', array( |
127 | 127 | "MODIFY COLUMN `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'", |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | ), $update_tables['users']['metamatter']['Type'] == 'int(20)'); |
140 | 140 | |
141 | 141 | $query = upd_do_query("SELECT * FROM {{que}} WHERE `que_type` = " . QUE_RESEARCH . " AND que_unit_id in (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") FOR UPDATE"); |
142 | - while($row = db_fetch($query)) |
|
142 | + while ($row = db_fetch($query)) |
|
143 | 143 | { |
144 | 144 | $planet_id = ($row['que_planet_id_origin'] ? $row['que_planet_id_origin'] : $row['que_planet_id']); |
145 | 145 | upd_do_query("SELECT id FROM {{planets}} WHERE id = {$planet_id} FOR UPDATE"); |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | LEFT JOIN {{planets}} AS p ON p.id = u.id_planet |
159 | 159 | WHERE unit_snid in (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") |
160 | 160 | FOR UPDATE"); |
161 | - while($row = db_fetch($query)) |
|
161 | + while ($row = db_fetch($query)) |
|
162 | 162 | { |
163 | - if(!$row['id_planet']) |
|
163 | + if (!$row['id_planet']) |
|
164 | 164 | { |
165 | 165 | continue; |
166 | 166 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | $unit_level = $row['unit_level']; |
170 | 170 | $price = get_unit_param($unit_id, P_COST); |
171 | 171 | $factor = $price['factor']; |
172 | - foreach($price as $resource_id => &$resource_amount) |
|
172 | + foreach ($price as $resource_id => &$resource_amount) |
|
173 | 173 | { |
174 | 174 | $resource_amount = $resource_amount * (pow($factor, $unit_level) - 1) / ($factor - 1); |
175 | 175 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | // Вернуть ресы за уже исследованную Экспедиционную технологию |
190 | 190 | upd_check_key('player_max_colonies', -1, $config->player_max_colonies >= 0); |
191 | 191 | |
192 | - if(!isset($update_tables['users']['player_rpg_explore_xp'])) |
|
192 | + if (!isset($update_tables['users']['player_rpg_explore_xp'])) |
|
193 | 193 | { |
194 | 194 | upd_alter_table('users', array( |
195 | 195 | "ADD COLUMN `player_rpg_explore_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
@@ -197,9 +197,9 @@ discard block |
||
197 | 197 | ), !isset($update_tables['users']['player_rpg_explore_xp'])); |
198 | 198 | } |
199 | 199 | |
200 | - if(!$update_tables['log_users_online']) |
|
200 | + if (!$update_tables['log_users_online']) |
|
201 | 201 | { |
202 | - upd_create_table('log_users_online',"( |
|
202 | + upd_create_table('log_users_online', "( |
|
203 | 203 | `online_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Measure time', |
204 | 204 | `online_count` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Users online', |
205 | 205 | |
@@ -213,12 +213,12 @@ discard block |
||
213 | 213 | "ADD `user_time_measured` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'When was time diff measured last time' AFTER `onlinetime`", |
214 | 214 | ), !$update_tables['users']['user_time_measured']); |
215 | 215 | |
216 | - if($update_tables['rw']) |
|
216 | + if ($update_tables['rw']) |
|
217 | 217 | { |
218 | 218 | upd_do_query("DROP TABLE IF EXISTS {{rw}};"); |
219 | 219 | } |
220 | 220 | |
221 | - if(!$update_tables['player_award']) |
|
221 | + if (!$update_tables['player_award']) |
|
222 | 222 | { |
223 | 223 | upd_create_table('player_award', "( |
224 | 224 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
@@ -261,14 +261,14 @@ discard block |
||
261 | 261 | upd_log_version_update(); |
262 | 262 | |
263 | 263 | |
264 | - if(!isset($update_tables['planets']['que_processed'])) { |
|
264 | + if (!isset($update_tables['planets']['que_processed'])) { |
|
265 | 265 | upd_alter_table('planets', array( |
266 | 266 | "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `last_update`", |
267 | 267 | ), true); |
268 | 268 | upd_do_query("UPDATE {{planets}} SET que_processed = last_update;"); |
269 | 269 | } |
270 | 270 | |
271 | - if(!isset($update_tables['users']['que_processed'])) { |
|
271 | + if (!isset($update_tables['users']['que_processed'])) { |
|
272 | 272 | upd_alter_table('users', array( |
273 | 273 | "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `onlinetime`", |
274 | 274 | ), true); |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | |
280 | 280 | |
281 | 281 | |
282 | - if(isset($update_tables['planets']['que'])) { |
|
282 | + if (isset($update_tables['planets']['que'])) { |
|
283 | 283 | $sn_data_aux = array( |
284 | 284 | SHIP_SMALL_FIGHTER_WRATH => array( |
285 | 285 | 'name' => 'ship_fighter_wrath', |
@@ -364,20 +364,20 @@ discard block |
||
364 | 364 | $unit_data = array(); |
365 | 365 | $planets = array(); |
366 | 366 | |
367 | - foreach($planet_unit_list as $unit_id) { |
|
368 | - if(!($unit_name = get_unit_param($unit_id, P_NAME))) { |
|
367 | + foreach ($planet_unit_list as $unit_id) { |
|
368 | + if (!($unit_name = get_unit_param($unit_id, P_NAME))) { |
|
369 | 369 | $unit_name = $sn_data_aux[$unit_id][P_NAME]; |
370 | 370 | } |
371 | - if(isset($update_tables['planets'][$unit_name])) { |
|
371 | + if (isset($update_tables['planets'][$unit_name])) { |
|
372 | 372 | $drop[] = "DROP COLUMN `{$unit_name}`"; |
373 | 373 | |
374 | - if(isset($aux_group[$unit_id])) { |
|
374 | + if (isset($aux_group[$unit_id])) { |
|
375 | 375 | $units_info[$unit_id] = $sn_data_aux[$unit_id]; |
376 | 376 | $units_info[$unit_id]['que'] = QUE_HANGAR; |
377 | 377 | } else { |
378 | 378 | $units_info[$unit_id] = get_unit_param($unit_id); |
379 | - foreach($ques_info as $que_id => $que_data1) { |
|
380 | - if(in_array($unit_id, $que_data1['unit_list'])) { |
|
379 | + foreach ($ques_info as $que_id => $que_data1) { |
|
380 | + if (in_array($unit_id, $que_data1['unit_list'])) { |
|
381 | 381 | $units_info[$unit_id]['que'] = $que_id; |
382 | 382 | break; |
383 | 383 | } |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | } |
388 | 388 | |
389 | 389 | $query = upd_do_query("SELECT * FROM {{planets}} FOR UPDATE"); |
390 | - while($row = db_fetch($query)) { |
|
390 | + while ($row = db_fetch($query)) { |
|
391 | 391 | $user_id = $row['id_owner']; |
392 | 392 | $planet_id = $row['id']; |
393 | 393 | |
@@ -395,12 +395,12 @@ discard block |
||
395 | 395 | |
396 | 396 | // Конвертируем юниты |
397 | 397 | $units_levels = array(); |
398 | - foreach($planet_unit_list as $unit_id) { |
|
398 | + foreach ($planet_unit_list as $unit_id) { |
|
399 | 399 | $unit_name = &$units_info[$unit_id][P_NAME]; |
400 | - if(!isset($row[$unit_name]) || !$row[$unit_name]) continue; |
|
400 | + if (!isset($row[$unit_name]) || !$row[$unit_name]) continue; |
|
401 | 401 | $units_levels[$unit_id] = $row[$unit_name]; |
402 | 402 | $unit_data[] = "({$user_id}," . LOC_PLANET . ",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})"; |
403 | - if(count($unit_data) > 30) { |
|
403 | + if (count($unit_data) > 30) { |
|
404 | 404 | $unit_data_max = strlen(implode(',', $unit_data)) > $unit_data_max ? strlen(implode(',', $unit_data)) : $unit_data_max; |
405 | 405 | upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';'); |
406 | 406 | $unit_data = array(); |
@@ -408,10 +408,10 @@ discard block |
||
408 | 408 | } |
409 | 409 | |
410 | 410 | // Конвертируем очередь построек |
411 | - if($row['que']) { |
|
411 | + if ($row['que']) { |
|
412 | 412 | $que = explode(';', $row['que']); |
413 | - foreach($que as $que_item) { |
|
414 | - if(!$que_item) continue; |
|
413 | + foreach ($que as $que_item) { |
|
414 | + if (!$que_item) continue; |
|
415 | 415 | |
416 | 416 | $que_item = explode(',', $que_item); |
417 | 417 | |
@@ -424,8 +424,8 @@ discard block |
||
424 | 424 | $unit_factor = $unit_cost[P_FACTOR] ? $unit_cost[P_FACTOR] : 1; |
425 | 425 | $price_increase = pow($unit_factor, $unit_level); |
426 | 426 | // $unit_time = 0; |
427 | - foreach($unit_cost as $resource_id => &$resource_amount) { |
|
428 | - if(!in_array($resource_id, $group_resource_loot)) { |
|
427 | + foreach ($unit_cost as $resource_id => &$resource_amount) { |
|
428 | + if (!in_array($resource_id, $group_resource_loot)) { |
|
429 | 429 | unset($unit_cost[$resource_id]); |
430 | 430 | continue; |
431 | 431 | } |
@@ -439,33 +439,33 @@ discard block |
||
439 | 439 | } |
440 | 440 | |
441 | 441 | // Конвертируем очередь верфи |
442 | - if($row['b_hangar_id']) { |
|
443 | - $return_resources = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0, ); |
|
442 | + if ($row['b_hangar_id']) { |
|
443 | + $return_resources = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0,); |
|
444 | 444 | $hangar_units = sys_unit_str2arr($row['b_hangar_id']); |
445 | - foreach($hangar_units as $unit_id => $unit_count) { |
|
446 | - if($unit_count <= 0) continue; |
|
447 | - foreach($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) { |
|
448 | - if(!in_array($resource_id, $group_resource_loot)) continue; |
|
445 | + foreach ($hangar_units as $unit_id => $unit_count) { |
|
446 | + if ($unit_count <= 0) continue; |
|
447 | + foreach ($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) { |
|
448 | + if (!in_array($resource_id, $group_resource_loot)) continue; |
|
449 | 449 | $return_resources[$resource_id] += $unit_count * $resource_amount; |
450 | 450 | } |
451 | 451 | } |
452 | - if(array_sum($return_resources) > 0) { |
|
452 | + if (array_sum($return_resources) > 0) { |
|
453 | 453 | upd_do_query("UPDATE {{planets}} SET `metal` = `metal` + {$return_resources[RES_METAL]}, `crystal` = `crystal` + {$return_resources[RES_CRYSTAL]}, `deuterium` = `deuterium` + {$return_resources[RES_DEUTERIUM]} WHERE `id` = {$planet_id} LIMIT 1"); |
454 | 454 | } |
455 | 455 | } |
456 | 456 | |
457 | 457 | |
458 | - if(count($que_data) > 10) { |
|
458 | + if (count($que_data) > 10) { |
|
459 | 459 | $que_data_max = strlen(implode(',', $que_data)) > $que_data_max ? strlen(implode(',', $que_data)) : $que_data_max; |
460 | 460 | upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES ' . implode(',', $que_data) . ';'); |
461 | 461 | $que_data = array(); |
462 | 462 | } |
463 | 463 | } |
464 | 464 | |
465 | - if(!empty($unit_data)) |
|
465 | + if (!empty($unit_data)) |
|
466 | 466 | upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';'); |
467 | 467 | |
468 | - if(!empty($que_data)) |
|
468 | + if (!empty($que_data)) |
|
469 | 469 | upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES ' . implode(',', $que_data) . ';'); |
470 | 470 | |
471 | 471 | upd_alter_table('planets', $drop, true); |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | JOIN `{{users}}` AS u ON a.`id` = u.`user_as_ally` AND `user_as_ally` IS NOT NULL AND `username` = '' |
476 | 476 | SET u.`username` = CONCAT('[', a.`ally_tag`, ']');"); |
477 | 477 | |
478 | - if($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') { |
|
478 | + if ($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') { |
|
479 | 479 | upd_do_query("SET FOREIGN_KEY_CHECKS=0;"); |
480 | 480 | upd_alter_table('statpoints', "DROP FOREIGN KEY `FK_stats_id_ally`", $update_foreigns['statpoints']['FK_stats_id_ally']); |
481 | 481 | upd_alter_table('statpoints', "DROP KEY `I_stats_id_ally`", $update_indexes['statpoints']['I_stats_id_ally']); |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | "ADD CONSTRAINT `FK_users_browser_id` FOREIGN KEY (`user_last_browser_id`) REFERENCES `{$config->db_prefix}security_browser` (`browser_id`) ON DELETE SET NULL ON UPDATE CASCADE", |
572 | 572 | ), !isset($update_tables['users']['user_last_proxy'])); |
573 | 573 | |
574 | - if(!isset($update_tables['notes']['planet_type'])) { |
|
574 | + if (!isset($update_tables['notes']['planet_type'])) { |
|
575 | 575 | upd_alter_table('notes', array( |
576 | 576 | // "ADD COLUMN `planet_name` VARCHAR(64) NOT NULL DEFAULT '' AFTER `title`", |
577 | 577 | "ADD COLUMN `galaxy` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `title`", |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | upd_alter_table('users', "ADD COLUMN `user_bot` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['users']['user_bot'])); |
591 | 591 | upd_alter_table('unit', "ADD KEY `I_unit_type_snid` (unit_type, unit_snid) USING BTREE", !$update_indexes['unit']['I_unit_type_snid']); |
592 | 592 | |
593 | - if($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') { |
|
593 | + if ($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') { |
|
594 | 594 | upd_alter_table('users', array( |
595 | 595 | "MODIFY COLUMN `settings_tooltiptime` smallint(5) unsigned NOT NULL DEFAULT '500'", |
596 | 596 | ), $update_tables['users']['settings_tooltiptime']['Type'] != 'smallint'); |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | upd_do_query("UPDATE `{{users}}` SET settings_tooltiptime = 500;"); |
599 | 599 | } |
600 | 600 | |
601 | - if(!isset($update_tables['log_users_online']['online_aggregated'])) { |
|
601 | + if (!isset($update_tables['log_users_online']['online_aggregated'])) { |
|
602 | 602 | upd_alter_table('log_users_online', "ADD COLUMN `online_aggregated` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['log_users_online']['online_aggregated'])); |
603 | 603 | upd_alter_table('log_users_online', array( |
604 | 604 | "DROP PRIMARY KEY", |
@@ -606,13 +606,13 @@ discard block |
||
606 | 606 | ), $update_indexes['log_users_online']['PRIMARY'] != 'online_timestamp,online_aggregated,'); |
607 | 607 | } |
608 | 608 | |
609 | - if(!isset($update_tables['users']['gender'])) { |
|
609 | + if (!isset($update_tables['users']['gender'])) { |
|
610 | 610 | upd_alter_table('users', "ADD COLUMN `gender` TINYINT(1) UNSIGNED NOT NULL DEFAULT " . GENDER_UNKNOWN, !isset($update_tables['users']['gender'])); |
611 | - upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', " . GENDER_FEMALE. ", IF(UPPER(`sex`) = 'M', " . GENDER_MALE . ", " . GENDER_UNKNOWN . "));"); |
|
611 | + upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', " . GENDER_FEMALE . ", IF(UPPER(`sex`) = 'M', " . GENDER_MALE . ", " . GENDER_UNKNOWN . "));"); |
|
612 | 612 | } |
613 | 613 | upd_alter_table('users', "DROP COLUMN `sex`", isset($update_tables['users']['sex'])); |
614 | 614 | |
615 | - if(!$update_tables['users']['dark_matter_total']) { |
|
615 | + if (!$update_tables['users']['dark_matter_total']) { |
|
616 | 616 | upd_alter_table('users', "ADD `dark_matter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Dark Matter amount ever gained' AFTER `dark_matter`", !$update_tables['users']['dark_matter_total']); |
617 | 617 | upd_do_query( |
618 | 618 | "UPDATE `{{users}}` AS u |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | } |
626 | 626 | |
627 | 627 | upd_check_key('player_metamatter_immortal', 100000, !isset($config->player_metamatter_immortal)); |
628 | - if(!$update_tables['users']['metamatter_total']) { |
|
628 | + if (!$update_tables['users']['metamatter_total']) { |
|
629 | 629 | upd_alter_table('users', "ADD `metamatter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Metamatter amount ever bought'", !$update_tables['users']['metamatter_total']); |
630 | 630 | |
631 | 631 | upd_do_query( |
@@ -637,11 +637,11 @@ discard block |
||
637 | 637 | (SELECT IF(sum(amount) IS NULL, 0, sum(amount)) FROM {{log_metamatter}} AS mm WHERE mm.user_id = u.id AND mm.amount > 0) |
638 | 638 | );"); |
639 | 639 | } |
640 | - if(!isset($update_tables['users']['immortal'])) { |
|
640 | + if (!isset($update_tables['users']['immortal'])) { |
|
641 | 641 | upd_alter_table('users', "ADD COLUMN `immortal` TIMESTAMP NULL", !isset($update_tables['users']['immortal'])); |
642 | 642 | upd_do_query("UPDATE {{users}} SET `immortal` = NOW() WHERE `metamatter_total` > 0;"); |
643 | 643 | } |
644 | - if(isset($update_tables['player_award'])) { |
|
644 | + if (isset($update_tables['player_award'])) { |
|
645 | 645 | upd_do_query( |
646 | 646 | "UPDATE {{users}} AS u JOIN {{player_award}} AS pa ON u.id = pa.player_id |
647 | 647 | SET metamatter_total = 1, immortal = NOW() |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | CONSTRAINT `FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
669 | 669 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"); |
670 | 670 | |
671 | - if(empty($update_tables['blitz_statpoints'])) { |
|
671 | + if (empty($update_tables['blitz_statpoints'])) { |
|
672 | 672 | upd_create_table('blitz_statpoints', " ( |
673 | 673 | `stat_date` int(11) NOT NULL DEFAULT '0', |
674 | 674 | `id_owner` bigint(20) unsigned DEFAULT NULL, |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | CONSTRAINT `FK_survey_votes_survey_parent_id` FOREIGN KEY (`survey_parent_id`) REFERENCES `{{survey}}` (`survey_id`) ON DELETE CASCADE ON UPDATE CASCADE |
737 | 737 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"); |
738 | 738 | |
739 | - if(empty($update_tables['security_url'])) { |
|
739 | + if (empty($update_tables['security_url'])) { |
|
740 | 740 | upd_create_table('security_url', " ( |
741 | 741 | `url_id` int unsigned NOT NULL AUTO_INCREMENT, |
742 | 742 | `url_string` VARCHAR(250) NOT NULL DEFAULT '', |
@@ -749,9 +749,9 @@ discard block |
||
749 | 749 | |
750 | 750 | $strings = array(); |
751 | 751 | $query = doquery($query); |
752 | - while($row = db_fetch($query)) { |
|
752 | + while ($row = db_fetch($query)) { |
|
753 | 753 | $strings[] = '("' . db_escape($row['url']) . '")'; |
754 | - if(count($strings) > 100) { |
|
754 | + if (count($strings) > 100) { |
|
755 | 755 | doquery($query_string . implode(',', $strings)); |
756 | 756 | $strings = array(); |
757 | 757 | } |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | !empty($strings) ? doquery($query_string . implode(',', $strings)) : false; |
760 | 760 | } |
761 | 761 | |
762 | - if(isset($update_tables['counter']['page'])) // TODO REMOVE |
|
762 | + if (isset($update_tables['counter']['page'])) // TODO REMOVE |
|
763 | 763 | { |
764 | 764 | update_security_url("SELECT DISTINCT `page` as url FROM {{counter}}"); |
765 | 765 | update_security_url("SELECT DISTINCT `url` as url FROM {{counter}}"); |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | "ADD CONSTRAINT `FK_counter_page_url_id` FOREIGN KEY (`page_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE", |
785 | 785 | "ADD CONSTRAINT `FK_counter_plain_url_id` FOREIGN KEY (`plain_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE", |
786 | 786 | ), !isset($update_tables['counter']['device_id'])); |
787 | - if(isset($update_tables['counter']['ip'])) { |
|
787 | + if (isset($update_tables['counter']['ip'])) { |
|
788 | 788 | // upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `user_proxy` = `proxy`, `visit_time` = FROM_UNIXTIME(`time`)'); |
789 | 789 | upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `visit_time` = FROM_UNIXTIME(`time`)'); |
790 | 790 | upd_do_query('UPDATE `{{counter}}` AS c JOIN {{security_url}} AS u ON u.url_string = c.page SET c.page_url_id = u.url_id'); |
@@ -835,8 +835,8 @@ discard block |
||
835 | 835 | |
836 | 836 | upd_check_key('stats_history_days', 14, !$config->stats_history_days); |
837 | 837 | |
838 | - if($config->payment_currency_default != 'USD') { |
|
839 | - upd_check_key('payment_currency_default', 'USD', true); |
|
838 | + if ($config->payment_currency_default != 'USD') { |
|
839 | + upd_check_key('payment_currency_default', 'USD', true); |
|
840 | 840 | upd_check_key('payment_currency_exchange_dm_', 20000, true); |
841 | 841 | upd_check_key('payment_currency_exchange_mm_', 20000, true); |
842 | 842 | upd_check_key('payment_currency_exchange_usd', 1, true); |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | function propagade_player_options($old_option_name, $new_option_id) { |
919 | 919 | global $update_tables; |
920 | 920 | |
921 | - if(!empty($update_tables['users'][$old_option_name])) { |
|
921 | + if (!empty($update_tables['users'][$old_option_name])) { |
|
922 | 922 | upd_do_query( |
923 | 923 | "REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`) |
924 | 924 | SELECT `id`, {$new_option_id}, `{$old_option_name}` |
@@ -952,7 +952,7 @@ discard block |
||
952 | 952 | |
953 | 953 | // 2015-08-03 15:05:26 40a6.0 |
954 | 954 | |
955 | - if(empty($update_tables['planets']['position_original'])) { |
|
955 | + if (empty($update_tables['planets']['position_original'])) { |
|
956 | 956 | upd_alter_table('planets', array( |
957 | 957 | "ADD COLUMN `position_original` smallint NOT NULL DEFAULT 0", |
958 | 958 | "ADD COLUMN `field_max_original` smallint NOT NULL DEFAULT 0", |
@@ -980,12 +980,12 @@ discard block |
||
980 | 980 | // 2015-08-27 19:14:05 40a10.0 |
981 | 981 | |
982 | 982 | // Старая версия таблицы |
983 | - if(!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) { |
|
983 | + if (!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) { |
|
984 | 984 | upd_drop_table('account'); |
985 | 985 | upd_drop_table('account_translate'); |
986 | 986 | } |
987 | 987 | |
988 | - if(empty($update_tables['account'])) { |
|
988 | + if (empty($update_tables['account'])) { |
|
989 | 989 | upd_create_table('account', " ( |
990 | 990 | `account_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
991 | 991 | `account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT '', |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | upd_alter_table('security_url', "MODIFY COLUMN `url_string` VARCHAR(250) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''", empty($update_tables['security_url']['ube_report_capture_result'])); |
1044 | 1044 | |
1045 | 1045 | // 2015-09-24 11:39:37 40a10.25 |
1046 | - if(empty($update_tables['log_metamatter']['provider_id'])) { |
|
1046 | + if (empty($update_tables['log_metamatter']['provider_id'])) { |
|
1047 | 1047 | upd_alter_table('log_metamatter', array( |
1048 | 1048 | "ADD COLUMN `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Account provider'", |
1049 | 1049 | "ADD COLUMN `account_id` bigint(20) unsigned NOT NULL DEFAULT 0", |
@@ -1093,7 +1093,7 @@ discard block |
||
1093 | 1093 | upd_check_key('event_halloween_2015_code', '', !isset($config->event_halloween_2015_code)); |
1094 | 1094 | upd_check_key('event_halloween_2015_timestamp', SN_TIME_SQL, !isset($config->event_halloween_2015_timestamp)); |
1095 | 1095 | upd_check_key('event_halloween_2015_units_used', serialize(array()), !isset($config->event_halloween_2015_units_used)); |
1096 | - if(empty($update_tables['log_halloween_2015'])) { |
|
1096 | + if (empty($update_tables['log_halloween_2015'])) { |
|
1097 | 1097 | upd_create_table('log_halloween_2015', " ( |
1098 | 1098 | `log_hw2015_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1099 | 1099 | `player_id` bigint(20) unsigned NOT NULL COMMENT 'User ID', |
@@ -1107,7 +1107,7 @@ discard block |
||
1107 | 1107 | } |
1108 | 1108 | |
1109 | 1109 | // 2015-11-28 06:30:27 40a19.21 |
1110 | - if(!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) { |
|
1110 | + if (!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) { |
|
1111 | 1111 | upd_alter_table('ube_report', array( |
1112 | 1112 | "ADD COLUMN `ube_report_debris_total_in_metal` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Total debris in metal'", |
1113 | 1113 | // "ADD KEY `I_ube_report_debris_id` (`ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC)", // For Best Battles module |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | } |
1123 | 1123 | |
1124 | 1124 | // 2015-12-06 15:10:58 40b1.0 |
1125 | - if(!empty($update_indexes['planets']['I_metal_mine'])) { |
|
1125 | + if (!empty($update_indexes['planets']['I_metal_mine'])) { |
|
1126 | 1126 | upd_alter_table('planets', "DROP KEY `I_metal`", $update_indexes['planets']['I_metal']); |
1127 | 1127 | upd_alter_table('planets', "DROP KEY `I_ship_sattelite_sloth`", $update_indexes['planets']['I_ship_sattelite_sloth']); |
1128 | 1128 | upd_alter_table('planets', "DROP KEY `I_ship_bomber_envy`", $update_indexes['planets']['I_ship_bomber_envy']); |
@@ -1187,7 +1187,7 @@ discard block |
||
1187 | 1187 | case 40: |
1188 | 1188 | upd_log_version_update(); |
1189 | 1189 | |
1190 | - if(empty($update_tables['festival'])) { |
|
1190 | + if (empty($update_tables['festival'])) { |
|
1191 | 1191 | upd_create_table('festival', " ( |
1192 | 1192 | `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
1193 | 1193 | `start` datetime NOT NULL COMMENT 'Festival start datetime', |
@@ -1228,7 +1228,7 @@ discard block |
||
1228 | 1228 | ); |
1229 | 1229 | } |
1230 | 1230 | |
1231 | - if(empty($update_tables['festival_unit'])) { |
|
1231 | + if (empty($update_tables['festival_unit'])) { |
|
1232 | 1232 | upd_create_table('festival_unit', " ( |
1233 | 1233 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1234 | 1234 | `highspot_id` int(10) unsigned DEFAULT NULL, |
@@ -1245,7 +1245,7 @@ discard block |
||
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | // 2015-12-21 06:06:09 41a0.12 |
1248 | - if(empty($update_tables['festival_unit_log'])) { |
|
1248 | + if (empty($update_tables['festival_unit_log'])) { |
|
1249 | 1249 | upd_create_table('festival_unit_log', " ( |
1250 | 1250 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1251 | 1251 | `highspot_id` int(10) unsigned DEFAULT NULL, |
@@ -1273,13 +1273,13 @@ discard block |
||
1273 | 1273 | $update_tables['security_browser']['browser_user_agent']['Collation'] == 'latin1_bin' |
1274 | 1274 | ); |
1275 | 1275 | |
1276 | - if($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') { |
|
1276 | + if ($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') { |
|
1277 | 1277 | upd_alter_table('security_browser', "DROP KEY `I_browser_user_agent`", true); |
1278 | 1278 | upd_alter_table('security_browser', "ADD KEY `I_browser_user_agent` (`browser_user_agent`) USING HASH", true); |
1279 | 1279 | } |
1280 | 1280 | |
1281 | 1281 | // 2016-12-03 20:36:46 41a61.0 |
1282 | - if(empty($update_tables['auth_vkontakte_account'])) { |
|
1282 | + if (empty($update_tables['auth_vkontakte_account'])) { |
|
1283 | 1283 | upd_create_table('auth_vkontakte_account', " ( |
1284 | 1284 | `user_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1285 | 1285 | `access_token` varchar(250) NOT NULL DEFAULT '', |
@@ -1321,7 +1321,7 @@ discard block |
||
1321 | 1321 | |
1322 | 1322 | classSupernova::$cache->unset_by_prefix('lng_'); |
1323 | 1323 | |
1324 | -if($new_version) { |
|
1324 | +if ($new_version) { |
|
1325 | 1325 | $config->db_saveItem('db_version', $new_version); |
1326 | 1326 | upd_log_message("<font color=green>DB version is now {$new_version}</font>"); |
1327 | 1327 | } else { |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | 'factor' => 1.5, |
16 | 16 | ), |
17 | 17 | P_UNIT_PRODUCTION => array( |
18 | - RES_METAL => function ($level, $production_factor, $user, $planet_row) {return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
19 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
18 | + RES_METAL => function($level, $production_factor, $user, $planet_row) {return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
19 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
20 | 20 | ), |
21 | 21 | P_MINING_IS_MANAGED => true, |
22 | 22 | ), |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | 'factor' => 1.6, |
34 | 34 | ), |
35 | 35 | P_UNIT_PRODUCTION => array( |
36 | - RES_CRYSTAL => function ($level, $production_factor, $user, $planet_row) {return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
37 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
36 | + RES_CRYSTAL => function($level, $production_factor, $user, $planet_row) {return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
37 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
38 | 38 | ), |
39 | 39 | P_MINING_IS_MANAGED => true, |
40 | 40 | ), |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | 'factor' => 1.5, |
52 | 52 | ), |
53 | 53 | P_UNIT_PRODUCTION => array( |
54 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) {return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28);}, |
|
55 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
54 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) {return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28); }, |
|
55 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
56 | 56 | ), |
57 | 57 | P_MINING_IS_MANAGED => true, |
58 | 58 | ), |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | 'factor' => 1.5, |
70 | 70 | ), |
71 | 71 | P_UNIT_PRODUCTION => array( |
72 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
72 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
73 | 73 | ), |
74 | 74 | P_MINING_IS_MANAGED => true, |
75 | 75 | ), |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | 'factor' => 1.8, |
88 | 88 | ), |
89 | 89 | P_UNIT_PRODUCTION => array( |
90 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
91 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, "", TECH_ENERGY), $level) * (0.1 * $production_factor);}, |
|
90 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
91 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, "", TECH_ENERGY), $level) * (0.1 * $production_factor); }, |
|
92 | 92 | ), |
93 | 93 | P_MINING_IS_MANAGED => true, |
94 | 94 | ), |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | 'factor' => 2, |
106 | 106 | ), |
107 | 107 | 'storage' => array( |
108 | - RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
108 | + RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
109 | 109 | ), |
110 | 110 | ), |
111 | 111 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | 'factor' => 2, |
122 | 122 | ), |
123 | 123 | 'storage' => array( |
124 | - RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
124 | + RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
125 | 125 | ), |
126 | 126 | ), |
127 | 127 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | 'factor' => 2, |
138 | 138 | ), |
139 | 139 | 'storage' => array( |
140 | - RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
140 | + RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
141 | 141 | ), |
142 | 142 | ), |
143 | 143 |
@@ -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 | 12 | $full_filename = $dir_name . $file; |
13 | - if($modules && is_dir($full_filename)) { |
|
14 | - if(file_exists($full_filename = "{$full_filename}/{$file}.{$load_extension}")) { |
|
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 | } |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function init_update(&$config) { |
41 | 41 | $update_file = SN_ROOT_PHYSICAL . "includes/update" . DOT_PHP_EX; |
42 | - if(file_exists($update_file)) { |
|
43 | - if(filemtime($update_file) > $config->db_loadItem('var_db_update') || $config->db_loadItem('db_version') < DB_VERSION) { |
|
44 | - if(defined('IN_ADMIN')) { |
|
42 | + if (file_exists($update_file)) { |
|
43 | + if (filemtime($update_file) > $config->db_loadItem('var_db_update') || $config->db_loadItem('db_version') < DB_VERSION) { |
|
44 | + if (defined('IN_ADMIN')) { |
|
45 | 45 | sn_db_transaction_start(); // Для защиты от двойного запуска апдейта - начинаем транзакцию. Так запись в базе будет блокирована |
46 | - if(SN_TIME_NOW >= $config->db_loadItem('var_db_update_end')) { |
|
46 | + if (SN_TIME_NOW >= $config->db_loadItem('var_db_update_end')) { |
|
47 | 47 | $config->db_saveItem('var_db_update_end', SN_TIME_NOW + ($config->upd_lock_time ? $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 | $config->db_saveItem('var_db_update', $current_time); |
55 | 55 | $config->db_saveItem('var_db_update_end', $current_time); |
56 | - } elseif(filemtime($update_file) > $config->var_db_update) { |
|
56 | + } elseif (filemtime($update_file) > $config->var_db_update) { |
|
57 | 57 | $timeout = $config->var_db_update_end - SN_TIME_NOW; |
58 | 58 | die( |
59 | 59 | "Обновляется база данных. Рассчетное время окончания - {$timeout} секунд (время обновления может увеличиваться). Пожалуйста, подождите...<br /> |
@@ -30,29 +30,29 @@ discard block |
||
30 | 30 | } |
31 | 31 | $size = getimagesize(SN_ROOT_PHYSICAL . $img_name); |
32 | 32 | $im = imagecreatefrompng(SN_ROOT_PHYSICAL . $img_name); |
33 | - $image = imagecreatetruecolor($size[0],$size[1]); |
|
34 | - imagecopy($image,$im,0,0,0,0,$size[0],$size[1]); |
|
33 | + $image = imagecreatetruecolor($size[0], $size[1]); |
|
34 | + imagecopy($image, $im, 0, 0, 0, 0, $size[0], $size[1]); |
|
35 | 35 | imagedestroy($im); |
36 | 36 | |
37 | 37 | // Colors |
38 | 38 | $color = "FFFFFF"; |
39 | - $red = hexdec(substr($color,0,2)); |
|
40 | - $green = hexdec(substr($color,2,4)); |
|
41 | - $blue = hexdec(substr($color,4,6)); |
|
42 | - $select = imagecolorallocate($image,$red,$green,$blue); |
|
39 | + $red = hexdec(substr($color, 0, 2)); |
|
40 | + $green = hexdec(substr($color, 2, 4)); |
|
41 | + $blue = hexdec(substr($color, 4, 6)); |
|
42 | + $select = imagecolorallocate($image, $red, $green, $blue); |
|
43 | 43 | $txt_shadow = imagecolorallocatealpha($image, 255, 255, 255, 255); |
44 | 44 | $txt_color = imagecolorallocatealpha($image, 255, 255, 255, 2); |
45 | 45 | $txt_shadow2 = imagecolorallocatealpha($image, 255, 255, 255, 255); |
46 | 46 | $txt_color2 = imagecolorallocatealpha($image, 255, 255, 255, 40); |
47 | 47 | |
48 | - $fonts = array ( |
|
48 | + $fonts = array( |
|
49 | 49 | 'userbar' => SN_ROOT_PHYSICAL . "design/fonts/" . $config->int_userbar_font, |
50 | 50 | 'universe' => SN_ROOT_PHYSICAL . "design/fonts/" . $config->int_banner_fontUniverse, |
51 | 51 | 'raids' => SN_ROOT_PHYSICAL . "design/fonts/" . $config->int_banner_fontRaids, |
52 | 52 | 'info' => SN_ROOT_PHYSICAL . "design/fonts/" . $config->int_banner_fontInfo, |
53 | 53 | ); |
54 | 54 | |
55 | - if($id) |
|
55 | + if ($id) |
|
56 | 56 | { |
57 | 57 | // Querys |
58 | 58 | $user = db_user_by_id($id); |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | $b_user = $user['username']; |
63 | 63 | $b_ally = $user['ally_name']; |
64 | 64 | $b_planet = $planet_row['name']; |
65 | - $b_xyz = "[".$planet_row['galaxy'].":".$planet_row['system'].":".$planet_row['planet']."]"; |
|
66 | - $b_lvl = ($user['total_rank'] ? $user['total_rank'] : $config->users_amount) ."/{$config->users_amount}"; |
|
65 | + $b_xyz = "[" . $planet_row['galaxy'] . ":" . $planet_row['system'] . ":" . $planet_row['planet'] . "]"; |
|
66 | + $b_lvl = ($user['total_rank'] ? $user['total_rank'] : $config->users_amount) . "/{$config->users_amount}"; |
|
67 | 67 | } |
68 | 68 | else |
69 | 69 | { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | imagettftext($image, 11, 0, 8, 26, $txt_shadow, $fonts['info'], $b_user); |
86 | 86 | imagettftext($image, 11, 0, 6, 23, $txt_color, $fonts['info'], $b_user); |
87 | 87 | |
88 | - if($id) |
|
88 | + if ($id) |
|
89 | 89 | { |
90 | 90 | // Player level - right-alligned |
91 | 91 | $is = imagettfbbox(11, 0, $fonts['info'], $b_lvl); |
@@ -94,37 +94,37 @@ discard block |
||
94 | 94 | |
95 | 95 | // Ally name |
96 | 96 | $is = imagettfbbox(9, 0, $fonts['info'], $b_ally); |
97 | - imagettftext($image, 9, 0, 412-$is[2], 37, $txt_shadow, $fonts['info'], $b_ally); |
|
98 | - imagettftext($image, 9, 0, 410-$is[2], 35, $txt_color, $fonts['info'], $b_ally); |
|
97 | + imagettftext($image, 9, 0, 412 - $is[2], 37, $txt_shadow, $fonts['info'], $b_ally); |
|
98 | + imagettftext($image, 9, 0, 410 - $is[2], 35, $txt_color, $fonts['info'], $b_ally); |
|
99 | 99 | |
100 | 100 | // Player b_planet |
101 | - imagettftext($image, 6, 0, 8, 10, $txt_shadow2, $fonts['raids'], $b_planet." ".$b_xyz); |
|
102 | - imagettftext($image, 6, 0, 6, 9, $txt_color2, $fonts['raids'], $b_planet." ".$b_xyz); |
|
101 | + imagettftext($image, 6, 0, 8, 10, $txt_shadow2, $fonts['raids'], $b_planet . " " . $b_xyz); |
|
102 | + imagettftext($image, 6, 0, 6, 9, $txt_color2, $fonts['raids'], $b_planet . " " . $b_xyz); |
|
103 | 103 | |
104 | 104 | //StatPoint |
105 | - $b_points = $lang['ov_points'].": ".pretty_number($user['total_points']); |
|
105 | + $b_points = $lang['ov_points'] . ": " . pretty_number($user['total_points']); |
|
106 | 106 | $is = imagettfbbox(8, 0, $fonts['info'], $b_points); |
107 | - imagettftext($image, 8, 0, 412-$is[2], 11, $txt_shadow, $fonts['info'], $b_points); |
|
108 | - imagettftext($image, 8, 0, 410-$is[2], 9, $txt_color, $fonts['info'], $b_points); |
|
107 | + imagettftext($image, 8, 0, 412 - $is[2], 11, $txt_shadow, $fonts['info'], $b_points); |
|
108 | + imagettftext($image, 8, 0, 410 - $is[2], 9, $txt_color, $fonts['info'], $b_points); |
|
109 | 109 | |
110 | 110 | //Raids Total |
111 | 111 | imagettftext($image, 6, 0, 8, 37, $txt_shadow2, $fonts['raids'], $lang['NumberOfRaids']); |
112 | 112 | imagettftext($image, 6, 0, 6, 35, $txt_color2, $fonts['raids'], $lang['NumberOfRaids']); |
113 | - $b_points = ": ".pretty_number($user['raids']); |
|
113 | + $b_points = ": " . pretty_number($user['raids']); |
|
114 | 114 | imagettftext($image, 6, 0, 61, 37, $txt_shadow2, $fonts['raids'], $b_points); |
115 | 115 | imagettftext($image, 6, 0, 59, 35, $txt_color2, $fonts['raids'], $b_points); |
116 | 116 | |
117 | 117 | //Raids Won |
118 | 118 | imagettftext($image, 6, 0, 8, 47, $txt_shadow2, $fonts['raids'], $lang['RaidsWin']); |
119 | 119 | imagettftext($image, 6, 0, 6, 45, $txt_color2, $fonts['raids'], $lang['RaidsWin']); |
120 | - $b_points = ": ".pretty_number($user['raidswin']); |
|
120 | + $b_points = ": " . pretty_number($user['raidswin']); |
|
121 | 121 | imagettftext($image, 6, 0, 61, 47, $txt_shadow2, $fonts['raids'], $b_points); |
122 | 122 | imagettftext($image, 6, 0, 59, 45, $txt_color2, $fonts['raids'], $b_points); |
123 | 123 | |
124 | 124 | //Raids Lost |
125 | 125 | imagettftext($image, 6, 0, 8, 57, $txt_shadow2, $fonts['raids'], $lang['RaidsLoose']); |
126 | 126 | imagettftext($image, 6, 0, 6, 55, $txt_color2, $fonts['raids'], $lang['RaidsLoose']); |
127 | - $b_points = ": ".pretty_number($user['raidsloose']); |
|
127 | + $b_points = ": " . pretty_number($user['raidsloose']); |
|
128 | 128 | imagettftext($image, 6, 0, 61, 57, $txt_shadow2, $fonts['raids'], $b_points); |
129 | 129 | imagettftext($image, 6, 0, 59, 55, $txt_color2, $fonts['raids'], $b_points); |
130 | 130 | } |
@@ -137,25 +137,25 @@ discard block |
||
137 | 137 | $is = imagettfbbox(9, 0, $fonts['userbar'], $b_univ); |
138 | 138 | $is = $size[0] - $is[2] - 2; |
139 | 139 | imagettftext($image, 9, 0, $is, $size[1] - 3, $txt_shadow, $fonts['userbar'], $b_univ); |
140 | - imagettftext($image, 9, 0, $is-1, $size[1] - 5, $txt_color, $fonts['userbar'], $b_univ); |
|
141 | - imagettftext($image, 22, 0, $is-8, $size[1], $txt_color, $fonts['userbar'], '/'); |
|
140 | + imagettftext($image, 9, 0, $is - 1, $size[1] - 5, $txt_color, $fonts['userbar'], $b_univ); |
|
141 | + imagettftext($image, 22, 0, $is - 8, $size[1], $txt_color, $fonts['userbar'], '/'); |
|
142 | 142 | |
143 | 143 | // Player name |
144 | 144 | imagettftext($image, 9, 0, 4, $size[1] - 4, $txt_shadow, $fonts['userbar'], $b_user); |
145 | 145 | imagettftext($image, 9, 0, 2, $size[1] - 6, $txt_color, $fonts['userbar'], $b_user); |
146 | 146 | |
147 | - if($id) |
|
147 | + if ($id) |
|
148 | 148 | { |
149 | 149 | // Player level - right-alligned |
150 | 150 | $isp = imagettfbbox(9, 0, $fonts['userbar'], $b_lvl); |
151 | - imagettftext($image, 9, 0, $is-$isp[2] - 10, $size[1] - 4, $txt_shadow, $fonts['userbar'], $b_lvl); |
|
152 | - imagettftext($image, 9, 0, $is-$isp[2] - 10 - 1, $size[1] - 4 - 1, $txt_color, $fonts['userbar'], $b_lvl); |
|
151 | + imagettftext($image, 9, 0, $is - $isp[2] - 10, $size[1] - 4, $txt_shadow, $fonts['userbar'], $b_lvl); |
|
152 | + imagettftext($image, 9, 0, $is - $isp[2] - 10 - 1, $size[1] - 4 - 1, $txt_color, $fonts['userbar'], $b_lvl); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | 156 | //And now convert it back to PNG-8 |
157 | - $im_result = imagecreate($size[0],$size[1]); |
|
158 | - imagecopy($im_result,$image,0,0,0,0,$size[0],$size[1]); |
|
157 | + $im_result = imagecreate($size[0], $size[1]); |
|
158 | + imagecopy($im_result, $image, 0, 0, 0, 0, $size[0], $size[1]); |
|
159 | 159 | imagedestroy($image); |
160 | 160 | //And save it |
161 | 161 | $imagetypes = imagetypes(); |
@@ -11,8 +11,7 @@ discard block |
||
11 | 11 | * @version 1.0 copyright 2008 By e-Zobar for XNova |
12 | 12 | */ |
13 | 13 | |
14 | -function int_banner_create($id, $type = 'userbar', $format = 'png') |
|
15 | -{ |
|
14 | +function int_banner_create($id, $type = 'userbar', $format = 'png') { |
|
16 | 15 | // banner.php?id=<userid>&type=<banner|userbar>&format=<png> |
17 | 16 | global $config, $lang; |
18 | 17 | |
@@ -64,8 +63,7 @@ discard block |
||
64 | 63 | $b_planet = $planet_row['name']; |
65 | 64 | $b_xyz = "[".$planet_row['galaxy'].":".$planet_row['system'].":".$planet_row['planet']."]"; |
66 | 65 | $b_lvl = ($user['total_rank'] ? $user['total_rank'] : $config->users_amount) ."/{$config->users_amount}"; |
67 | - } |
|
68 | - else |
|
66 | + } else |
|
69 | 67 | { |
70 | 68 | $b_user = $lang['ov_banner_empty_id']; |
71 | 69 | } |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function geoip_status(){return sn_function_call('geoip_status', array(&$result));} |
|
3 | +function geoip_status() {return sn_function_call('geoip_status', 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('geoip_ip_info', array($ip, &$result));} |
|
8 | +function geoip_ip_info($ip) {return sn_function_call('geoip_ip_info', array($ip, &$result)); } |
|
9 | 9 | function sn_geoip_ip_info($ip, &$result) { |
10 | 10 | return $result = false; |
11 | 11 | } |
@@ -12,34 +12,34 @@ discard block |
||
12 | 12 | |
13 | 13 | $in_admin = defined('IN_ADMIN') && IN_ADMIN === true; |
14 | 14 | |
15 | - if($in_admin) |
|
15 | + if ($in_admin) |
|
16 | 16 | { |
17 | 17 | $quest_id = sys_get_param_id('id'); |
18 | 18 | $quest_name = sys_get_param_str_unsafe('QUEST_NAME'); |
19 | - if(!empty($quest_name)) |
|
19 | + if (!empty($quest_name)) |
|
20 | 20 | { |
21 | 21 | $quest_description = sys_get_param_str_unsafe('QUEST_DESCRIPTION'); |
22 | 22 | try |
23 | 23 | { |
24 | 24 | $quest_rewards_list = sys_get_param('QUEST_REWARDS_LIST'); |
25 | 25 | $quest_rewards = array(); |
26 | - foreach($quest_rewards_list as $quest_rewards_id => $quest_rewards_amount) |
|
26 | + foreach ($quest_rewards_list as $quest_rewards_id => $quest_rewards_amount) |
|
27 | 27 | { |
28 | - if(!in_array($quest_rewards_id, $quest_reward_allowed)) |
|
28 | + if (!in_array($quest_rewards_id, $quest_reward_allowed)) |
|
29 | 29 | { |
30 | 30 | throw new Exception($lang['qst_adm_err_reward_type']); |
31 | 31 | } |
32 | 32 | |
33 | - if($quest_rewards_amount < 0) |
|
33 | + if ($quest_rewards_amount < 0) |
|
34 | 34 | { |
35 | 35 | throw new Exception($lang['qst_adm_err_reward_amount']); |
36 | 36 | } |
37 | - elseif($quest_rewards_amount > 0) |
|
37 | + elseif ($quest_rewards_amount > 0) |
|
38 | 38 | { |
39 | 39 | $quest_rewards[] = "{$quest_rewards_id},{$quest_rewards_amount}"; |
40 | 40 | } |
41 | 41 | } |
42 | - if(empty($quest_rewards)) |
|
42 | + if (empty($quest_rewards)) |
|
43 | 43 | { |
44 | 44 | throw new Exception($lang['qst_adm_err_reward_empty']); |
45 | 45 | } |
@@ -47,13 +47,13 @@ discard block |
||
47 | 47 | $quest_rewards = implode(';', $quest_rewards); |
48 | 48 | |
49 | 49 | $quest_unit_id = sys_get_param_int('QUEST_UNIT_ID'); |
50 | - if(!in_array($quest_unit_id, $quest_units_allowed)) |
|
50 | + if (!in_array($quest_unit_id, $quest_units_allowed)) |
|
51 | 51 | { |
52 | 52 | throw new Exception($lang['qst_adm_err_unit_id']); |
53 | 53 | } |
54 | 54 | |
55 | 55 | $quest_unit_amount = sys_get_param_float('QUEST_UNIT_AMOUNT'); |
56 | - if($quest_unit_amount <= 0) |
|
56 | + if ($quest_unit_amount <= 0) |
|
57 | 57 | { |
58 | 58 | throw new Exception($lang['qst_adm_err_unit_amount']); |
59 | 59 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | // TODO: Change quest type |
63 | 63 | $quest_type = 0; |
64 | 64 | |
65 | - if($mode == 'edit') |
|
65 | + if ($mode == 'edit') |
|
66 | 66 | { |
67 | 67 | $quest_name = db_escape($quest_name); |
68 | 68 | $quest_description = db_escape($quest_description); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $mode = ''; |
104 | 104 | }; |
105 | 105 | |
106 | - switch($mode) |
|
106 | + switch ($mode) |
|
107 | 107 | { |
108 | 108 | case 'del': |
109 | 109 | doquery("DELETE FROM {{quest}} WHERE `quest_id` = {$quest_id} LIMIT 1;"); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $query = doquery("SELECT count(*) AS count FROM {{quest}};", '', true); |
121 | 121 | $config->db_saveItem('quest_total', $query['count']); |
122 | 122 | } |
123 | - elseif(!$user_id) |
|
123 | + elseif (!$user_id) |
|
124 | 124 | { |
125 | 125 | $user_id = $user['id']; |
126 | 126 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | 'IN_ADMIN' => $in_admin, |
135 | 135 | )); |
136 | 136 | |
137 | - if($quest) |
|
137 | + if ($quest) |
|
138 | 138 | { |
139 | 139 | $quest_templatized = qst_templatize(qst_quest_parse($quest, false)); |
140 | 140 | } |
@@ -143,19 +143,19 @@ discard block |
||
143 | 143 | $quest_templatized['quest_rewards_list'] = array(); |
144 | 144 | } |
145 | 145 | |
146 | - foreach($quest_reward_allowed as $unit_id) |
|
146 | + foreach ($quest_reward_allowed as $unit_id) |
|
147 | 147 | { |
148 | 148 | $found = false; |
149 | - foreach($quest_templatized['quest_rewards_list'] as $quest_templatized_reward) |
|
149 | + foreach ($quest_templatized['quest_rewards_list'] as $quest_templatized_reward) |
|
150 | 150 | { |
151 | - if($quest_templatized_reward['ID'] == $unit_id) |
|
151 | + if ($quest_templatized_reward['ID'] == $unit_id) |
|
152 | 152 | { |
153 | 153 | $found = true; |
154 | 154 | break; |
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | - if(!$found) |
|
158 | + if (!$found) |
|
159 | 159 | { |
160 | 160 | $quest_templatized['quest_rewards_list'][$unit_id] = array( |
161 | 161 | 'ID' => $unit_id, |
@@ -167,12 +167,12 @@ discard block |
||
167 | 167 | |
168 | 168 | qst_assign_to_template($template, $quest_templatized); |
169 | 169 | |
170 | - foreach($quest_list as $quest_data) |
|
170 | + foreach ($quest_list as $quest_data) |
|
171 | 171 | { |
172 | 172 | qst_assign_to_template($template, qst_templatize($quest_data, true), 'quest'); |
173 | 173 | } |
174 | 174 | |
175 | - foreach($quest_units_allowed as $unit_id) |
|
175 | + foreach ($quest_units_allowed as $unit_id) |
|
176 | 176 | { |
177 | 177 | $template->assign_block_vars('allowed_unit', array( |
178 | 178 | 'ID' => $unit_id, |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | { |
186 | 186 | $quest_list = array(); |
187 | 187 | |
188 | - if($user_id) |
|
188 | + if ($user_id) |
|
189 | 189 | { |
190 | - if($status !== false) |
|
190 | + if ($status !== false) |
|
191 | 191 | { |
192 | 192 | $query_add_where = "AND qs.quest_status_status "; |
193 | - if($status == null) |
|
193 | + if ($status == null) |
|
194 | 194 | { |
195 | 195 | $query_add_where .= "IS NULL"; |
196 | 196 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | ;" |
211 | 211 | ); |
212 | 212 | |
213 | - while($quest = db_fetch($query)) |
|
213 | + while ($quest = db_fetch($query)) |
|
214 | 214 | { |
215 | 215 | $quest_list[$quest['quest_id']] = qst_quest_parse($quest); |
216 | 216 | } |
@@ -220,16 +220,16 @@ discard block |
||
220 | 220 | |
221 | 221 | function qst_assign_to_template(&$template, $quest_templatized, $block_name = false) |
222 | 222 | { |
223 | - if($block_name) |
|
223 | + if ($block_name) |
|
224 | 224 | { |
225 | 225 | $template->assign_block_vars($block_name, $quest_templatized); |
226 | 226 | } |
227 | 227 | else |
228 | 228 | { |
229 | 229 | $template->assign_vars($quest_templatized); |
230 | - if(!empty($quest_templatized['quest_rewards_list'])) |
|
230 | + if (!empty($quest_templatized['quest_rewards_list'])) |
|
231 | 231 | { |
232 | - foreach($quest_templatized['quest_rewards_list'] as $quest_reward) |
|
232 | + foreach ($quest_templatized['quest_rewards_list'] as $quest_reward) |
|
233 | 233 | { |
234 | 234 | $template->assign_block_vars(($block_name ? $block_name . '.' : '') . 'quest_rewards_list', $quest_reward); |
235 | 235 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | global $lang; |
252 | 252 | |
253 | 253 | $tmp = array(); |
254 | - foreach($quest['quest_rewards_list'] as $quest_reward_id => $quest_reward_amount) |
|
254 | + foreach ($quest['quest_rewards_list'] as $quest_reward_id => $quest_reward_amount) |
|
255 | 255 | { |
256 | 256 | $tmp[] = array( |
257 | 257 | 'ID' => $quest_reward_id, |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | function qst_active_triggers($quest_list) |
279 | 279 | { |
280 | 280 | $quest_triggers = array(); |
281 | - foreach($quest_list as $quest_id => $quest) |
|
281 | + foreach ($quest_list as $quest_id => $quest) |
|
282 | 282 | { |
283 | - if($quest['quest_status_status'] != QUEST_STATUS_COMPLETE) |
|
283 | + if ($quest['quest_status_status'] != QUEST_STATUS_COMPLETE) |
|
284 | 284 | { |
285 | 285 | list($quest_unit_id, $quest_unit_amount) = explode(',', $quest['quest_conditions']); |
286 | 286 | $quest_triggers[$quest_id] = $quest_unit_id; |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | |
293 | 293 | function qst_reward(&$user, &$rewards, &$quest_list) |
294 | 294 | { |
295 | - if(empty($rewards)) return; |
|
295 | + if (empty($rewards)) return; |
|
296 | 296 | |
297 | 297 | global $lang; |
298 | 298 | |
@@ -300,15 +300,15 @@ discard block |
||
300 | 300 | $total_rewards = array(); |
301 | 301 | $comment_dm = ''; |
302 | 302 | |
303 | - foreach($rewards as $quest_id => $user_data) |
|
304 | - foreach($user_data as $user_id => $planet_data) |
|
305 | - foreach($planet_data as $planet_id => $reward_list) |
|
303 | + foreach ($rewards as $quest_id => $user_data) |
|
304 | + foreach ($user_data as $user_id => $planet_data) |
|
305 | + foreach ($planet_data as $planet_id => $reward_list) |
|
306 | 306 | { |
307 | 307 | $comment = sprintf($lang['qst_msg_complete_body'], $quest_list[$quest_id]['quest_name']); |
308 | 308 | $comment_dm .= isset($reward_list[RES_DARK_MATTER]) ? $comment : ''; |
309 | 309 | |
310 | 310 | $comment_reward = array(); |
311 | - foreach($reward_list as $unit_id => $unit_amount) |
|
311 | + foreach ($reward_list as $unit_id => $unit_amount) |
|
312 | 312 | { |
313 | 313 | $comment_reward[] = $unit_amount . ' ' . $lang['tech'][$unit_id]; |
314 | 314 | $total_rewards[$user_id][$planet_id][$unit_id] += $unit_amount; |
@@ -326,23 +326,23 @@ discard block |
||
326 | 326 | |
327 | 327 | $group_resources = sn_get_groups('resources_loot'); |
328 | 328 | $quest_rewards_allowed = sn_get_groups('quest_rewards'); |
329 | - if(!empty($total_rewards)) |
|
329 | + if (!empty($total_rewards)) |
|
330 | 330 | { |
331 | - foreach($total_rewards as $user_id => $planet_data) |
|
331 | + foreach ($total_rewards as $user_id => $planet_data) |
|
332 | 332 | { |
333 | 333 | $user_row = classSupernova::db_get_record_by_id(LOC_USER, $user_id); |
334 | - foreach($planet_data as $planet_id => $unit_data) |
|
334 | + foreach ($planet_data as $planet_id => $unit_data) |
|
335 | 335 | { |
336 | 336 | $local_changeset = array(); |
337 | - foreach($unit_data as $unit_id => $unit_amount) |
|
337 | + foreach ($unit_data as $unit_id => $unit_amount) |
|
338 | 338 | { |
339 | - if(!isset($quest_rewards_allowed[$unit_id])) continue; |
|
339 | + if (!isset($quest_rewards_allowed[$unit_id])) continue; |
|
340 | 340 | |
341 | - if($unit_id == RES_DARK_MATTER) |
|
341 | + if ($unit_id == RES_DARK_MATTER) |
|
342 | 342 | { |
343 | 343 | rpg_points_change($user['id'], RPG_QUEST, $unit_amount, $comment_dm); |
344 | 344 | } |
345 | - elseif(isset($group_resources[$unit_id])) |
|
345 | + elseif (isset($group_resources[$unit_id])) |
|
346 | 346 | { |
347 | 347 | $local_changeset[pname_resource_name($unit_id)] = array('delta' => $unit_amount); |
348 | 348 | } |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | // unit |
354 | 354 | } |
355 | 355 | |
356 | - if(!empty($local_changeset)) |
|
356 | + if (!empty($local_changeset)) |
|
357 | 357 | { |
358 | 358 | $planet_id = $planet_id == 0 && isset($user_row['id_planet']) ? $user_row['id_planet'] : $planet_id; |
359 | 359 | $db_changeset[$planet_id ? 'planets' : 'users'][] = array( |
@@ -1,7 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function qst_render_page() |
|
4 | -{ |
|
3 | +function qst_render_page() { |
|
5 | 4 | global $lang, $user, $template, $config; |
6 | 5 | |
7 | 6 | $user_id = sys_get_param_id('user_id', false); |
@@ -33,8 +32,7 @@ discard block |
||
33 | 32 | if($quest_rewards_amount < 0) |
34 | 33 | { |
35 | 34 | throw new Exception($lang['qst_adm_err_reward_amount']); |
36 | - } |
|
37 | - elseif($quest_rewards_amount > 0) |
|
35 | + } elseif($quest_rewards_amount > 0) |
|
38 | 36 | { |
39 | 37 | $quest_rewards[] = "{$quest_rewards_id},{$quest_rewards_amount}"; |
40 | 38 | } |
@@ -75,8 +73,7 @@ discard block |
||
75 | 73 | `quest_rewards` = '{$quest_rewards}' |
76 | 74 | WHERE `quest_id` = {$quest_id} LIMIT 1;" |
77 | 75 | ); |
78 | - } |
|
79 | - else |
|
76 | + } else |
|
80 | 77 | { |
81 | 78 | sn_db_perform('{{quest}}', array( |
82 | 79 | 'quest_name' => $quest_name, |
@@ -94,8 +91,7 @@ discard block |
||
94 | 91 | msg_send_simple_message('*', 0, 0, MSG_TYPE_PLAYER, $lang['sys_administration'], $lang['news_title'], $text); |
95 | 92 | } |
96 | 93 | */ |
97 | - } |
|
98 | - catch (Exception $e) |
|
94 | + } catch (Exception $e) |
|
99 | 95 | { |
100 | 96 | message($e->getMessage(), $lang['sys_error']); |
101 | 97 | } |
@@ -119,8 +115,7 @@ discard block |
||
119 | 115 | } |
120 | 116 | $query = doquery("SELECT count(*) AS count FROM {{quest}};", '', true); |
121 | 117 | $config->db_saveItem('quest_total', $query['count']); |
122 | - } |
|
123 | - elseif(!$user_id) |
|
118 | + } elseif(!$user_id) |
|
124 | 119 | { |
125 | 120 | $user_id = $user['id']; |
126 | 121 | } |
@@ -137,8 +132,7 @@ discard block |
||
137 | 132 | if($quest) |
138 | 133 | { |
139 | 134 | $quest_templatized = qst_templatize(qst_quest_parse($quest, false)); |
140 | - } |
|
141 | - else |
|
135 | + } else |
|
142 | 136 | { |
143 | 137 | $quest_templatized['quest_rewards_list'] = array(); |
144 | 138 | } |
@@ -181,8 +175,7 @@ discard block |
||
181 | 175 | } |
182 | 176 | } |
183 | 177 | |
184 | -function qst_get_quests($user_id = false, $status = false) |
|
185 | -{ |
|
178 | +function qst_get_quests($user_id = false, $status = false) { |
|
186 | 179 | $quest_list = array(); |
187 | 180 | |
188 | 181 | if($user_id) |
@@ -193,8 +186,7 @@ discard block |
||
193 | 186 | if($status == null) |
194 | 187 | { |
195 | 188 | $query_add_where .= "IS NULL"; |
196 | - } |
|
197 | - else |
|
189 | + } else |
|
198 | 190 | { |
199 | 191 | $query_add_where .= "= {$status}"; |
200 | 192 | } |
@@ -218,13 +210,11 @@ discard block |
||
218 | 210 | return $quest_list; |
219 | 211 | } |
220 | 212 | |
221 | -function qst_assign_to_template(&$template, $quest_templatized, $block_name = false) |
|
222 | -{ |
|
213 | +function qst_assign_to_template(&$template, $quest_templatized, $block_name = false) { |
|
223 | 214 | if($block_name) |
224 | 215 | { |
225 | 216 | $template->assign_block_vars($block_name, $quest_templatized); |
226 | - } |
|
227 | - else |
|
217 | + } else |
|
228 | 218 | { |
229 | 219 | $template->assign_vars($quest_templatized); |
230 | 220 | if(!empty($quest_templatized['quest_rewards_list'])) |
@@ -237,8 +227,7 @@ discard block |
||
237 | 227 | } |
238 | 228 | } |
239 | 229 | |
240 | -function qst_quest_parse($quest) |
|
241 | -{ |
|
230 | +function qst_quest_parse($quest) { |
|
242 | 231 | list($quest['quest_unit_id'], $quest['quest_unit_amount']) = explode(',', $quest['quest_conditions']); |
243 | 232 | |
244 | 233 | $quest['quest_rewards_list'] = sys_unit_str2arr($quest['quest_rewards']); |
@@ -246,8 +235,7 @@ discard block |
||
246 | 235 | return $quest; |
247 | 236 | } |
248 | 237 | |
249 | -function qst_templatize($quest, $for_display = true) |
|
250 | -{ |
|
238 | +function qst_templatize($quest, $for_display = true) { |
|
251 | 239 | global $lang; |
252 | 240 | |
253 | 241 | $tmp = array(); |
@@ -275,8 +263,7 @@ discard block |
||
275 | 263 | ); |
276 | 264 | } |
277 | 265 | |
278 | -function qst_active_triggers($quest_list) |
|
279 | -{ |
|
266 | +function qst_active_triggers($quest_list) { |
|
280 | 267 | $quest_triggers = array(); |
281 | 268 | foreach($quest_list as $quest_id => $quest) |
282 | 269 | { |
@@ -290,9 +277,10 @@ discard block |
||
290 | 277 | return $quest_triggers; |
291 | 278 | } |
292 | 279 | |
293 | -function qst_reward(&$user, &$rewards, &$quest_list) |
|
294 | -{ |
|
295 | - if(empty($rewards)) return; |
|
280 | +function qst_reward(&$user, &$rewards, &$quest_list) { |
|
281 | + if(empty($rewards)) { |
|
282 | + return; |
|
283 | + } |
|
296 | 284 | |
297 | 285 | global $lang; |
298 | 286 | |
@@ -300,11 +288,12 @@ discard block |
||
300 | 288 | $total_rewards = array(); |
301 | 289 | $comment_dm = ''; |
302 | 290 | |
303 | - foreach($rewards as $quest_id => $user_data) |
|
304 | - foreach($user_data as $user_id => $planet_data) |
|
291 | + foreach($rewards as $quest_id => $user_data) { |
|
292 | + foreach($user_data as $user_id => $planet_data) |
|
305 | 293 | foreach($planet_data as $planet_id => $reward_list) |
306 | 294 | { |
307 | 295 | $comment = sprintf($lang['qst_msg_complete_body'], $quest_list[$quest_id]['quest_name']); |
296 | + } |
|
308 | 297 | $comment_dm .= isset($reward_list[RES_DARK_MATTER]) ? $comment : ''; |
309 | 298 | |
310 | 299 | $comment_reward = array(); |
@@ -336,17 +325,17 @@ discard block |
||
336 | 325 | $local_changeset = array(); |
337 | 326 | foreach($unit_data as $unit_id => $unit_amount) |
338 | 327 | { |
339 | - if(!isset($quest_rewards_allowed[$unit_id])) continue; |
|
328 | + if(!isset($quest_rewards_allowed[$unit_id])) { |
|
329 | + continue; |
|
330 | + } |
|
340 | 331 | |
341 | 332 | if($unit_id == RES_DARK_MATTER) |
342 | 333 | { |
343 | 334 | rpg_points_change($user['id'], RPG_QUEST, $unit_amount, $comment_dm); |
344 | - } |
|
345 | - elseif(isset($group_resources[$unit_id])) |
|
335 | + } elseif(isset($group_resources[$unit_id])) |
|
346 | 336 | { |
347 | 337 | $local_changeset[pname_resource_name($unit_id)] = array('delta' => $unit_amount); |
348 | - } |
|
349 | - else // Проверим на юниты |
|
338 | + } else // Проверим на юниты |
|
350 | 339 | { |
351 | 340 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, $unit_amount, $user_row, $planet_id); |
352 | 341 | } |
@@ -372,8 +361,7 @@ discard block |
||
372 | 361 | } |
373 | 362 | } |
374 | 363 | |
375 | -function get_quest_amount_complete($user_id) |
|
376 | -{ |
|
364 | +function get_quest_amount_complete($user_id) { |
|
377 | 365 | // TODO: Make it faster - rewrite SQL? |
378 | 366 | return count(qst_get_quests($user_id, QUEST_STATUS_COMPLETE)); |
379 | 367 | } |
@@ -4,9 +4,9 @@ discard block |
||
4 | 4 | { |
5 | 5 | global $user; |
6 | 6 | |
7 | - if(!empty($ranks)) |
|
7 | + if (!empty($ranks)) |
|
8 | 8 | { |
9 | - foreach($ranks as $rank => $rights) |
|
9 | + foreach ($ranks as $rank => $rights) |
|
10 | 10 | { |
11 | 11 | $rights = implode(',', $rights); |
12 | 12 | $ranklist .= $rights . ';'; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | ORDER BY alliance_diplomacy_time, alliance_diplomacy_id;" |
38 | 38 | ); |
39 | 39 | |
40 | - while($record = db_fetch($query)) |
|
40 | + while ($record = db_fetch($query)) |
|
41 | 41 | { |
42 | 42 | $temp_array[$record['alliance_diplomacy_contr_ally_id']] = $record; |
43 | 43 | } |
@@ -1,7 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function ali_rank_list_save($ranks) |
|
4 | -{ |
|
3 | +function ali_rank_list_save($ranks) { |
|
5 | 4 | global $user; |
6 | 5 | |
7 | 6 | if(!empty($ranks)) |
@@ -17,8 +16,7 @@ discard block |
||
17 | 16 | return $ranklist; |
18 | 17 | } |
19 | 18 | |
20 | -function ali_relations($ally_from, $ally_to = 0) |
|
21 | -{ |
|
19 | +function ali_relations($ally_from, $ally_to = 0) { |
|
22 | 20 | $ally_to = intval($ally_to); |
23 | 21 | $ally_to = $ally_to ? " AND alliance_diplomacy_contr_ally_id = {$ally_to}" : ''; |
24 | 22 | |
@@ -45,8 +43,7 @@ discard block |
||
45 | 43 | return $temp_array; |
46 | 44 | } |
47 | 45 | |
48 | -function ali_relation($ally_from, $ally_to) |
|
49 | -{ |
|
46 | +function ali_relation($ally_from, $ally_to) { |
|
50 | 47 | $relation = ali_relations($ally_from, $ally_to); |
51 | 48 | return empty($relation) ? ALLY_DIPLOMACY_NEUTRAL : $relation[$ally_to]['alliance_diplomacy_relation']; |
52 | 49 | } |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | $template->assign_var('NEWS_COUNT', db_num_rows($announce_list)); |
22 | 22 | |
23 | 23 | $users = array(); |
24 | - while($announce = db_fetch($announce_list)) { |
|
25 | - if($announce['user_id'] && !isset($users[$announce['user_id']])) { |
|
24 | + while ($announce = db_fetch($announce_list)) { |
|
25 | + if ($announce['user_id'] && !isset($users[$announce['user_id']])) { |
|
26 | 26 | $users[$announce['user_id']] = db_user_by_id($announce['user_id']); |
27 | 27 | } |
28 | 28 | |
29 | 29 | $survey_vote = array('survey_vote_id' => 1); |
30 | 30 | $survey_complete = strtotime($announce['survey_until']) < SN_TIME_NOW; |
31 | 31 | |
32 | - if($announce['survey_id'] && !empty($user['id'])) { |
|
32 | + if ($announce['survey_id'] && !empty($user['id'])) { |
|
33 | 33 | $survey_vote = !$survey_complete ? $survey_vote = doquery("SELECT `survey_vote_id` FROM `{{survey_votes}}` WHERE survey_parent_id = {$announce['survey_id']} AND survey_vote_user_id = {$user['id']} LIMIT 1;", true) : array(); |
34 | 34 | } |
35 | 35 | |
@@ -41,8 +41,7 @@ discard block |
||
41 | 41 | 'ANNOUNCE' => cht_message_parse($announce['strAnnounce'], false, intval($announce['authlevel'])), |
42 | 42 | 'DETAIL_URL' => $announce['detail_url'], |
43 | 43 | 'USER_NAME' => |
44 | - isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)): |
|
45 | - js_safe_string($announce['user_name']), |
|
44 | + 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']), |
|
46 | 45 | 'NEW' => $announce['unix_time'] + $config->game_news_actual >= SN_TIME_NOW, |
47 | 46 | 'FUTURE' => $announce['unix_time'] > SN_TIME_NOW, |
48 | 47 | 'SURVEY_ID' => $announce['survey_id'], |
@@ -52,13 +51,13 @@ discard block |
||
52 | 51 | 'SURVEY_UNTIL' => $announce['survey_until'], |
53 | 52 | )); |
54 | 53 | |
55 | - foreach($announce_exploded as $announce_paragraph) { |
|
54 | + foreach ($announce_exploded as $announce_paragraph) { |
|
56 | 55 | $template->assign_block_vars('announces.paragraph', array( |
57 | 56 | 'TEXT' => $announce_paragraph, |
58 | 57 | )); |
59 | 58 | } |
60 | 59 | |
61 | - if($announce['survey_id']) { |
|
60 | + if ($announce['survey_id']) { |
|
62 | 61 | $survey_query = doquery( |
63 | 62 | "SELECT survey_answer_text AS `TEXT`, count(DISTINCT survey_vote_id) AS `VOTES` |
64 | 63 | FROM `{{survey_answers}}` AS sa |
@@ -69,15 +68,15 @@ discard block |
||
69 | 68 | ); |
70 | 69 | $survey_vote_result = array(); |
71 | 70 | $total_votes = 0; |
72 | - while($row = db_fetch($survey_query)) { |
|
71 | + while ($row = db_fetch($survey_query)) { |
|
73 | 72 | $survey_vote_result[] = $row; |
74 | 73 | $total_votes += $row['VOTES']; |
75 | 74 | } |
76 | 75 | |
77 | - if(empty($survey_vote) && !$survey_complete) { |
|
76 | + if (empty($survey_vote) && !$survey_complete) { |
|
78 | 77 | // Can vote |
79 | 78 | $survey_query = doquery("SELECT * FROM {{survey_answers}} WHERE survey_parent_id = {$announce['survey_id']} ORDER BY survey_answer_id;"); |
80 | - while($row = db_fetch($survey_query)) { |
|
79 | + while ($row = db_fetch($survey_query)) { |
|
81 | 80 | $template->assign_block_vars('announces.survey_answers', array( |
82 | 81 | 'ID' => $row['survey_answer_id'], |
83 | 82 | 'TEXT' => $row['survey_answer_text'], |
@@ -85,7 +84,7 @@ discard block |
||
85 | 84 | } |
86 | 85 | } else { |
87 | 86 | // Show result |
88 | - foreach($survey_vote_result as &$vote_result) { |
|
87 | + foreach ($survey_vote_result as &$vote_result) { |
|
89 | 88 | $vote_percent = $total_votes ? $vote_result['VOTES'] / $total_votes * 100 : 0; |
90 | 89 | $vote_result['PERCENT'] = $vote_percent; |
91 | 90 | $vote_result['PERCENT_TEXT'] = round($vote_percent, 1); |
@@ -102,7 +101,7 @@ discard block |
||
102 | 101 | } |
103 | 102 | |
104 | 103 | function nws_mark_read(&$user) { |
105 | - if(isset($user['id'])) { |
|
104 | + if (isset($user['id'])) { |
|
106 | 105 | db_user_set_by_id($user['id'], '`news_lastread` = ' . SN_TIME_NOW); |
107 | 106 | $user['news_lastread'] = SN_TIME_NOW; |
108 | 107 | } |
@@ -110,17 +109,17 @@ discard block |
||
110 | 109 | } |
111 | 110 | |
112 | 111 | function survey_vote(&$user) { |
113 | - if(empty($user['id'])) { |
|
112 | + if (empty($user['id'])) { |
|
114 | 113 | return true; |
115 | 114 | } |
116 | 115 | |
117 | 116 | sn_db_transaction_start(); |
118 | 117 | $survey_id = sys_get_param_id('survey_id'); |
119 | 118 | $is_voted = doquery("SELECT `survey_vote_id` FROM `{{survey_votes}}` WHERE survey_parent_id = {$survey_id} AND survey_vote_user_id = {$user['id']} FOR UPDATE;", true); |
120 | - if(empty($is_voted)) { |
|
119 | + if (empty($is_voted)) { |
|
121 | 120 | $survey_vote_id = sys_get_param_id('survey_vote'); |
122 | 121 | $is_answer_exists = doquery("SELECT `survey_answer_id` FROM `{{survey_answers}}` WHERE survey_parent_id = {$survey_id} AND survey_answer_id = {$survey_vote_id};", true); |
123 | - if(!empty($is_answer_exists)) { |
|
122 | + if (!empty($is_answer_exists)) { |
|
124 | 123 | $user_name_safe = db_escape($user['username']); |
125 | 124 | doquery("INSERT INTO {{survey_votes}} SET `survey_parent_id` = {$survey_id}, `survey_parent_answer_id` = {$survey_vote_id}, `survey_vote_user_id` = {$user['id']}, `survey_vote_user_name` = '{$user_name_safe}';"); |
126 | 125 | } |