@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | //while($CurrentFleet = db_fetch($FlyingFleets)) |
22 | 22 | |
23 | 23 | $all_flying_fleets = db_fleet_list('', DB_SELECT_PLAIN); |
24 | -foreach($all_flying_fleets as $fleet_id => $CurrentFleet) { |
|
24 | +foreach ($all_flying_fleets as $fleet_id => $CurrentFleet) { |
|
25 | 25 | $FleetOwner = db_user_by_id($CurrentFleet['fleet_owner']); |
26 | 26 | $TargetOwner = db_user_by_id($CurrentFleet['fleet_target_owner']); |
27 | 27 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $fleet_data['fleet']['STAY_TIME_INT'] = $CurrentFleet['fleet_end_stay']; |
33 | 33 | |
34 | 34 | $template->assign_block_vars('fleets', $fleet_data['fleet']); |
35 | - foreach($fleet_data['ships'] as $ship_data) { |
|
35 | + foreach ($fleet_data['ships'] as $ship_data) { |
|
36 | 36 | $template->assign_block_vars('fleets.ships', $ship_data); |
37 | 37 | } |
38 | 38 | } |
@@ -19,13 +19,13 @@ discard block |
||
19 | 19 | // define('SESSION_INTERRUPT', 15*60); // Можно увеличить до 4 часов - никито не может сидеть 2 суток с перерывом менее 4 часов |
20 | 20 | // define('SUSPICIOUS_LONG', 2 * 60*60); // Тогда это увеличиваем до, скажем суток - и там смотрим |
21 | 21 | |
22 | -define('SESSION_INTERRUPT', 1 * 60*60); // Можно увеличить до 4 часов - никито не может сидеть 2 суток с перерывом менее 4 часов |
|
23 | -define('SUSPICIOUS_LONG', 16 * 60*60); // Тогда это увеличиваем до, скажем суток - и там смотрим |
|
22 | +define('SESSION_INTERRUPT', 1 * 60 * 60); // Можно увеличить до 4 часов - никито не может сидеть 2 суток с перерывом менее 4 часов |
|
23 | +define('SUSPICIOUS_LONG', 16 * 60 * 60); // Тогда это увеличиваем до, скажем суток - и там смотрим |
|
24 | 24 | |
25 | 25 | |
26 | 26 | function check_suspicious(&$session, &$session_list_last_id, &$row) { |
27 | 27 | $session[2] = $session[1] - $session[0]; |
28 | - if($session[2] > SUSPICIOUS_LONG) |
|
28 | + if ($session[2] > SUSPICIOUS_LONG) |
|
29 | 29 | { |
30 | 30 | $session[2] = pretty_time($session[2]); |
31 | 31 | $session[0] = date(FMT_DATE_TIME_SQL, $session[0]); |
@@ -46,24 +46,24 @@ discard block |
||
46 | 46 | $session_list = array(); |
47 | 47 | $query = doquery("SELECT `visit_time`, user_id FROM {{counter}} where user_id <> 0 and visit_time > UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 7 DAY)) order by user_id, visit_time;"); |
48 | 48 | $session = array(); |
49 | -if($row = db_fetch($query)) { |
|
49 | +if ($row = db_fetch($query)) { |
|
50 | 50 | $session = array( |
51 | 51 | 0 => strtotime($row['visit_time']), // start |
52 | 52 | 1 => strtotime($row['visit_time']), // end |
53 | 53 | ); |
54 | 54 | $last_id = $row['user_id']; |
55 | 55 | } |
56 | -while($row = db_fetch($query)) { |
|
56 | +while ($row = db_fetch($query)) { |
|
57 | 57 | $row['visit_time'] = strtotime($row['visit_time']); |
58 | - if($last_id == $row['user_id']) { |
|
58 | + if ($last_id == $row['user_id']) { |
|
59 | 59 | // Тот же юзер |
60 | - if($row['visit_time'] - $session[1] <= SESSION_INTERRUPT) { // Та же сессия |
|
60 | + if ($row['visit_time'] - $session[1] <= SESSION_INTERRUPT) { // Та же сессия |
|
61 | 61 | $session[1] = $row['visit_time']; |
62 | 62 | } else { |
63 | 63 | // Новая сессия |
64 | 64 | // check_suspicious($session, $session_list[$last_id], $row); |
65 | 65 | $session[2] = $session[1] - $session[0]; |
66 | - if($session[2] > SUSPICIOUS_LONG) |
|
66 | + if ($session[2] > SUSPICIOUS_LONG) |
|
67 | 67 | { |
68 | 68 | $session[2] = pretty_time($session[2]); |
69 | 69 | $session[0] = date(FMT_DATE_TIME_SQL, $session[0]); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | } else { |
79 | 79 | // check_suspicious($session, $session_list[$last_id], $row); |
80 | 80 | $session[2] = $session[1] - $session[0]; |
81 | - if($session[2] > SUSPICIOUS_LONG) |
|
81 | + if ($session[2] > SUSPICIOUS_LONG) |
|
82 | 82 | { |
83 | 83 | $session[2] = pretty_time($session[2]); |
84 | 84 | $session[0] = date(FMT_DATE_TIME_SQL, $session[0]); |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | -if($last_id) { |
|
96 | +if ($last_id) { |
|
97 | 97 | // check_suspicious($session, $session_list[$last_id], $row = array('time' => 0)); |
98 | 98 | $session[2] = $session[1] - $session[0]; |
99 | 99 | |
100 | - if($session[2] > SUSPICIOUS_LONG) |
|
100 | + if ($session[2] > SUSPICIOUS_LONG) |
|
101 | 101 | { |
102 | 102 | $session[2] = pretty_time($session[2]); |
103 | 103 | $session[0] = date(FMT_DATE_TIME_SQL, $session[0]); |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | print("<td>ID</td><td>Username</td><td>Start</td><td>End</td><td>Length</td>"); |
112 | 112 | print("<td>Last online</td>"); |
113 | 113 | print("</tr>"); |
114 | -foreach($session_list as $user_id => $value) { |
|
114 | +foreach ($session_list as $user_id => $value) { |
|
115 | 115 | $user_record = doquery("SELECT `username`, onlinetime FROM {{users}} WHERE id = {$user_id};", true); |
116 | - foreach($value as $interval_data) { |
|
116 | + foreach ($value as $interval_data) { |
|
117 | 117 | print("<tr>"); |
118 | 118 | print("<td>{$user_id}</td><td>{$user_record['username']}</td><td>{$interval_data[0]}</td><td>{$interval_data[1]}</td><td>{$interval_data[2]}</td>"); |
119 | 119 | print("<td>" . date(FMT_DATE_TIME_SQL, $user_record['onlinetime']) . "</td>"); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | $mip_data = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET); |
15 | 15 | $MIPDamage = floor(mrc_modify_value($attackerTech, false, TECH_WEAPON, $MIPs * $mip_data[P_ATTACK] * mt_rand(80, 120) / 100)); |
16 | - foreach($structures as $key => $structure) |
|
16 | + foreach ($structures as $key => $structure) |
|
17 | 17 | { |
18 | 18 | $unit_info = get_unit_param($key); |
19 | 19 | $amplify = isset($mip_data[P_AMPLIFY][$key]) ? $mip_data[P_AMPLIFY][$key] : 1; |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | { |
32 | 32 | //attacking only selected structure |
33 | 33 | $damageDone = $structures[$targetedStructure][$damageTo]; |
34 | - $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] ); |
|
34 | + $structsDestroyed = min(floor($MIPDamage / $damageDone), $structures[$targetedStructure][0]); |
|
35 | 35 | $structures[$targetedStructure][0] -= $structsDestroyed; |
36 | - $MIPDamage -= $structsDestroyed*$damageDone; |
|
36 | + $MIPDamage -= $structsDestroyed * $damageDone; |
|
37 | 37 | } |
38 | 38 | else |
39 | 39 | { |
@@ -44,16 +44,16 @@ discard block |
||
44 | 44 | do |
45 | 45 | { |
46 | 46 | // finding is there any structure that can be damaged with leftovers of $MIPDamage |
47 | - foreach($can_be_damaged as $key => $unit_id) |
|
47 | + foreach ($can_be_damaged as $key => $unit_id) |
|
48 | 48 | { |
49 | 49 | //debug($structures[$unit_id][0]); |
50 | 50 | //debug($structures[$unit_id][$damageTo], $MIPDamage); |
51 | - if($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage) |
|
51 | + if ($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage) |
|
52 | 52 | { |
53 | 53 | unset($can_be_damaged[$key]); |
54 | 54 | } |
55 | 55 | } |
56 | - if(empty($can_be_damaged)) |
|
56 | + if (empty($can_be_damaged)) |
|
57 | 57 | { |
58 | 58 | break; |
59 | 59 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | //debug($destroyed, 'Actually destroyed'); |
73 | 73 | |
74 | 74 | //print('<hr>'); |
75 | - } while($MIPDamage > 0 && !empty($can_be_damaged)); |
|
75 | + } while ($MIPDamage > 0 && !empty($can_be_damaged)); |
|
76 | 76 | //debug($MIPDamage, 'MIPDamage left'); |
77 | 77 | } |
78 | 78 | //debug($structures);//die(); |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | $crystal += $destroyed * $unit_info[P_COST][RES_CRYSTAL] / 4; |
88 | 88 | } |
89 | 89 | |
90 | - $return['structures'] = $structures; // Structures left after attack |
|
91 | - $return['metal'] = floor($metal); // Metal scraps |
|
90 | + $return['structures'] = $structures; // Structures left after attack |
|
91 | + $return['metal'] = floor($metal); // Metal scraps |
|
92 | 92 | $return['crystal'] = floor($crystal); // Crystal scraps |
93 | 93 | |
94 | 94 | return $return; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | $iraks = doquery("SELECT * FROM {{iraks}} WHERE `fleet_end_time` <= " . SN_TIME_NOW . " FOR UPDATE;"); |
114 | 114 | |
115 | - while($fleetRow = db_fetch($iraks)) { |
|
115 | + while ($fleetRow = db_fetch($iraks)) { |
|
116 | 116 | set_time_limit(15); |
117 | 117 | $db_changeset = array(); |
118 | 118 | |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | |
129 | 129 | $rowAttacker = db_user_by_id($fleetRow['fleet_owner'], true); |
130 | 130 | |
131 | - if($target_planet_row['id']) { |
|
131 | + if ($target_planet_row['id']) { |
|
132 | 132 | $planetDefense = array(); |
133 | - foreach(sn_get_groups('defense_active') as $unit_id) { |
|
133 | + foreach (sn_get_groups('defense_active') as $unit_id) { |
|
134 | 134 | $planetDefense[$unit_id] = array(mrc_get_level($targetUser, $target_planet_row, $unit_id, true, true)); |
135 | 135 | } |
136 | 136 | |
@@ -141,23 +141,23 @@ discard block |
||
141 | 141 | $message = $lang['mip_all_destroyed']; |
142 | 142 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit(UNIT_DEF_MISSILE_INTERCEPTOR, -$missiles, $targetUser, $target_planet_row['id']); |
143 | 143 | } else { |
144 | - if($interceptors) { |
|
144 | + if ($interceptors) { |
|
145 | 145 | $message = sprintf($lang['mip_destroyed'], $interceptors); |
146 | 146 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit(UNIT_DEF_MISSILE_INTERCEPTOR, -$interceptors, $targetUser, $target_planet_row['id']); |
147 | 147 | } |
148 | 148 | |
149 | 149 | $attackResult = COE_missileAttack($targetUser, $rowAttacker, $missiles - $interceptors, $planetDefense, $fleetRow['primaer']); |
150 | 150 | |
151 | - foreach($attackResult['structures'] as $key => $structure) { |
|
151 | + foreach ($attackResult['structures'] as $key => $structure) { |
|
152 | 152 | $destroyed = $planetDefense[$key][0] - $structure[0]; |
153 | - if($destroyed) { |
|
153 | + if ($destroyed) { |
|
154 | 154 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($key, -$destroyed, $targetUser, $target_planet_row['id']); |
155 | 155 | |
156 | 156 | $message .= " {$lang['tech'][$key]} - {$destroyed} {$lang['quantity']}<br>"; |
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
160 | - if(!empty($message)) { |
|
160 | + if (!empty($message)) { |
|
161 | 161 | $message = $lang['mip_defense_destroyed'] . $message . "{$lang['mip_recycled']}{$lang['Metal']}: {$attackResult['metal']}, {$lang['Crystal']}: {$attackResult['crystal']}<br>"; |
162 | 162 | |
163 | 163 | DBStaticPlanet::db_planet_set_by_id($target_planet_row['id'], "`metal` = `metal` + {$attackResult['metal']}, `crystal` = `crystal` + {$attackResult['crystal']}"); |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | |
175 | 175 | empty($message) ? $message = $lang['mip_no_defense'] : false; |
176 | 176 | |
177 | - msg_send_simple_message ( $fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message ); |
|
178 | - msg_send_simple_message ( $fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message ); |
|
177 | + msg_send_simple_message($fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message); |
|
178 | + msg_send_simple_message($fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message); |
|
179 | 179 | } |
180 | 180 | doquery("DELETE FROM {{iraks}} WHERE id = '{$fleetRow['id']}';"); |
181 | 181 | } |
@@ -186,11 +186,11 @@ |
||
186 | 186 | } |
187 | 187 | |
188 | 188 | $exclude = $user_row; |
189 | - foreach($blocks as $title => $fields) { |
|
189 | + foreach ($blocks as $title => $fields) { |
|
190 | 190 | userBlockAssign($exclude, $template, $title, $fields); |
191 | 191 | } |
192 | 192 | |
193 | - if(!empty($exclude)) { |
|
193 | + if (!empty($exclude)) { |
|
194 | 194 | userBlockAssign($exclude, $template, '!!! НЕИЗВЕСТНЫЕ ПАРАМЕТРЫ !!!', array_keys($exclude)); |
195 | 195 | } |
196 | 196 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @copyright 2008-2015 Gorlum for Project "SuperNova.WS" |
6 | 6 | */ |
7 | 7 | |
8 | -if(!defined('INSIDE')) { |
|
8 | +if (!defined('INSIDE')) { |
|
9 | 9 | die(); |
10 | 10 | } |
11 | 11 | |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | function db_change_units_perform($query, $tablename, $object_id) { |
15 | 15 | $query = implode(',', $query); |
16 | - if($query && $object_id) { |
|
16 | + if ($query && $object_id) { |
|
17 | 17 | return classSupernova::db_upd_record_by_id($tablename == 'users' ? LOC_USER : LOC_PLANET, $object_id, $query); |
18 | 18 | } |
19 | 19 | } |
@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | |
30 | 30 | $group = sn_get_groups('resources_loot'); |
31 | 31 | |
32 | - foreach($unit_list as $unit_id => $unit_amount) { |
|
33 | - if(!in_array($unit_id, $group)) { |
|
32 | + foreach ($unit_list as $unit_id => $unit_amount) { |
|
33 | + if (!in_array($unit_id, $group)) { |
|
34 | 34 | // TODO - remove later |
35 | 35 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: db_change_units() вызван для не-ресурсов!</h1>'); |
36 | 36 | pdump(debug_backtrace()); |
37 | 37 | die('db_change_units() вызван для не-ресурсов!'); |
38 | 38 | } |
39 | 39 | |
40 | - if(!$unit_amount) { |
|
40 | + if (!$unit_amount) { |
|
41 | 41 | continue; |
42 | 42 | } |
43 | 43 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $unit_location = sys_get_unit_location($user, $planet, $unit_id); |
47 | 47 | |
48 | 48 | // Changing value in object |
49 | - switch($unit_location) { |
|
49 | + switch ($unit_location) { |
|
50 | 50 | case LOC_USER: |
51 | 51 | $user[$unit_db_name] += $unit_amount; |
52 | 52 | break; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | global $lang; |
4 | 4 | |
5 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
5 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
6 | 6 | { |
7 | 7 | $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
8 | 8 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | $page = gettemplate('ali_admin_mail', true); |
21 | 21 | |
22 | 22 | if ($ranks) { |
23 | - foreach($ranks as $id => $array) { |
|
23 | + foreach ($ranks as $id => $array) { |
|
24 | 24 | $page->assign_block_vars('ranks', array( |
25 | 25 | 'NAME' => $array['name'], |
26 | 26 | 'VALUE' => $id, |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('IN_UPDATE')) { |
|
3 | +if (!defined('IN_UPDATE')) { |
|
4 | 4 | die('Trying to call update helpers externally!'); |
5 | 5 | } |
6 | 6 | |
@@ -8,12 +8,12 @@ discard block |
||
8 | 8 | global $update_tables; |
9 | 9 | |
10 | 10 | upd_add_more_time(); |
11 | - if(!$no_log) { |
|
11 | + if (!$no_log) { |
|
12 | 12 | upd_log_message("Performing query '{$query}'"); |
13 | 13 | } |
14 | 14 | |
15 | - if(strpos($query, '{{') !== false) { |
|
16 | - foreach($update_tables as $tableName => $cork) { |
|
15 | + if (strpos($query, '{{') !== false) { |
|
16 | + foreach ($update_tables as $tableName => $cork) { |
|
17 | 17 | $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix . $tableName, $query); |
18 | 18 | } |
19 | 19 | } |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | global $config, $sys_log_disabled; |
26 | 26 | |
27 | 27 | $config->db_loadItem($key); |
28 | - if($condition || !isset($config->$key)) { |
|
28 | + if ($condition || !isset($config->$key)) { |
|
29 | 29 | upd_add_more_time(); |
30 | - if(!$sys_log_disabled) { |
|
30 | + if (!$sys_log_disabled) { |
|
31 | 31 | upd_log_message("Updating config key '{$key}' with value '{$default_value}'"); |
32 | 32 | } |
33 | 33 | $config->db_saveItem($key, $default_value); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | function upd_log_message($message) { |
56 | 56 | global $sys_log_disabled, $upd_log, $debug; |
57 | 57 | |
58 | - if($sys_log_disabled) |
|
58 | + if ($sys_log_disabled) |
|
59 | 59 | { |
60 | 60 | // print("{$message}<br />"); |
61 | 61 | } else { |
@@ -67,15 +67,15 @@ discard block |
||
67 | 67 | function upd_unset_table_info($table_name) { |
68 | 68 | global $update_tables, $update_indexes, $update_foreigns; |
69 | 69 | |
70 | - if(isset($update_tables[$table_name])) { |
|
70 | + if (isset($update_tables[$table_name])) { |
|
71 | 71 | unset($update_tables[$table_name]); |
72 | 72 | } |
73 | 73 | |
74 | - if(isset($update_indexes[$table_name])) { |
|
74 | + if (isset($update_indexes[$table_name])) { |
|
75 | 75 | unset($update_indexes[$table_name]); |
76 | 76 | } |
77 | 77 | |
78 | - if(isset($update_foreigns[$table_name])) { |
|
78 | + if (isset($update_foreigns[$table_name])) { |
|
79 | 79 | unset($update_foreigns[$table_name]); |
80 | 80 | } |
81 | 81 | } |
@@ -89,18 +89,18 @@ discard block |
||
89 | 89 | upd_unset_table_info($tableName); |
90 | 90 | |
91 | 91 | $q1 = upd_do_query("SHOW FULL COLUMNS FROM {$prefix_table_name};", true); |
92 | - while($r1 = db_fetch($q1)) { |
|
92 | + while ($r1 = db_fetch($q1)) { |
|
93 | 93 | $update_tables[$tableName][$r1['Field']] = $r1; |
94 | 94 | } |
95 | 95 | |
96 | 96 | $q1 = upd_do_query("SHOW INDEX FROM {$prefix_table_name};", true); |
97 | - while($r1 = db_fetch($q1)) { |
|
97 | + while ($r1 = db_fetch($q1)) { |
|
98 | 98 | $update_indexes[$tableName][$r1['Key_name']] .= "{$r1['Column_name']},"; |
99 | 99 | $update_indexes_full[$tableName][$r1['Key_name']][$r1['Column_name']] = $r1; |
100 | 100 | } |
101 | 101 | |
102 | - $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name). "' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true); |
|
103 | - while($r1 = db_fetch($q1)) { |
|
102 | + $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true); |
|
103 | + while ($r1 = db_fetch($q1)) { |
|
104 | 104 | $table_referenced = str_replace($config->db_prefix, '', $r1['REFERENCED_TABLE_NAME']); |
105 | 105 | |
106 | 106 | $update_foreigns[$tableName][$r1['CONSTRAINT_NAME']] .= "{$r1['COLUMN_NAME']},{$table_referenced},{$r1['REFERENCED_COLUMN_NAME']};"; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | function upd_alter_table($table, $alters, $condition = true) { |
111 | 111 | global $config, $update_tables; |
112 | 112 | |
113 | - if(!$condition) { |
|
113 | + if (!$condition) { |
|
114 | 114 | return; |
115 | 115 | } |
116 | 116 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $alters_print = is_array($alters) ? dump($alters) : $alters; |
119 | 119 | upd_log_message("Altering table '{$table}' with alterations {$alters_print}"); |
120 | 120 | |
121 | - if(!is_array($alters)) { |
|
121 | + if (!is_array($alters)) { |
|
122 | 122 | $alters = array($alters); |
123 | 123 | } |
124 | 124 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | |
129 | 129 | $result = upd_do_query($qry); |
130 | 130 | $error = db_error(); |
131 | - if($error) { |
|
131 | + if ($error) { |
|
132 | 132 | die("Altering error for table `{$table}`: {$error}<br />{$alters_print}"); |
133 | 133 | } |
134 | 134 | |
@@ -155,19 +155,19 @@ discard block |
||
155 | 155 | function upd_create_table($table_name, $declaration, $tableOptions = '') { |
156 | 156 | global $config, $update_tables; |
157 | 157 | |
158 | - if(!$update_tables[$table_name]) { |
|
158 | + if (!$update_tables[$table_name]) { |
|
159 | 159 | upd_do_query('set foreign_key_checks = 0;', true); |
160 | 160 | $declaration = trim($declaration); |
161 | - if(substr($declaration, 0, 1) != '(') { |
|
161 | + if (substr($declaration, 0, 1) != '(') { |
|
162 | 162 | $declaration = "($declaration)"; |
163 | 163 | } |
164 | 164 | $tableOptions = trim($tableOptions); |
165 | - if(!empty($tableOptions)) { |
|
165 | + if (!empty($tableOptions)) { |
|
166 | 166 | $declaration .= $tableOptions; |
167 | 167 | } |
168 | 168 | $result = upd_do_query("CREATE TABLE IF NOT EXISTS `{$config->db_prefix}{$table_name}` {$declaration}"); |
169 | 169 | $error = db_error(); |
170 | - if($error) { |
|
170 | + if ($error) { |
|
171 | 171 | die("Creating error for table `{$table_name}`: {$error}<br />" . dump($declaration)); |
172 | 172 | } |
173 | 173 | upd_do_query('set foreign_key_checks = 1;', true); |
@@ -193,14 +193,14 @@ discard block |
||
193 | 193 | |
194 | 194 | |
195 | 195 | function upd_db_unit_changeset_prepare($unit_id, $unit_value, $user, $planet_id = null) { |
196 | - if(!is_array($user)) { |
|
196 | + if (!is_array($user)) { |
|
197 | 197 | // TODO - remove later |
198 | 198 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: upd_db_unit_changeset_prepare() - USER is not ARRAY</h1>'); |
199 | 199 | pdump(debug_backtrace()); |
200 | 200 | die('USER is not ARRAY'); |
201 | 201 | } |
202 | 202 | |
203 | - if(!isset($user['id']) || !$user['id']) { |
|
203 | + if (!isset($user['id']) || !$user['id']) { |
|
204 | 204 | // TODO - remove later |
205 | 205 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: upd_db_unit_changeset_prepare() - USER[id] пустой</h1>'); |
206 | 206 | pdump($user); |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | |
216 | 216 | $db_changeset = array(); |
217 | 217 | $temp = upd_db_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id'); |
218 | - if($temp['unit_id']) { |
|
218 | + if ($temp['unit_id']) { |
|
219 | 219 | // update |
220 | 220 | $db_changeset = array( |
221 | 221 | 'action' => SQL_OP_UPDATE, |
@@ -261,53 +261,53 @@ discard block |
||
261 | 261 | |
262 | 262 | |
263 | 263 | function upd_db_changeset_apply($db_changeset) { |
264 | - if(!is_array($db_changeset) || empty($db_changeset)) { |
|
264 | + if (!is_array($db_changeset) || empty($db_changeset)) { |
|
265 | 265 | return; |
266 | 266 | } |
267 | 267 | |
268 | - foreach($db_changeset as $table_name => $table_data) { |
|
269 | - foreach($table_data as $record_id => $conditions) { |
|
268 | + foreach ($db_changeset as $table_name => $table_data) { |
|
269 | + foreach ($table_data as $record_id => $conditions) { |
|
270 | 270 | $where = ''; |
271 | - if(!empty($conditions['where'])) { |
|
271 | + if (!empty($conditions['where'])) { |
|
272 | 272 | $where = 'WHERE ' . implode(' AND ', $conditions['where']); |
273 | 273 | } |
274 | 274 | |
275 | 275 | $fields = array(); |
276 | - if($conditions['fields']) { |
|
277 | - foreach($conditions['fields'] as $field_name => $field_data) { |
|
276 | + if ($conditions['fields']) { |
|
277 | + foreach ($conditions['fields'] as $field_name => $field_data) { |
|
278 | 278 | $condition = "`{$field_name}` = "; |
279 | 279 | $value = ''; |
280 | - if($field_data['delta']) { |
|
280 | + if ($field_data['delta']) { |
|
281 | 281 | $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; |
282 | - } elseif($field_data['set']) { |
|
283 | - $value = (is_string($field_data['set']) ? "'{$field_data['set']}'": $field_data['set']); |
|
282 | + } elseif ($field_data['set']) { |
|
283 | + $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); |
|
284 | 284 | } |
285 | - if($value) { |
|
285 | + if ($value) { |
|
286 | 286 | $fields[] = $condition . $value; |
287 | 287 | } |
288 | 288 | } |
289 | 289 | } |
290 | 290 | $fields = implode(',', $fields); |
291 | 291 | |
292 | - switch($conditions['action']) { |
|
292 | + switch ($conditions['action']) { |
|
293 | 293 | case SQL_OP_DELETE: |
294 | 294 | upd_do_query("DELETE FROM {{{$table_name}}} {$where}"); |
295 | 295 | break; |
296 | 296 | |
297 | 297 | case SQL_OP_UPDATE: |
298 | - if($fields) { |
|
298 | + if ($fields) { |
|
299 | 299 | upd_do_query("UPDATE {{{$table_name}}} SET {$fields} {$where}"); |
300 | 300 | } |
301 | 301 | break; |
302 | 302 | |
303 | 303 | case SQL_OP_INSERT: |
304 | - if($fields) { |
|
304 | + if ($fields) { |
|
305 | 305 | upd_do_query("INSERT INTO {{{$table_name}}} SET {$fields}"); |
306 | 306 | } |
307 | 307 | break; |
308 | 308 | |
309 | 309 | case SQL_OP_REPLACE: |
310 | - if($fields) { |
|
310 | + if ($fields) { |
|
311 | 311 | upd_do_query("REPLACE INTO {{{$table_name}}} SET {$fields}"); |
312 | 312 | } |
313 | 313 | break; |
@@ -14,39 +14,39 @@ discard block |
||
14 | 14 | |
15 | 15 | lng_include('fleet'); |
16 | 16 | |
17 | -if($TargetPlanet = sys_get_param_id('jmpto')) |
|
17 | +if ($TargetPlanet = sys_get_param_id('jmpto')) |
|
18 | 18 | { |
19 | 19 | sn_db_transaction_start(); |
20 | 20 | db_user_by_id($user['id'], true, 'id'); |
21 | 21 | $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true); |
22 | - if(!($NextJumpTime = uni_get_time_to_jump($planetrow))) |
|
22 | + if (!($NextJumpTime = uni_get_time_to_jump($planetrow))) |
|
23 | 23 | { |
24 | 24 | $TargetGate = DBStaticPlanet::db_planet_by_id($TargetPlanet, true, '`id`, `last_jump_time`'); |
25 | - if(mrc_get_level($user, $TargetGate, STRUC_MOON_GATE) > 0) |
|
25 | + if (mrc_get_level($user, $TargetGate, STRUC_MOON_GATE) > 0) |
|
26 | 26 | { |
27 | - $NextDestTime = uni_get_time_to_jump ( $TargetGate ); |
|
28 | - if(!$NextDestTime) |
|
27 | + $NextDestTime = uni_get_time_to_jump($TargetGate); |
|
28 | + if (!$NextDestTime) |
|
29 | 29 | { |
30 | 30 | // $SubQueryOri = ""; |
31 | 31 | // $SubQueryDes = ""; |
32 | 32 | $ship_list = sys_get_param('ships'); |
33 | 33 | $db_changeset = array(); |
34 | - foreach($ship_list as $ship_id => $ship_count) |
|
34 | + foreach ($ship_list as $ship_id => $ship_count) |
|
35 | 35 | { |
36 | - if(!in_array($ship_id, sn_get_groups('fleet'))) |
|
36 | + if (!in_array($ship_id, sn_get_groups('fleet'))) |
|
37 | 37 | { |
38 | 38 | continue; |
39 | 39 | } |
40 | 40 | |
41 | 41 | $ship_count = max(0, min(floor($ship_count), mrc_get_level($user, $planetrow, $ship_id))); |
42 | - if($ship_count) |
|
42 | + if ($ship_count) |
|
43 | 43 | { |
44 | 44 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($ship_id, -$ship_count, $user, $planetrow['id']); |
45 | 45 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($ship_id, $ship_count, $user, $TargetGate['id']); |
46 | 46 | } |
47 | 47 | } |
48 | 48 | // Dit monsieur, y avait quelque chose a envoyer ??? |
49 | - if(!empty($db_changeset)) |
|
49 | + if (!empty($db_changeset)) |
|
50 | 50 | { |
51 | 51 | DBStaticPlanet::db_planet_set_by_id($TargetGate['id'], "`last_jump_time` = " . SN_TIME_NOW . ""); |
52 | 52 | DBStaticPlanet::db_planet_set_by_id($planetrow['id'], "`last_jump_time` = " . SN_TIME_NOW . ""); |
@@ -55,31 +55,31 @@ discard block |
||
55 | 55 | db_user_set_by_id($user['id'], "`current_planet` = '{$TargetGate['id']}'"); |
56 | 56 | |
57 | 57 | $planetrow['last_jump_time'] = SN_TIME_NOW; |
58 | - $RetMessage = $lang['gate_jump_done'] ." - ". pretty_time(uni_get_time_to_jump($planetrow)); |
|
58 | + $RetMessage = $lang['gate_jump_done'] . " - " . pretty_time(uni_get_time_to_jump($planetrow)); |
|
59 | 59 | } else { |
60 | 60 | $RetMessage = $lang['gate_wait_data']; |
61 | 61 | } |
62 | 62 | } else { |
63 | - $RetMessage = $lang['gate_wait_dest'] ." - ". pretty_time($NextDestTime); |
|
63 | + $RetMessage = $lang['gate_wait_dest'] . " - " . pretty_time($NextDestTime); |
|
64 | 64 | } |
65 | 65 | } else { |
66 | 66 | $RetMessage = $lang['gate_no_dest_g']; |
67 | 67 | } |
68 | 68 | } else { |
69 | - $RetMessage = $lang['gate_wait_star'] ." - ". pretty_time($NextJumpTime); |
|
69 | + $RetMessage = $lang['gate_wait_star'] . " - " . pretty_time($NextJumpTime); |
|
70 | 70 | } |
71 | 71 | sn_db_transaction_commit(); |
72 | 72 | messageBox($RetMessage, $lang['tech'][STRUC_MOON_GATE], "jumpgate.php", 10); |
73 | 73 | } else { |
74 | 74 | $template = gettemplate('jumpgate', true); |
75 | - if(mrc_get_level($user, $planetrow, STRUC_MOON_GATE) > 0) |
|
75 | + if (mrc_get_level($user, $planetrow, STRUC_MOON_GATE) > 0) |
|
76 | 76 | { |
77 | 77 | $Combo = ''; |
78 | 78 | $MoonList = DBStaticPlanet::db_planet_list_moon_other($user['id'], $planetrow['id']); |
79 | 79 | // while($CurMoon = db_fetch($MoonList)) |
80 | - foreach($MoonList as $CurMoon) |
|
80 | + foreach ($MoonList as $CurMoon) |
|
81 | 81 | { |
82 | - if(mrc_get_level($user, $CurMoon, STRUC_MOON_GATE) >= 1) |
|
82 | + if (mrc_get_level($user, $CurMoon, STRUC_MOON_GATE) >= 1) |
|
83 | 83 | { |
84 | 84 | $NextJumpTime = uni_get_time_to_jump($CurMoon); |
85 | 85 | $template->assign_block_vars('moon', array( |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | - foreach(sn_get_groups('fleet') as $Ship) |
|
96 | + foreach (sn_get_groups('fleet') as $Ship) |
|
97 | 97 | { |
98 | - if(($ship_count = mrc_get_level($user, $planetrow, $Ship)) <= 0) |
|
98 | + if (($ship_count = mrc_get_level($user, $planetrow, $Ship)) <= 0) |
|
99 | 99 | { |
100 | 100 | continue; |
101 | 101 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
14 | 14 | |
15 | -if(classSupernova::$config->game_mode == GAME_BLITZ) { |
|
15 | +if (classSupernova::$config->game_mode == GAME_BLITZ) { |
|
16 | 16 | messageBox($lang['sys_blitz_page_disabled'], $lang['sys_error'], 'overview.php', 10); |
17 | 17 | die(); |
18 | 18 | } |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | |
26 | 26 | $template = gettemplate('search', true); |
27 | 27 | |
28 | -if($searchtext && $type) |
|
28 | +if ($searchtext && $type) |
|
29 | 29 | { |
30 | - switch($type) |
|
30 | + switch ($type) |
|
31 | 31 | { |
32 | 32 | case "planetname": |
33 | 33 | // $search = db_planet_list_search($searchtext); |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | break; |
44 | 44 | } |
45 | 45 | |
46 | - while($row = db_fetch($search)) |
|
46 | + while ($row = db_fetch($search)) |
|
47 | 47 | { |
48 | - if($type=='playername' || $type=='planetname') |
|
48 | + if ($type == 'playername' || $type == 'planetname') |
|
49 | 49 | { |
50 | 50 | $template->assign_block_vars('search_result', array( |
51 | 51 | 'PLAYER_ID' => $row['uid'], |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | 'ALLY_TAG' => htmlentities($row['ally_tag'], ENT_COMPAT, 'UTF-8'), |
63 | 63 | )); |
64 | 64 | } |
65 | - elseif($type=='ally') |
|
65 | + elseif ($type == 'ally') |
|
66 | 66 | { |
67 | 67 | $template->assign_block_vars('search_result', array( |
68 | 68 | 'ALLY_NAME' => htmlentities($row['ally_name'], ENT_COMPAT, 'UTF-8'), |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | 'ally' => 'sys_alliance', |
82 | 82 | ); |
83 | 83 | |
84 | -foreach($search_type as $type_id => $type_lang) |
|
84 | +foreach ($search_type as $type_id => $type_lang) |
|
85 | 85 | { |
86 | 86 | $template->assign_block_vars('type', array( |
87 | 87 | 'ID' => $type_id, |