Completed
Push — work-fleets ( ff9274...a405f7 )
by SuperNova.WS
06:32
created
includes/pages/contact.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
   $query = db_user_list("`authlevel` > 0 ORDER BY `authlevel` ASC");
17 17
 
18 18
   // while($row = db_fetch($query))
19
-  foreach($query as $row) {
19
+  foreach ($query as $row) {
20 20
     $template_result['.']['contact'][] = array(
21 21
       'NAME'  => $row['username'],
22 22
       'LEVEL' => classLocale::$lang['user_level'][$row['authlevel']],
Please login to merge, or discard this patch.
includes/alliance/ali_internal_members.inc 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -2,31 +2,31 @@  discard block
 block discarded – undo
2 2
 
3 3
 $classLocale = classLocale::$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
   $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
7 7
 }
8 8
 
9 9
 // Changing rank for single user
10 10
 $id_user = sys_get_param_id('id_user');
11
-if(isset($_GET['id_rank'])) {
11
+if (isset($_GET['id_rank'])) {
12 12
   $id_rank = sys_get_param_int('id_rank');
13 13
 }
14
-if($id_user && isset($id_rank) && $user_admin) {
14
+if ($id_user && isset($id_rank) && $user_admin) {
15 15
   db_user_set_by_id($id_user, "`ally_rank_id` = {$id_rank}");
16 16
 }
17 17
 
18 18
 $id_kick = sys_get_param_id('kick');
19 19
 
20
-if($id_kick && $user_can_kick) {
20
+if ($id_kick && $user_can_kick) {
21 21
   $u = db_user_by_id($id_kick, true);
22
-  if($u['ally_id'] == $ally['id'] && $u['id'] != $ally['ally_owner']) {
22
+  if ($u['ally_id'] == $ally['id'] && $u['id'] != $ally['ally_owner']) {
23 23
     db_user_set_by_id($id_kick, '`ally_id`= null, `ally_name` = null, `ally_tag` = null, ally_register_time = 0, ally_rank_id = 0');
24 24
     db_ally_update_member_decrease($ally);
25 25
   }
26 26
 }
27 27
 
28 28
 $sort2 = sys_get_param_int('sort2');
29
-if($sort2) {
29
+if ($sort2) {
30 30
   $sort2s = "DESC";
31 31
   $sort2 = 0;
32 32
 } else {
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 }
36 36
 
37 37
 $sort1 = sys_get_param_int('sort1');
38
-if($sort1 > 5 || $sort1 < 0) {
38
+if ($sort1 > 5 || $sort1 < 0) {
39 39
   $sort1 = 0;
40 40
 }
41 41
 $sort1s = array(
@@ -53,21 +53,21 @@  discard block
 block discarded – undo
53 53
   'id, username, galaxy, system, planet, onlinetime, ally_rank_id, ally_register_time, total_points');
54 54
 
55 55
 // while ($userRow = db_fetch($userList))
56
-foreach($userList as $userRow) {
56
+foreach ($userList as $userRow) {
57 57
   $i++;
58
-  if(!isset($ranks[$userRow['ally_rank_id']])) {
58
+  if (!isset($ranks[$userRow['ally_rank_id']])) {
59 59
     $userRow['ally_rank_id'] = 0;
60 60
   }
61 61
 
62
-  if($ally['ally_owner'] == $userRow['id']) {
62
+  if ($ally['ally_owner'] == $userRow['id']) {
63 63
     $ally_range = ($ally['ally_owner_range']) ? $ally['ally_owner_range'] : classLocale::$lang['Founder'];
64 64
   } else {
65
-    if($user_admin) {
65
+    if ($user_admin) {
66 66
       $ally_range = '<select onchange="window.location=\'alliance.php?mode=admin&edit=members&id_user=' . $userRow['id'] . '&id_rank=\' + this.value">';
67 67
 
68
-      foreach($ranks as $rankID => $rankArray) {
68
+      foreach ($ranks as $rankID => $rankArray) {
69 69
         $ally_range .= '<option value="' . $rankID . '"';
70
-        if($rankID == $userRow['ally_rank_id']) {
70
+        if ($rankID == $userRow['ally_rank_id']) {
71 71
           $ally_range .= " selected";
72 72
         }
73 73
         $ally_range .= '>' . $rankArray['name'];
@@ -80,20 +80,20 @@  discard block
 block discarded – undo
80 80
   }
81 81
 
82 82
   $last_active = time() - $userRow["onlinetime"];
83
-  if($user_admin) {
84
-    if($last_active < 60) {
83
+  if ($user_admin) {
84
+    if ($last_active < 60) {
85 85
       $tmp = "lime>{$classLocale['On']}";
86
-    } elseif($last_active < 60 * 60) {
86
+    } elseif ($last_active < 60 * 60) {
87 87
       $last_active = round($last_active / 60);
88 88
       $tmp = "lime>{$last_active} {$classLocale['sys_min_short']}";
89
-    } elseif($last_active < 60 * 60 * 24) {
89
+    } elseif ($last_active < 60 * 60 * 24) {
90 90
       $last_active = round($last_active / (60 * 60));
91 91
       $tmp = "green>{$last_active} {$classLocale['sys_hrs_short']}";
92 92
     } else {
93 93
       $last_active = round($last_active / (60 * 60 * 24));
94
-      if($last_active < 7) {
94
+      if ($last_active < 7) {
95 95
         $tmp = "yellow";
96
-      } elseif($last_active < 30) {
96
+      } elseif ($last_active < 30) {
97 97
         $tmp = "orange";
98 98
       } else {
99 99
         $tmp = "red";
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
       $tmp .= ">{$last_active} {$classLocale['sys_day_short']}";
102 102
     }
103 103
   } else {
104
-    if($user_onlinestatus) {
105
-      if($last_active < 60 * 5) {
104
+    if ($user_onlinestatus) {
105
+      if ($last_active < 60 * 5) {
106 106
         $tmp = "lime>{$classLocale['On']}";
107
-      } elseif($last_active < 60 * 15) {
107
+      } elseif ($last_active < 60 * 15) {
108 108
         $tmp = "yellow>{$classLocale['ali_lessThen15min']}";
109 109
       } else {
110 110
         $tmp = "red>{$classLocale['Off']}";
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
   ));
132 132
 }
133 133
 
134
-if($i != $ally['ally_members']) {
134
+if ($i != $ally['ally_members']) {
135 135
   db_ally_update_member_set($i, $ally);
136 136
 }
137 137
 
Please login to merge, or discard this patch.
admin/admin_chat.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
 
15 15
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
16 16
 
17
-if($user['authlevel'] < 3) {
17
+if ($user['authlevel'] < 3) {
18 18
   AdminMessage(classLocale::$lang['adm_err_denied']);
19 19
 }
20 20
 
21
-if($delete = sys_get_param_str('delete')) {
21
+if ($delete = sys_get_param_str('delete')) {
22 22
   db_chat_message_delete($delete);
23
-} elseif(sys_get_param_str('deleteall') == 'yes') {
23
+} elseif (sys_get_param_str('deleteall') == 'yes') {
24 24
   db_chat_message_purge();
25 25
 }
26 26
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
 $query = db_chat_message_get_last_25();
30 30
 $i = 0;
31
-while($e = db_fetch($query)) {
31
+while ($e = db_fetch($query)) {
32 32
   $i++;
33 33
   $template->assign_block_vars('messages', array(
34 34
     'ID' => $e['messageid'],
Please login to merge, or discard this patch.
admin/banned.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
18 18
 
19
-if($user['authlevel'] < 1) {
19
+if ($user['authlevel'] < 1) {
20 20
   AdminMessage(classLocale::$lang['adm_err_denied']);
21 21
 }
22 22
 
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
 $template = gettemplate("admin/admin_ban", true);
29 29
 
30 30
 $player_banned_row = db_user_by_username($name_unsafe);
31
-if($mode == 'banit' && $action) {
32
-  if($player_banned_row) {
31
+if ($mode == 'banit' && $action) {
32
+  if ($player_banned_row) {
33 33
     $reas = $_POST['why'];
34 34
     $days = $_POST['days'];
35 35
     $hour = $_POST['hour'];
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     $adm_bn_thpl = classLocale::$lang['adm_bn_thpl'];
50 50
     $DoneMessage = "{$adm_bn_thpl} {$name_output} {$adm_bn_isbn}";
51 51
 
52
-    if($is_vacation) {
52
+    if ($is_vacation) {
53 53
       $DoneMessage .= classLocale::$lang['adm_bn_vctn'];
54 54
     }
55 55
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
   }
60 60
 
61 61
   AdminMessage($DoneMessage, classLocale::$lang['adm_ban_title']);
62
-} elseif($mode == 'unbanit' && $action) {
62
+} elseif ($mode == 'unbanit' && $action) {
63 63
   sys_admin_player_ban_unset($user, $player_banned_row, ($reason = sys_get_param_str('why')) ? $reason : classLocale::$lang['sys_unbanned']);
64 64
 
65 65
   $DoneMessage = classLocale::$lang['adm_unbn_thpl'] . " " . $name_output . " " . classLocale::$lang['adm_unbn_isbn'];
Please login to merge, or discard this patch.
admin/planet_compensate.php 2 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2
-define('INSIDE'  , true);
3
-define('INSTALL' , false);
2
+define('INSIDE', true);
3
+define('INSTALL', false);
4 4
 define('IN_ADMIN', true);
5 5
 
6 6
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
7 7
 
8
-if($user['authlevel'] < 3)
8
+if ($user['authlevel'] < 3)
9 9
 {
10 10
   AdminMessage(classLocale::$lang['adm_err_denied']);
11 11
 }
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 $username_unsafe = sys_get_param_str_unsafe('username');
26 26
 $username = sys_get_param_escaped('username');
27 27
 
28
-if($galaxy_src)
28
+if ($galaxy_src)
29 29
 {
30 30
   sn_db_transaction_start();
31 31
   $errors = array();
@@ -35,41 +35,41 @@  discard block
 block discarded – undo
35 35
   $planet = sys_o_get_updated($owner, array('galaxy' => $galaxy_src, 'system' => $system_src, 'planet' => $planet_src, 'planet_type' => 1), SN_TIME_NOW);
36 36
   $que    = $planet['que'];
37 37
   $planet = $planet['planet'];
38
-  if(!$planet)
38
+  if (!$planet)
39 39
   {
40 40
     $errors[] = classLocale::$lang['adm_pl_comp_err_0'];
41 41
   }
42 42
 
43
-  if($planet['destruyed'])
43
+  if ($planet['destruyed'])
44 44
   {
45 45
     $errors[] = classLocale::$lang['adm_pl_comp_err_1'];
46 46
   }
47 47
 
48
-  if($planet['id_owner'] != $owner['id'] || !$username)
48
+  if ($planet['id_owner'] != $owner['id'] || !$username)
49 49
   {
50 50
     $errors[] = classLocale::$lang['adm_pl_comp_err_4'];
51 51
   }
52 52
 
53 53
   $destination = sys_o_get_updated($owner, array('galaxy' => $galaxy_dst, 'system' => $system_dst, 'planet' => $planet_dst, 'planet_type' => 1), SN_TIME_NOW);
54 54
   $destination = $destination['planet'];
55
-  if(!$destination)
55
+  if (!$destination)
56 56
   {
57 57
     $errors[] = classLocale::$lang['adm_pl_comp_err_2'];
58 58
   }
59 59
 
60
-  if($planet['id'] == $destination['id'])
60
+  if ($planet['id'] == $destination['id'])
61 61
   {
62 62
     $errors[] = classLocale::$lang['adm_pl_comp_err_5'];
63 63
   }
64 64
 
65
-  if($planet['id_owner'] != $destination['id_owner'])
65
+  if ($planet['id_owner'] != $destination['id_owner'])
66 66
   {
67 67
     $errors[] = classLocale::$lang['adm_pl_comp_err_3'];
68 68
   }
69 69
 
70
-  if(!empty($errors))
70
+  if (!empty($errors))
71 71
   {
72
-    foreach($errors as $error)
72
+    foreach ($errors as $error)
73 73
     {
74 74
       $template->assign_block_vars('error', array(
75 75
         'TEXT' => $error,
@@ -83,14 +83,14 @@  discard block
 block discarded – undo
83 83
     killer_add_planet($planet);
84 84
 
85 85
     $moon = db_planet_by_gspt($galaxy_src, $system_src, $planet_src, PT_MOON, true);
86
-    if($moon)
86
+    if ($moon)
87 87
     {
88 88
       $moon = sys_o_get_updated($owner, $moon, SN_TIME_NOW);
89 89
       $moon = $moon['planet'];
90 90
       killer_add_planet($moon);
91 91
     }
92 92
 
93
-    foreach(sn_get_groups('resources_loot') as $resource_id)
93
+    foreach (sn_get_groups('resources_loot') as $resource_id)
94 94
     {
95 95
       $resource_name = pname_resource_name($resource_id);
96 96
       $template->assign_var("{$resource_name}_cost", $final_cost[$resource_id]);
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
       $template->assign_var("{$resource_name}_bonus", $final_cost[$resource_id]);
99 99
     }
100 100
 
101
-    if($_GET['btn_confirm'])
101
+    if ($_GET['btn_confirm'])
102 102
     {
103 103
       $time = SN_TIME_NOW + PERIOD_DAY;
104 104
 
105 105
       db_unit_list_delete($planet['id_owner'], LOC_PLANET, $planet['id']);
106 106
       db_planet_set_by_id($planet['id'], "id_owner = 0, destruyed = {$time}");
107
-      if($moon)
107
+      if ($moon)
108 108
       {
109 109
         db_unit_list_delete($planet['id_owner'], LOC_PLANET, $moon['id']);
110 110
         db_planet_set_by_id($moon['id'], "id_owner = 0, destruyed = {$time}");
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
   'username' => $username,
132 132
 ));
133 133
 
134
-display(parsetemplate($template), classLocale::$lang['adm_pl_comp_title'], false, '', true );
134
+display(parsetemplate($template), classLocale::$lang['adm_pl_comp_title'], false, '', true);
135 135
 
136 136
 function killer_add_planet($planet)
137 137
 {
@@ -146,34 +146,34 @@  discard block
 block discarded – undo
146 146
   }
147 147
   */
148 148
 
149
-  foreach(sn_get_groups('structures') as $unit_id)
149
+  foreach (sn_get_groups('structures') as $unit_id)
150 150
   {
151 151
     $build_level = mrc_get_level($user, $planet, $unit_id, true, true);
152
-    if($build_level > 0)
152
+    if ($build_level > 0)
153 153
     {
154 154
       $unit_cost = get_unit_param($unit_id, 'cost');
155 155
       $build_factor = $unit_cost['factor'] != 1 ? (1 - pow($unit_cost['factor'], $build_level)) / (1 - $unit_cost['factor']) : $unit_cost['factor'];
156
-      foreach($sn_group_resources_loot as $resource_id)
156
+      foreach ($sn_group_resources_loot as $resource_id)
157 157
       {
158 158
         $final_cost[$resource_id] += isset($unit_cost[$resource_id]) && $unit_cost[$resource_id] > 0 ? floor($unit_cost[$resource_id] * $build_factor) : 0;
159 159
       }
160 160
     }
161 161
   }
162 162
 
163
-  foreach(sn_get_groups(array('defense', 'fleet')) as $unit_id)
163
+  foreach (sn_get_groups(array('defense', 'fleet')) as $unit_id)
164 164
   {
165 165
     $unit_count = mrc_get_level($user, $planet, $unit_id, true, true);
166
-    if($unit_count > 0)
166
+    if ($unit_count > 0)
167 167
     {
168 168
       $unit_cost = get_unit_param($unit_id, 'cost');
169
-      foreach($sn_group_resources_loot as $resource_id)
169
+      foreach ($sn_group_resources_loot as $resource_id)
170 170
       {
171 171
         $final_cost[$resource_id] += isset($unit_cost[$resource_id]) && $unit_cost[$resource_id] > 0 ? floor($unit_cost[$resource_id] * $unit_count) : 0;
172 172
       }
173 173
     }
174 174
   }
175 175
 
176
-  foreach($sn_group_resources_loot as $resource_id)
176
+  foreach ($sn_group_resources_loot as $resource_id)
177 177
   {
178 178
     $final_cost[$resource_id] += floor(mrc_get_level($user, $planet, $resource_id, true, true));
179 179
   }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -79,8 +79,7 @@  discard block
 block discarded – undo
79 79
         'TEXT' => $error,
80 80
       ));
81 81
     }
82
-  }
83
-  else
82
+  } else
84 83
   {
85 84
     $template->assign_var('CHECK', 1);
86 85
 
@@ -159,8 +158,7 @@  discard block
 block discarded – undo
159 158
 
160 159
 display(parsetemplate($template), classLocale::$lang['adm_pl_comp_title'], false, '', true );
161 160
 
162
-function killer_add_planet($planet)
163
-{
161
+function killer_add_planet($planet) {
164 162
   global $final_cost;
165 163
 
166 164
   $final_cost = array();
Please login to merge, or discard this patch.
infos.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -47,20 +47,20 @@  discard block
 block discarded – undo
47 47
   ));
48 48
 
49 49
   $ActualProd = floor($Prod[$BuildID]);
50
-  if($BuildID != STRUC_MINE_FUSION) {
50
+  if ($BuildID != STRUC_MINE_FUSION) {
51 51
     $ActualNeed = floor($Prod[STRUC_MINE_SOLAR]);
52 52
   } else {
53 53
     $ActualNeed = floor($Prod[STRUC_MINE_DEUTERIUM]);
54 54
   }
55 55
 
56 56
   $BuildStartLvl = $CurrentBuildtLvl - 2;
57
-  if($BuildStartLvl < 1) {
57
+  if ($BuildStartLvl < 1) {
58 58
     $BuildStartLvl = 1;
59 59
   }
60 60
   $Table = '';
61 61
   $ProdFirst = 0;
62
-  for($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 10; $BuildLevel++) {
63
-    if($BuildID != STRUC_MOON_PHALANX) {
62
+  for ($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 10; $BuildLevel++) {
63
+    if ($BuildID != STRUC_MOON_PHALANX) {
64 64
       $Prod[STRUC_MINE_METAL] = floor(mrc_modify_value(
65 65
         $CurrentUser,
66 66
         $CurrentPlanet,
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
       ));
88 88
 
89 89
       $bloc['build_lvl'] = ($CurrentBuildtLvl == $BuildLevel) ? "<font color=\"#ff0000\">" . $BuildLevel . "</font>" : $BuildLevel;
90
-      if($ProdFirst > 0) {
91
-        if($BuildID != STRUC_MINE_FUSION) {
90
+      if ($ProdFirst > 0) {
91
+        if ($BuildID != STRUC_MINE_FUSION) {
92 92
           $bloc['build_gain'] = "<font color=\"lime\">(" . pretty_number(floor($Prod[$BuildID] - $ProdFirst)) . ")</font>";
93 93
         } else {
94 94
           $bloc['build_gain'] = "<font color=\"lime\">(" . pretty_number(floor($Prod[STRUC_MINE_SOLAR] - $ProdFirst)) . ")</font>";
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
       } else {
97 97
         $bloc['build_gain'] = '';
98 98
       }
99
-      if($BuildID != STRUC_MINE_FUSION) {
99
+      if ($BuildID != STRUC_MINE_FUSION) {
100 100
         $bloc['build_prod'] = pretty_number(floor($Prod[$BuildID]));
101 101
         $bloc['build_prod_diff'] = pretty_number(floor($Prod[$BuildID] - $ActualProd), true, true);
102 102
         $bloc['build_need'] = pretty_number(floor($Prod[STRUC_MINE_SOLAR]), true, true);
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
         $bloc['build_need'] = pretty_number(floor($Prod[STRUC_MINE_DEUTERIUM]), true, true);
108 108
         $bloc['build_need_diff'] = pretty_number(floor($Prod[STRUC_MINE_DEUTERIUM] - $ActualNeed), true, true);
109 109
       }
110
-      if($ProdFirst == 0) {
111
-        if($BuildID != STRUC_MINE_FUSION) {
110
+      if ($ProdFirst == 0) {
111
+        if ($BuildID != STRUC_MINE_FUSION) {
112 112
           $ProdFirst = floor($Prod[$BuildID]);
113 113
         } else {
114 114
           $ProdFirst = floor($Prod[STRUC_MINE_SOLAR]);
@@ -133,22 +133,22 @@  discard block
 block discarded – undo
133 133
 
134 134
   $str_rapid_from = '';
135 135
   $str_rapid_to = '';
136
-  foreach(sn_get_groups(array('fleet', 'defense_active')) as $enemy_id) {
136
+  foreach (sn_get_groups(array('fleet', 'defense_active')) as $enemy_id) {
137 137
     $enemy_data = get_unit_param($enemy_id);
138 138
     $enemy_durability = $enemy_data['shield'] + $enemy_data['armor'];
139 139
 
140 140
     $rapid = floor($unit_data['attack'] * (isset($unit_data['amplify'][$enemy_id]) ? $unit_data['amplify'][$enemy_id] : 1) / $enemy_durability);
141
-    if($rapid >= 1) {
141
+    if ($rapid >= 1) {
142 142
       $str_rapid_to .= "{$classLocale['nfo_rf_again']} {$classLocale['tech'][$enemy_id]} <font color=\"#00ff00\">{$rapid}</font><br>";
143 143
     }
144 144
 
145 145
     $rapid = floor($enemy_data['attack'] * (isset($enemy_data['amplify'][$unit_id]) ? $enemy_data['amplify'][$unit_id] : 1) / $unit_durability);
146
-    if($rapid >= 1) {
146
+    if ($rapid >= 1) {
147 147
       $str_rapid_from .= "{$classLocale['tech'][$enemy_id]} {$classLocale['nfo_rf_from']} <font color=\"#ff0000\">{$rapid}</font><br>";
148 148
     }
149 149
   }
150 150
 
151
-  if($str_rapid_to && $str_rapid_from) {
151
+  if ($str_rapid_to && $str_rapid_from) {
152 152
     $str_rapid_to .= '<hr>';
153 153
   }
154 154
 
@@ -156,16 +156,16 @@  discard block
 block discarded – undo
156 156
 }
157 157
 
158 158
 $unit_id = sys_get_param_id('gid');
159
-if($unit_id == RES_DARK_MATTER) {
159
+if ($unit_id == RES_DARK_MATTER) {
160 160
   sys_redirect('dark_matter.php');
161 161
 }
162 162
 
163
-if($unit_id == RES_METAMATTER) {
163
+if ($unit_id == RES_METAMATTER) {
164 164
   sys_redirect('metamatter.php');
165 165
 }
166 166
 
167 167
 lng_include('infos');
168
-if(!$unit_id || (!get_unit_param($unit_id) && !isset(classLocale::$lang['info'][$unit_id]))) {
168
+if (!$unit_id || (!get_unit_param($unit_id) && !isset(classLocale::$lang['info'][$unit_id]))) {
169 169
   sys_redirect('index.php?page=techtree');
170 170
 }
171 171
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 $unit_data = get_unit_param($unit_id);
175 175
 $unit_type = $unit_data['type'];
176 176
 
177
-if($unit_type == UNIT_SHIPS) {
177
+if ($unit_type == UNIT_SHIPS) {
178 178
   $template_result['UNIT_IS_SHIP'] = true;
179 179
 
180 180
   $ship_data = get_ship_data($unit_id, $user);
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
   );
191 191
 
192 192
   $engine_template_info = array();
193
-  foreach($unit_data['engine'] as $unit_engine_data) {
193
+  foreach ($unit_data['engine'] as $unit_engine_data) {
194 194
     $unit_engine_data = get_engine_data($user, $unit_engine_data);
195 195
 
196 196
     $engine_template_info[] = array(
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 
210 210
 
211 211
 $sn_data_group_combat = sn_get_groups('combat');
212
-if(in_array($unit_id, $sn_data_group_combat)) {
212
+if (in_array($unit_id, $sn_data_group_combat)) {
213 213
   $template_result['UNIT_IS_COMBAT'] = true;
214 214
 
215 215
   $unit_durability = $unit_data['shield'] + $unit_data['armor'];
@@ -217,21 +217,21 @@  discard block
 block discarded – undo
217 217
   $volley_arr = $rapid_to = $rapid_from = array();
218 218
   $str_rapid_from = '';
219 219
   $str_rapid_to = '';
220
-  foreach($sn_data_group_combat as $enemy_id) {
220
+  foreach ($sn_data_group_combat as $enemy_id) {
221 221
     $enemy_data = get_unit_param($enemy_id);
222 222
     $enemy_durability = $enemy_data['shield'] + $enemy_data['armor'];
223 223
 
224 224
     $rapid = $unit_data['attack'] * (isset($unit_data['amplify'][$enemy_id]) ? $unit_data['amplify'][$enemy_id] : 1) / $enemy_durability;
225
-    if($rapid >= 1) {
225
+    if ($rapid >= 1) {
226 226
       $volley_arr[$enemy_id]['TO'] = floor($rapid);
227 227
     }
228 228
 
229 229
     $rapid = $enemy_data['attack'] * (isset($enemy_data['amplify'][$unit_id]) ? $enemy_data['amplify'][$unit_id] : 1) / $unit_durability;
230
-    if($rapid >= 1) {
230
+    if ($rapid >= 1) {
231 231
       $volley_arr[$enemy_id]['FROM'] = floor($rapid);
232 232
     }
233 233
   }
234
-  foreach($volley_arr as $enemy_id => &$rapid) {
234
+  foreach ($volley_arr as $enemy_id => &$rapid) {
235 235
     $rapid['ENEMY_ID'] = $enemy_id;
236 236
     $rapid['ENEMY_NAME'] = classLocale::$lang['tech'][$enemy_id];
237 237
   }
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
 
250 250
 }
251 251
 
252
-if(classLocale::$lang['info'][$unit_id]['effect']) {
252
+if (classLocale::$lang['info'][$unit_id]['effect']) {
253 253
   $template_result['UNIT_EFFECT'] = classLocale::$lang['info'][$unit_id]['effect'];
254 254
 }
255 255
 
256
-if($unit_data['bonus']) {
256
+if ($unit_data['bonus']) {
257 257
   $unit_bonus = !$unit_data['bonus'] || $unit_data['bonus_type'] == BONUS_ABILITY ? '' : (
258 258
     ($unit_data['bonus'] >= 0 ? '+' : '') . $unit_data['bonus'] . ($unit_data['bonus_type'] == BONUS_PERCENT ? '%' : '')
259 259
   );
Please login to merge, or discard this patch.
search.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
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
   message(classLocale::$lang['sys_blitz_page_disabled'], classLocale::$lang['sys_error'], 'overview.php', 10);
17 17
   die();
18 18
 }
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 
26 26
 $template = gettemplate('search', true);
27 27
 
28
-if($searchtext && $type) {
29
-  switch($type) {
28
+if ($searchtext && $type) {
29
+  switch ($type) {
30 30
     case "planetname":
31 31
       // $search = db_planet_list_search($searchtext);
32 32
     break;
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
     break;
42 42
   }
43 43
 
44
-  while($row = db_fetch($search)) {
45
-    if($type == 'playername' || $type == 'planetname') {
44
+  while ($row = db_fetch($search)) {
45
+    if ($type == 'playername' || $type == 'planetname') {
46 46
       $template->assign_block_vars('search_result', array(
47 47
         'PLAYER_ID'       => $row['uid'],
48 48
         'PLAYER_NAME'     => htmlentities($row['username'], ENT_COMPAT, 'UTF-8'),
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         'ALLY_NAME'       => htmlentities($row['ally_name'], ENT_COMPAT, 'UTF-8'),
58 58
         'ALLY_TAG'        => htmlentities($row['ally_tag'], ENT_COMPAT, 'UTF-8'),
59 59
       ));
60
-    } elseif($type == 'ally') {
60
+    } elseif ($type == 'ally') {
61 61
       $template->assign_block_vars('search_result', array(
62 62
         'ALLY_NAME'     => htmlentities($row['ally_name'], ENT_COMPAT, 'UTF-8'),
63 63
         'ALLY_TAG'      => htmlentities($row['ally_tag'], ENT_COMPAT, 'UTF-8'),
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
   'ally'       => 'sys_alliance',
76 76
 );
77 77
 
78
-foreach($search_type as $type_id => $type_lang) {
78
+foreach ($search_type as $type_id => $type_lang) {
79 79
   $template->assign_block_vars('type', array(
80 80
     'ID'       => $type_id,
81 81
     'TEXT'     => classLocale::$lang[$type_lang],
Please login to merge, or discard this patch.
includes/includes/sys_avatar.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,29 +5,29 @@  discard block
 block discarded – undo
5 5
     $avatar_filename = $fullsize_filename = SN_ROOT_PHYSICAL . 'images/avatar/' . $prefix . '_' . $subject_id;
6 6
     $avatar_filename .= '.png';
7 7
     $fullsize_filename .= '_full.png';
8
-    if(sys_get_param_int('avatar_remove')) {
9
-      if(file_exists($avatar_filename) && !unlink($avatar_filename)) {
8
+    if (sys_get_param_int('avatar_remove')) {
9
+      if (file_exists($avatar_filename) && !unlink($avatar_filename)) {
10 10
         throw new Exception(classLocale::$lang['opt_msg_avatar_error_delete'], ERR_ERROR);
11 11
       }
12 12
       $avatar_field = 0;
13 13
       throw new Exception(classLocale::$lang['opt_msg_avatar_removed'], ERR_NONE);
14
-    } elseif($_FILES['avatar']['size']) {
15
-      if(!in_array($_FILES['avatar']['type'], array('image/gif', 'image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png')) || $_FILES['avatar']['size'] > 204800) {
14
+    } elseif ($_FILES['avatar']['size']) {
15
+      if (!in_array($_FILES['avatar']['type'], array('image/gif', 'image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png')) || $_FILES['avatar']['size'] > 204800) {
16 16
         throw new Exception(classLocale::$lang['opt_msg_avatar_error_unsupported'], ERR_WARNING);
17 17
       }
18 18
 
19
-      if($_FILES['avatar']['error']) {
19
+      if ($_FILES['avatar']['error']) {
20 20
         throw new Exception(sprintf(classLocale::$lang['opt_msg_avatar_error_upload'], $_FILES['avatar']['error']), ERR_ERROR);
21 21
       }
22 22
 
23
-      if(!($avatar_image = imagecreatefromstring(file_get_contents($_FILES['avatar']['tmp_name'])))) {
23
+      if (!($avatar_image = imagecreatefromstring(file_get_contents($_FILES['avatar']['tmp_name'])))) {
24 24
         throw new Exception(classLocale::$lang['opt_msg_avatar_error_unsupported'], ERR_WARNING);
25 25
       }
26 26
 
27 27
       $avatar_size = getimagesize($_FILES['avatar']['tmp_name']);
28 28
       $avatar_max_width = classSupernova::$config->avatar_max_width;
29 29
       $avatar_max_height = classSupernova::$config->avatar_max_height;
30
-      if($avatar_size[0] > $avatar_max_width || $avatar_size[1] > $avatar_max_height) {
30
+      if ($avatar_size[0] > $avatar_max_width || $avatar_size[1] > $avatar_max_height) {
31 31
         $aspect_ratio = min($avatar_max_width / $avatar_size[0], $avatar_max_height / $avatar_size[1]);
32 32
         $avatar_image_new = imagecreatetruecolor($avatar_size[0] * $aspect_ratio, $avatar_size[0] * $aspect_ratio);
33 33
         $result = imagecopyresized($avatar_image_new, $avatar_image, 0, 0, 0, 0, $avatar_size[0] * $aspect_ratio, $avatar_size[0] * $aspect_ratio, $avatar_size[0], $avatar_size[1]);
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
         $avatar_image = $avatar_image_new;
36 36
       }
37 37
 
38
-      if(file_exists($avatar_filename) && !unlink($avatar_filename)) {
38
+      if (file_exists($avatar_filename) && !unlink($avatar_filename)) {
39 39
         throw new Exception(classLocale::$lang['opt_msg_avatar_error_delete'], ERR_ERROR);
40 40
       }
41 41
 
42
-      if(!imagepng($avatar_image, $avatar_filename, 9)) {
42
+      if (!imagepng($avatar_image, $avatar_filename, 9)) {
43 43
         throw new Exception(classLocale::$lang['opt_msg_avatar_error_writing'], ERR_ERROR);
44 44
       }
45 45
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
       imagedestroy($avatar_image);
48 48
       throw new Exception(classLocale::$lang['opt_msg_avatar_uploaded'], ERR_NONE);
49 49
     }
50
-  } catch(Exception $e) {
50
+  } catch (Exception $e) {
51 51
     return array(
52 52
       'STATUS'  => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR,
53 53
       'MESSAGE' => $e->getMessage()
Please login to merge, or discard this patch.
includes/update.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -756,9 +756,11 @@
 block discarded – undo
756 756
         !empty($strings) ? doquery($query_string . implode(',', $strings)) : false;
757 757
       }
758 758
 
759
-      if(isset($update_tables['counter']['page'])) // TODO REMOVE
759
+      if(isset($update_tables['counter']['page'])) {
760
+        // TODO REMOVE
760 761
       {
761 762
         update_security_url("SELECT DISTINCT `page` AS url FROM {{counter}}");
763
+      }
762 764
         update_security_url("SELECT DISTINCT `url` AS url FROM {{counter}}");
763 765
       }
764 766
     }
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
 use Vector\Vector;
25 25
 
26
-if(!defined('INIT')) {
26
+if (!defined('INIT')) {
27 27
 //  include_once('init.php');
28 28
   die('Unauthorized access');
29 29
 }
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 classSupernova::$config->debug = 0;
42 42
 
43 43
 
44
-if(classSupernova::$config->db_version == DB_VERSION) {
45
-} elseif(classSupernova::$config->db_version > DB_VERSION) {
44
+if (classSupernova::$config->db_version == DB_VERSION) {
45
+} elseif (classSupernova::$config->db_version > DB_VERSION) {
46 46
   classSupernova::$config->db_saveItem('var_db_update_end', SN_TIME_NOW);
47 47
   die(
48 48
   'Internal error! Auotupdater detects DB version greater then can be handled!<br />
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
   );
52 52
 }
53 53
 
54
-if(classSupernova::$config->db_version < 26) {
54
+if (classSupernova::$config->db_version < 26) {
55 55
   $sys_log_disabled = true;
56 56
 }
57 57
 
@@ -70,20 +70,20 @@  discard block
 block discarded – undo
70 70
 $update_tables = array();
71 71
 $update_indexes = array();
72 72
 $query = upd_do_query('SHOW TABLES;', true);
73
-while($row = classSupernova::$db->db_fetch_row($query)) {
73
+while ($row = classSupernova::$db->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...');
77 77
 
78 78
 upd_do_query('SET FOREIGN_KEY_CHECKS=0;', true);
79 79
 
80
-if($new_version < 37) {
80
+if ($new_version < 37) {
81 81
   die('Upgrade from SN versions below 37 are not supported. Use SN version 39 to upgrade old DB then use V40+ for further upgrade');
82 82
 }
83 83
 
84 84
 ini_set('memory_limit', '1024M');
85 85
 
86
-switch($new_version) {
86
+switch ($new_version) {
87 87
   case 37:
88 88
     upd_log_version_update();
89 89
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
     upd_check_key('payment_currency_exchange_mm_', 2500, !classSupernova::$config->payment_currency_exchange_mm_);
100 100
 
101
-    if(!$update_tables['log_metamatter']) {
101
+    if (!$update_tables['log_metamatter']) {
102 102
       upd_create_table('log_metamatter',
103 103
         "(
104 104
           `id` SERIAL,
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
       "ADD `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'",
124 124
     ), !$update_tables['payment']['payment_test']);
125 125
 
126
-    if($update_tables['payment']['payment_test']['Default'] == 1) {
126
+    if ($update_tables['payment']['payment_test']['Default'] == 1) {
127 127
       upd_alter_table('payment', array(
128 128
         "MODIFY COLUMN `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'",
129 129
       ));
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     ), $update_tables['users']['metamatter']['Type'] == 'int(20)');
141 141
 
142 142
     $query = upd_do_query("SELECT * FROM {{que}} WHERE `que_type` = " . QUE_RESEARCH . " AND que_unit_id IN (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") FOR UPDATE");
143
-    while($row = db_fetch($query)) {
143
+    while ($row = db_fetch($query)) {
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");
146 146
       $price = sys_unit_str2arr($row['que_unit_price']);
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
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)) {
162
-      if(!$row['id_planet']) {
161
+    while ($row = db_fetch($query)) {
162
+      if (!$row['id_planet']) {
163 163
         continue;
164 164
       }
165 165
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
       $unit_level = $row['unit_level'];
168 168
       $price = get_unit_param($unit_id, P_COST);
169 169
       $factor = $price['factor'];
170
-      foreach($price as $resource_id => &$resource_amount) {
170
+      foreach ($price as $resource_id => &$resource_amount) {
171 171
         $resource_amount = $resource_amount * (pow($factor, $unit_level) - 1) / ($factor - 1);
172 172
       }
173 173
       // upd_do_query
@@ -186,14 +186,14 @@  discard block
 block discarded – undo
186 186
     // Вернуть ресы за уже исследованную Экспедиционную технологию
187 187
     upd_check_key('player_max_colonies', -1, classSupernova::$config->player_max_colonies >= 0);
188 188
 
189
-    if(!isset($update_tables['users']['player_rpg_explore_xp'])) {
189
+    if (!isset($update_tables['users']['player_rpg_explore_xp'])) {
190 190
       upd_alter_table('users', array(
191 191
         "ADD COLUMN `player_rpg_explore_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`",
192 192
         "ADD COLUMN `player_rpg_explore_xp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`",
193 193
       ), !isset($update_tables['users']['player_rpg_explore_xp']));
194 194
     }
195 195
 
196
-    if(!$update_tables['log_users_online']) {
196
+    if (!$update_tables['log_users_online']) {
197 197
       upd_create_table('log_users_online', "(
198 198
         `online_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Measure time',
199 199
         `online_count` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Users online',
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
       "ADD `user_time_measured` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'When was time diff measured last time' AFTER `onlinetime`",
209 209
     ), !$update_tables['users']['user_time_measured']);
210 210
 
211
-    if($update_tables['rw']) {
211
+    if ($update_tables['rw']) {
212 212
       upd_do_query("DROP TABLE IF EXISTS {{rw}};");
213 213
     }
214 214
 
215
-    if(!$update_tables['player_award']) {
215
+    if (!$update_tables['player_award']) {
216 216
       upd_create_table('player_award', "(
217 217
         `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
218 218
         `award_type_id` int(11) DEFAULT NULL COMMENT 'Award type i.e. order, medal, pennant, rank etc',
@@ -254,14 +254,14 @@  discard block
 block discarded – undo
254 254
     upd_log_version_update();
255 255
 
256 256
 
257
-    if(!isset($update_tables['planets']['que_processed'])) {
257
+    if (!isset($update_tables['planets']['que_processed'])) {
258 258
       upd_alter_table('planets', array(
259 259
         "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `last_update`",
260 260
       ), true);
261 261
       upd_do_query("UPDATE {{planets}} SET que_processed = last_update;");
262 262
     }
263 263
 
264
-    if(!isset($update_tables['users']['que_processed'])) {
264
+    if (!isset($update_tables['users']['que_processed'])) {
265 265
       upd_alter_table('users', array(
266 266
         "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `onlinetime`",
267 267
       ), true);
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
     }
270 270
 
271 271
 
272
-    if(isset($update_tables['planets']['que'])) {
272
+    if (isset($update_tables['planets']['que'])) {
273 273
       $sn_data_aux = array(
274 274
         SHIP_SMALL_FIGHTER_WRATH    => array(
275 275
           'name' => 'ship_fighter_wrath',
@@ -354,20 +354,20 @@  discard block
 block discarded – undo
354 354
       $unit_data = array();
355 355
       $planets = array();
356 356
 
357
-      foreach($planet_unit_list as $unit_id) {
358
-        if(!($unit_name = get_unit_param($unit_id, P_NAME))) {
357
+      foreach ($planet_unit_list as $unit_id) {
358
+        if (!($unit_name = get_unit_param($unit_id, P_NAME))) {
359 359
           $unit_name = $sn_data_aux[$unit_id][P_NAME];
360 360
         }
361
-        if(isset($update_tables['planets'][$unit_name])) {
361
+        if (isset($update_tables['planets'][$unit_name])) {
362 362
           $drop[] = "DROP COLUMN `{$unit_name}`";
363 363
 
364
-          if(isset($aux_group[$unit_id])) {
364
+          if (isset($aux_group[$unit_id])) {
365 365
             $units_info[$unit_id] = $sn_data_aux[$unit_id];
366 366
             $units_info[$unit_id]['que'] = QUE_HANGAR;
367 367
           } else {
368 368
             $units_info[$unit_id] = get_unit_param($unit_id);
369
-            foreach($ques_info as $que_id => $que_data1) {
370
-              if(in_array($unit_id, $que_data1['unit_list'])) {
369
+            foreach ($ques_info as $que_id => $que_data1) {
370
+              if (in_array($unit_id, $que_data1['unit_list'])) {
371 371
                 $units_info[$unit_id]['que'] = $que_id;
372 372
                 break;
373 373
               }
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
       }
378 378
 
379 379
       $query = upd_do_query("SELECT * FROM {{planets}} FOR UPDATE");
380
-      while($row = db_fetch($query)) {
380
+      while ($row = db_fetch($query)) {
381 381
         $user_id = $row['id_owner'];
382 382
         $planet_id = $row['id'];
383 383
 
@@ -385,14 +385,14 @@  discard block
 block discarded – undo
385 385
 
386 386
         // Конвертируем юниты
387 387
         $units_levels = array();
388
-        foreach($planet_unit_list as $unit_id) {
388
+        foreach ($planet_unit_list as $unit_id) {
389 389
           $unit_name = &$units_info[$unit_id][P_NAME];
390
-          if(!isset($row[$unit_name]) || !$row[$unit_name]) {
390
+          if (!isset($row[$unit_name]) || !$row[$unit_name]) {
391 391
             continue;
392 392
           }
393 393
           $units_levels[$unit_id] = $row[$unit_name];
394 394
           $unit_data[] = "({$user_id}," . LOC_PLANET . ",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})";
395
-          if(count($unit_data) > 30) {
395
+          if (count($unit_data) > 30) {
396 396
             $unit_data_max = strlen(implode(',', $unit_data)) > $unit_data_max ? strlen(implode(',', $unit_data)) : $unit_data_max;
397 397
             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) . ';');
398 398
             $unit_data = array();
@@ -400,10 +400,10 @@  discard block
 block discarded – undo
400 400
         }
401 401
 
402 402
         // Конвертируем очередь построек
403
-        if($row['que']) {
403
+        if ($row['que']) {
404 404
           $que = explode(';', $row['que']);
405
-          foreach($que as $que_item) {
406
-            if(!$que_item) {
405
+          foreach ($que as $que_item) {
406
+            if (!$que_item) {
407 407
               continue;
408 408
             }
409 409
 
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
             $unit_factor = $unit_cost[P_FACTOR] ? $unit_cost[P_FACTOR] : 1;
419 419
             $price_increase = pow($unit_factor, $unit_level);
420 420
             // $unit_time = 0;
421
-            foreach($unit_cost as $resource_id => &$resource_amount) {
422
-              if(!in_array($resource_id, $group_resource_loot)) {
421
+            foreach ($unit_cost as $resource_id => &$resource_amount) {
422
+              if (!in_array($resource_id, $group_resource_loot)) {
423 423
                 unset($unit_cost[$resource_id]);
424 424
                 continue;
425 425
               }
@@ -433,38 +433,38 @@  discard block
 block discarded – undo
433 433
         }
434 434
 
435 435
         // Конвертируем очередь верфи
436
-        if($row['b_hangar_id']) {
436
+        if ($row['b_hangar_id']) {
437 437
           $return_resources = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0,);
438 438
           $hangar_units = sys_unit_str2arr($row['b_hangar_id']);
439
-          foreach($hangar_units as $unit_id => $unit_count) {
440
-            if($unit_count <= 0) {
439
+          foreach ($hangar_units as $unit_id => $unit_count) {
440
+            if ($unit_count <= 0) {
441 441
               continue;
442 442
             }
443
-            foreach($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) {
444
-              if(!in_array($resource_id, $group_resource_loot)) {
443
+            foreach ($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) {
444
+              if (!in_array($resource_id, $group_resource_loot)) {
445 445
                 continue;
446 446
               }
447 447
               $return_resources[$resource_id] += $unit_count * $resource_amount;
448 448
             }
449 449
           }
450
-          if(array_sum($return_resources) > 0) {
450
+          if (array_sum($return_resources) > 0) {
451 451
             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");
452 452
           }
453 453
         }
454 454
 
455 455
 
456
-        if(count($que_data) > 10) {
456
+        if (count($que_data) > 10) {
457 457
           $que_data_max = strlen(implode(',', $que_data)) > $que_data_max ? strlen(implode(',', $que_data)) : $que_data_max;
458 458
           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) . ';');
459 459
           $que_data = array();
460 460
         }
461 461
       }
462 462
 
463
-      if(!empty($unit_data)) {
463
+      if (!empty($unit_data)) {
464 464
         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) . ';');
465 465
       }
466 466
 
467
-      if(!empty($que_data)) {
467
+      if (!empty($que_data)) {
468 468
         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) . ';');
469 469
       }
470 470
 
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
571 571
       "ADD CONSTRAINT `FK_users_browser_id` FOREIGN KEY (`user_last_browser_id`) REFERENCES `{{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 `galaxy` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `title`",
577 577
         "ADD COLUMN `system` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `galaxy`",
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
     upd_alter_table('users', "ADD COLUMN `user_bot` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['users']['user_bot']));
590 590
     upd_alter_table('unit', "ADD KEY `I_unit_type_snid` (unit_type, unit_snid) USING BTREE", !$update_indexes['unit']['I_unit_type_snid']);
591 591
 
592
-    if($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') {
592
+    if ($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') {
593 593
       upd_alter_table('users', array(
594 594
         "MODIFY COLUMN `settings_tooltiptime` smallint(5) unsigned NOT NULL DEFAULT '500'",
595 595
       ), $update_tables['users']['settings_tooltiptime']['Type'] != 'smallint');
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
       upd_do_query("UPDATE `{{users}}` SET settings_tooltiptime = 500;");
598 598
     }
599 599
 
600
-    if(!isset($update_tables['log_users_online']['online_aggregated'])) {
600
+    if (!isset($update_tables['log_users_online']['online_aggregated'])) {
601 601
       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']));
602 602
       upd_alter_table('log_users_online', array(
603 603
         "DROP PRIMARY KEY",
@@ -605,13 +605,13 @@  discard block
 block discarded – undo
605 605
       ), $update_indexes['log_users_online']['PRIMARY'] != 'online_timestamp,online_aggregated,');
606 606
     }
607 607
 
608
-    if(!isset($update_tables['users']['gender'])) {
608
+    if (!isset($update_tables['users']['gender'])) {
609 609
       upd_alter_table('users', "ADD COLUMN `gender` TINYINT(1) UNSIGNED NOT NULL DEFAULT " . GENDER_UNKNOWN, !isset($update_tables['users']['gender']));
610 610
       upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', " . GENDER_FEMALE . ", IF(UPPER(`sex`) = 'M', " . GENDER_MALE . ", " . GENDER_UNKNOWN . "));");
611 611
     }
612 612
     upd_alter_table('users', "DROP COLUMN `sex`", isset($update_tables['users']['sex']));
613 613
 
614
-    if(!$update_tables['users']['dark_matter_total']) {
614
+    if (!$update_tables['users']['dark_matter_total']) {
615 615
       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']);
616 616
       upd_do_query(
617 617
         "UPDATE `{{users}}` AS u
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
     }
625 625
 
626 626
     upd_check_key('player_metamatter_immortal', 100000, !isset(classSupernova::$config->player_metamatter_immortal));
627
-    if(!$update_tables['users']['metamatter_total']) {
627
+    if (!$update_tables['users']['metamatter_total']) {
628 628
       upd_alter_table('users', "ADD `metamatter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Metamatter amount ever bought'", !$update_tables['users']['metamatter_total']);
629 629
 
630 630
       upd_do_query(
@@ -636,11 +636,11 @@  discard block
 block discarded – undo
636 636
             (SELECT IF(sum(amount) IS NULL, 0, sum(amount)) FROM {{log_metamatter}} AS mm WHERE mm.user_id = u.id AND mm.amount > 0)
637 637
           );");
638 638
     }
639
-    if(!isset($update_tables['users']['immortal'])) {
639
+    if (!isset($update_tables['users']['immortal'])) {
640 640
       upd_alter_table('users', "ADD COLUMN `immortal` TIMESTAMP NULL", !isset($update_tables['users']['immortal']));
641 641
       upd_do_query("UPDATE {{users}} SET `immortal` = NOW() WHERE `metamatter_total` > 0;");
642 642
     }
643
-    if(isset($update_tables['player_award'])) {
643
+    if (isset($update_tables['player_award'])) {
644 644
       upd_do_query(
645 645
         "UPDATE {{users}} AS u JOIN {{player_award}} AS pa ON u.id = pa.player_id
646 646
           SET metamatter_total = 1, immortal = NOW()
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
       CONSTRAINT `FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
668 668
     ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
669 669
 
670
-    if(empty($update_tables['blitz_statpoints'])) {
670
+    if (empty($update_tables['blitz_statpoints'])) {
671 671
       upd_create_table('blitz_statpoints', " (
672 672
         `stat_date` int(11) NOT NULL DEFAULT '0',
673 673
         `id_owner` bigint(20) unsigned DEFAULT NULL,
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
       CONSTRAINT `FK_survey_votes_survey_parent_id` FOREIGN KEY (`survey_parent_id`) REFERENCES `{{survey}}` (`survey_id`) ON DELETE CASCADE ON UPDATE CASCADE
736 736
     ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
737 737
 
738
-    if(empty($update_tables['security_url'])) {
738
+    if (empty($update_tables['security_url'])) {
739 739
       upd_create_table('security_url', " (
740 740
         `url_id` int unsigned NOT NULL AUTO_INCREMENT,
741 741
         `url_string` VARCHAR(250) NOT NULL DEFAULT '',
@@ -748,9 +748,9 @@  discard block
 block discarded – undo
748 748
 
749 749
         $strings = array();
750 750
         $query = classSupernova::$db->doSql($query);
751
-        while($row = db_fetch($query)) {
751
+        while ($row = db_fetch($query)) {
752 752
           $strings[] = '("' . db_escape($row['url']) . '")';
753
-          if(count($strings) > 100) {
753
+          if (count($strings) > 100) {
754 754
             classSupernova::$db->doSql($query_string . implode(',', $strings));
755 755
             $strings = array();
756 756
           }
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
         !empty($strings) ? classSupernova::$db->doSql($query_string . implode(',', $strings)) : false;
759 759
       }
760 760
 
761
-      if(isset($update_tables['counter']['page'])) // TODO REMOVE
761
+      if (isset($update_tables['counter']['page'])) // TODO REMOVE
762 762
       {
763 763
         update_security_url("SELECT DISTINCT `page` AS url FROM {{counter}}");
764 764
         update_security_url("SELECT DISTINCT `url` AS url FROM {{counter}}");
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
       "ADD CONSTRAINT `FK_counter_page_url_id` FOREIGN KEY (`page_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE",
784 784
       "ADD CONSTRAINT `FK_counter_plain_url_id` FOREIGN KEY (`plain_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE",
785 785
     ), !isset($update_tables['counter']['device_id']));
786
-    if(isset($update_tables['counter']['ip'])) {
786
+    if (isset($update_tables['counter']['ip'])) {
787 787
       // upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `user_proxy` = `proxy`, `visit_time` = FROM_UNIXTIME(`time`)');
788 788
       upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `visit_time` = FROM_UNIXTIME(`time`)');
789 789
       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');
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 
835 835
     upd_check_key('stats_history_days', 14, !classSupernova::$config->stats_history_days);
836 836
 
837
-    if(classSupernova::$config->payment_currency_default != 'USD') {
837
+    if (classSupernova::$config->payment_currency_default != 'USD') {
838 838
       upd_check_key('payment_currency_default', 'USD', true);
839 839
       upd_check_key('payment_currency_exchange_dm_', 20000, true);
840 840
       upd_check_key('payment_currency_exchange_mm_', 20000, true);
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
     function propagade_player_options($old_option_name, $new_option_id) {
918 918
       global $update_tables;
919 919
 
920
-      if(!empty($update_tables['users'][$old_option_name])) {
920
+      if (!empty($update_tables['users'][$old_option_name])) {
921 921
         upd_do_query(
922 922
           "REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`)
923 923
           SELECT `id`, {$new_option_id}, `{$old_option_name}`
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
 
952 952
 
953 953
     // 2015-08-03 15:05:26 40a6.0
954
-    if(empty($update_tables['planets']['position_original'])) {
954
+    if (empty($update_tables['planets']['position_original'])) {
955 955
       upd_alter_table('planets', array(
956 956
         "ADD COLUMN `position_original` smallint NOT NULL DEFAULT 0",
957 957
         "ADD COLUMN `field_max_original` smallint NOT NULL DEFAULT 0",
@@ -979,12 +979,12 @@  discard block
 block discarded – undo
979 979
 
980 980
     // 2015-08-27 19:14:05 40a10.0
981 981
     // Старая версия таблицы
982
-    if(!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) {
982
+    if (!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) {
983 983
       upd_drop_table('account');
984 984
       upd_drop_table('account_translate');
985 985
     }
986 986
 
987
-    if(empty($update_tables['account'])) {
987
+    if (empty($update_tables['account'])) {
988 988
       upd_create_table('account', " (
989 989
           `account_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
990 990
           `account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT '',
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 
1047 1047
 
1048 1048
     // 2015-09-24 11:39:37 40a10.25
1049
-    if(empty($update_tables['log_metamatter']['provider_id'])) {
1049
+    if (empty($update_tables['log_metamatter']['provider_id'])) {
1050 1050
       upd_alter_table('log_metamatter', array(
1051 1051
         "ADD COLUMN `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Account provider'",
1052 1052
         "ADD COLUMN `account_id` bigint(20) unsigned NOT NULL DEFAULT 0",
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
     upd_check_key('event_halloween_2015_code', '', !isset(classSupernova::$config->event_halloween_2015_code));
1099 1099
     upd_check_key('event_halloween_2015_timestamp', SN_TIME_SQL, !isset(classSupernova::$config->event_halloween_2015_timestamp));
1100 1100
     upd_check_key('event_halloween_2015_units_used', serialize(array()), !isset(classSupernova::$config->event_halloween_2015_units_used));
1101
-    if(empty($update_tables['log_halloween_2015'])) {
1101
+    if (empty($update_tables['log_halloween_2015'])) {
1102 1102
       upd_create_table('log_halloween_2015', " (
1103 1103
       `log_hw2015_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1104 1104
       `player_id` bigint(20) unsigned NOT NULL COMMENT 'User ID',
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 
1114 1114
 
1115 1115
     // 2015-11-28 06:30:27 40a19.21
1116
-    if(!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) {
1116
+    if (!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) {
1117 1117
       upd_alter_table('ube_report', array(
1118 1118
         "ADD COLUMN `ube_report_debris_total_in_metal` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Total debris in metal'",
1119 1119
         "ADD KEY `I_ube_report_time_debris_id` (`ube_report_time_process` DESC, `ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC)", // For Best Battles module
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
 
1129 1129
 
1130 1130
     // 2015-12-06 15:10:58 40b1.0
1131
-    if(!empty($update_indexes['planets']['I_metal_mine'])) {
1131
+    if (!empty($update_indexes['planets']['I_metal_mine'])) {
1132 1132
       upd_alter_table('planets', "DROP KEY `I_metal`", $update_indexes['planets']['I_metal']);
1133 1133
       upd_alter_table('planets', "DROP KEY `I_ship_sattelite_sloth`", $update_indexes['planets']['I_ship_sattelite_sloth']);
1134 1134
       upd_alter_table('planets', "DROP KEY `I_ship_bomber_envy`", $update_indexes['planets']['I_ship_bomber_envy']);
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
   case 40:
1192 1192
     upd_log_version_update();
1193 1193
 
1194
-    if(empty($update_tables['festival'])) {
1194
+    if (empty($update_tables['festival'])) {
1195 1195
       upd_create_table('festival', " (
1196 1196
           `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
1197 1197
           `start` datetime NOT NULL COMMENT 'Festival start datetime',
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
       );
1233 1233
     }
1234 1234
 
1235
-    if(empty($update_tables['festival_unit'])) {
1235
+    if (empty($update_tables['festival_unit'])) {
1236 1236
       upd_create_table('festival_unit', " (
1237 1237
           `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1238 1238
           `highspot_id` int(10) unsigned DEFAULT NULL,
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
     }
1250 1250
 
1251 1251
     // 2015-12-21 06:06:09 41a0.12
1252
-    if(empty($update_tables['festival_unit_log'])) {
1252
+    if (empty($update_tables['festival_unit_log'])) {
1253 1253
       upd_create_table('festival_unit_log', " (
1254 1254
           `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1255 1255
           `highspot_id` int(10) unsigned DEFAULT NULL,
@@ -1279,16 +1279,16 @@  discard block
 block discarded – undo
1279 1279
       $update_tables['security_browser']['browser_user_agent']['Collation'] == 'latin1_bin'
1280 1280
     );
1281 1281
 
1282
-    if($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') {
1282
+    if ($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') {
1283 1283
       upd_alter_table('security_browser', "DROP KEY `I_browser_user_agent`", true);
1284 1284
       upd_alter_table('security_browser', "ADD KEY `I_browser_user_agent` (`browser_user_agent`) USING HASH", true);
1285 1285
     }
1286 1286
 
1287
-    if(!empty($update_tables['fleets']['fleet_array'])) {
1287
+    if (!empty($update_tables['fleets']['fleet_array'])) {
1288 1288
       $query = upd_do_query("SELECT * FROM {{fleets}}");
1289
-      while($row = db_fetch($query)) {
1289
+      while ($row = db_fetch($query)) {
1290 1290
         $unit_list = sys_unit_str2arr($row['fleet_array']);
1291
-        foreach($unit_list as $unit_id => $unit_count) {
1291
+        foreach ($unit_list as $unit_id => $unit_count) {
1292 1292
           upd_do_query(
1293 1293
             "REPLACE INTO {{unit}} (`unit_player_id`,`unit_location_type`,`unit_location_id`,`unit_type`,`unit_snid`,`unit_level`) VALUES
1294 1294
               ({$row['fleet_owner']}, " . LOC_FLEET . ", {$row['fleet_id']}, 200, {$unit_id}, {$unit_count});",
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
 
1326 1326
 classSupernova::$cache->unset_by_prefix('lng_');
1327 1327
 
1328
-if($new_version) {
1328
+if ($new_version) {
1329 1329
   classSupernova::$config->db_saveItem('db_version', $new_version);
1330 1330
   upd_log_message("<font color=green>DB version is now {$new_version}</font>");
1331 1331
 } else {
Please login to merge, or discard this patch.