Completed
Branch work-fleets (4d76fa)
by SuperNova.WS
05:23
created
includes/includes/mrc_mercenary.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -26,6 +26,10 @@
 block discarded – undo
26 26
   return true;
27 27
 }
28 28
 
29
+/**
30
+ * @param integer $mode
31
+ * @param integer $mercenary_id
32
+ */
29 33
 function mrc_mercenary_hire($mode, $user, $mercenary_id) {
30 34
   global $config, $lang, $sn_powerup_buy_discounts;
31 35
 
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -4,13 +4,13 @@  discard block
 block discarded – undo
4 4
 
5 5
 function mrc_officer_accessible(&$user, $mercenary_id) {
6 6
   $mercenary_info = get_unit_param($mercenary_id);
7
-  if(classSupernova::$config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) {
7
+  if (classSupernova::$config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) {
8 8
     return true;
9 9
   }
10 10
 
11
-  if(isset($mercenary_info[P_REQUIRE])) {
12
-    foreach($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) {
13
-      if(mrc_get_level($user, null, $unit_id) < $unit_level) {
11
+  if (isset($mercenary_info[P_REQUIRE])) {
12
+    foreach ($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) {
13
+      if (mrc_get_level($user, null, $unit_id) < $unit_level) {
14 14
         return false;
15 15
       }
16 16
     }
@@ -26,35 +26,35 @@  discard block
 block discarded – undo
26 26
     $is_permanent = $mode == UNIT_PLANS || !classSupernova::$config->empire_mercenary_temporary;
27 27
     $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? classSupernova::$config->ali_bonus_members : 1);
28 28
     $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1;
29
-    if(!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) {
29
+    if (!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) {
30 30
       throw new Exception(classLocale::$lang['mrc_msg_error_wrong_mercenary'], ERR_ERROR);
31 31
     }
32 32
 
33
-    if(!mrc_officer_accessible($user, $mercenary_id)) {
33
+    if (!mrc_officer_accessible($user, $mercenary_id)) {
34 34
       throw new Exception(classLocale::$lang['mrc_msg_error_requirements'], ERR_ERROR);
35 35
     }
36 36
 
37 37
     $mercenary_level = sys_get_param_int('mercenary_level');
38
-    if($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) {
38
+    if ($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) {
39 39
       throw new Exception(classLocale::$lang['mrc_msg_error_wrong_level'], ERR_ERROR);
40 40
     }
41 41
 
42
-    if($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) {
42
+    if ($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) {
43 43
       throw new Exception(classLocale::$lang['mrc_msg_error_wrong_period'], ERR_ERROR);
44 44
     }
45 45
 
46 46
     sn_db_transaction_start();
47 47
 
48 48
     $mercenary_level_old = mrc_get_level($user, $planetrow, $mercenary_id, true, true);
49
-    if(classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) {
49
+    if (classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) {
50 50
       throw new Exception(classLocale::$lang['mrc_msg_error_already_hired'], ERR_ERROR); // Can't hire already hired temp mercenary - dismiss first
51
-    } elseif(classSupernova::$config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) {
51
+    } elseif (classSupernova::$config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) {
52 52
       throw new Exception('', ERR_NONE); // Can't dismiss (!$mercenary_level) not hired (!$mercenary_level_old) temp mercenary. But no error
53 53
     }
54 54
 
55
-    if($mercenary_level) {
55
+    if ($mercenary_level) {
56 56
       $darkmater_cost = eco_get_total_cost($mercenary_id, $mercenary_level);
57
-      if(!classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old) {
57
+      if (!classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old) {
58 58
         $darkmater_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level_old);
59 59
         $darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] -= $darkmater_cost_old[BUILD_CREATE][RES_DARK_MATTER];
60 60
       }
@@ -64,13 +64,13 @@  discard block
 block discarded – undo
64 64
     }
65 65
     $darkmater_cost *= $cost_alliance_multiplyer;
66 66
 
67
-    if(mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) {
67
+    if (mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) {
68 68
       throw new Exception(classLocale::$lang['mrc_msg_error_no_resource'], ERR_ERROR);
69 69
     }
70 70
 
71
-    if(($darkmater_cost && $mercenary_level) || !$is_permanent) {
71
+    if (($darkmater_cost && $mercenary_level) || !$is_permanent) {
72 72
       $unit_row = db_unit_by_location($user['id'], LOC_USER, $user['id'], $mercenary_id);
73
-      if(is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) {
73
+      if (is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) {
74 74
         $dismiss_full_cost = eco_get_total_cost($mercenary_id, $unit_row['unit_level']);
75 75
         $dismiss_full_cost = $dismiss_full_cost[BUILD_CREATE][RES_DARK_MATTER];
76 76
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
       db_unit_list_delete($user['id'], LOC_USER, $user['id'], $mercenary_id);
84 84
     }
85 85
 
86
-    if($darkmater_cost && $mercenary_level) {
86
+    if ($darkmater_cost && $mercenary_level) {
87 87
       db_unit_set_insert(
88 88
         "unit_player_id = {$user['id']},
89 89
         unit_location_type = " . LOC_USER . ",
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     }
101 101
     sn_db_transaction_commit();
102 102
     sys_redirect($_SERVER['REQUEST_URI']);
103
-  } catch(Exception $e) {
103
+  } catch (Exception $e) {
104 104
     sn_db_transaction_rollback();
105 105
     $operation_result = array(
106 106
       'STATUS'  => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR,
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
   $mode = in_array($mode, array(UNIT_MERCENARIES, UNIT_PLANS)) ? $mode : UNIT_MERCENARIES;
119 119
   $is_permanent = $mode == UNIT_PLANS || !classSupernova::$config->empire_mercenary_temporary;
120 120
 
121
-  if($mercenary_id = sys_get_param_int('mercenary_id')) {
121
+  if ($mercenary_id = sys_get_param_int('mercenary_id')) {
122 122
     $operation_result = mrc_mercenary_hire($mode, $user, $mercenary_id);
123 123
   }
124 124
 
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 
127 127
   $template = gettemplate('mrc_mercenary_hire', true);
128 128
 
129
-  if(!empty($operation_result)) {
129
+  if (!empty($operation_result)) {
130 130
     $template->assign_block_vars('result', $operation_result);
131 131
   }
132 132
 
133
-  foreach($sn_powerup_buy_discounts as $hire_period => $hire_discount) {
133
+  foreach ($sn_powerup_buy_discounts as $hire_period => $hire_discount) {
134 134
     $template->assign_block_vars('period', array(
135 135
       'LENGTH'   => $hire_period,
136 136
       'TEXT'     => classLocale::$lang['mrc_period_list'][$hire_period],
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
   $user_dark_matter = mrc_get_level($user, null, RES_DARK_MATTER);
143 143
   $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? classSupernova::$config->ali_bonus_members : 1);
144 144
   $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1;
145
-  foreach(sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) {
145
+  foreach (sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) {
146 146
     {
147 147
       $mercenary = get_unit_param($mercenary_id);
148 148
       $mercenary_bonus = $mercenary['bonus'];
149 149
       $mercenary_bonus = $mercenary_bonus >= 0 ? "+{$mercenary_bonus}" : "{$mercenary_bonus}";
150
-      switch($mercenary['bonus_type']) {
150
+      switch ($mercenary['bonus_type']) {
151 151
         case BONUS_PERCENT:
152 152
           $mercenary_bonus = "{$mercenary_bonus}% ";
153 153
         break;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
       $mercenary_level = mrc_get_level($user, null, $mercenary_id, false, true);
165 165
       $mercenary_level_bonus = max(0, mrc_get_level($user, null, $mercenary_id) - $mercenary_level);
166 166
       $total_cost_old = 0;
167
-      if($is_permanent) {
167
+      if ($is_permanent) {
168 168
         $total_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level);
169 169
         $total_cost_old = $total_cost_old[BUILD_CREATE][RES_DARK_MATTER] * $cost_alliance_multiplyer;
170 170
       }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
       ));
194 194
 
195 195
       $upgrade_cost = 1;
196
-      for($i = classSupernova::$config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) {
196
+      for ($i = classSupernova::$config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) {
197 197
         $total_cost = eco_get_total_cost($mercenary_id, $i);
198 198
         $total_cost[BUILD_CREATE][RES_DARK_MATTER] *= $cost_alliance_multiplyer;
199 199
         $upgrade_cost = $total_cost[BUILD_CREATE][RES_DARK_MATTER] - $total_cost_old;
Please login to merge, or discard this patch.
resources.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
   ));
47 47
 };
48 48
 
49
-$ValidList['percent'] = array (  0,  10,  20,  30,  40,  50,  60,  70,  80,  90, 100 );
49
+$ValidList['percent'] = array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100);
50 50
 $template = gettemplate('resources', true);
51 51
 
52 52
 $transmutation_result = sn_sys_planet_core_transmute($user, $planetrow);
53
-if(!empty($transmutation_result))
53
+if (!empty($transmutation_result))
54 54
 {
55 55
   $template->assign_block_vars('result', $transmutation_result); // array('STATUS' => $transmutation_result['STATUS'], 'MESSAGE' => $transmutation_result['MESSAGE']));
56 56
 }
@@ -59,20 +59,20 @@  discard block
 block discarded – undo
59 59
 $production = $_POST['production'];
60 60
 //$SubQry     = '';
61 61
 $SubQry     = array();
62
-if(is_array($production)) {
63
-  foreach($production as $prod_id => $percent) {
64
-    if($percent > 100 || $percent < 0) {
62
+if (is_array($production)) {
63
+  foreach ($production as $prod_id => $percent) {
64
+    if ($percent > 100 || $percent < 0) {
65 65
       $debug->warning('Supplying wrong production percent (less then 0 or greater then 100)', 'Hack attempt', 302, array('base_dump' => true));
66 66
       die();
67 67
     }
68 68
 
69 69
     $prod_id = intval($prod_id);
70
-    if(in_array($prod_id, $sn_group_factories) && get_unit_param($prod_id, P_MINING_IS_MANAGED)) {
70
+    if (in_array($prod_id, $sn_group_factories) && get_unit_param($prod_id, P_MINING_IS_MANAGED)) {
71 71
       $field_name              = pname_factory_production_field_name($prod_id);
72 72
       $percent                 = floor($percent / 10);
73 73
       $planetrow[$field_name]  = $percent;
74 74
       //$SubQry                 .= "`{$field_name}` = '{$percent}',";
75
-      $SubQry[]                 = "`{$field_name}` = '{$percent}'";
75
+      $SubQry[] = "`{$field_name}` = '{$percent}'";
76 76
     } else {
77 77
       $debug->warning('Supplying wrong ID in production array - attempt to change some field - ID' . $prod_id, 'Resource Page', 301);
78 78
       continue;
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
   'ENERGY_TYPE'    => pretty_number($caps_real['production'][RES_ENERGY][0], true, true),
109 109
 ));
110 110
 
111
-foreach($sn_group_factories as $unit_id)
111
+foreach ($sn_group_factories as $unit_id)
112 112
 {
113
-  if(mrc_get_level($user, $planetrow, $unit_id) > 0 && get_unit_param($unit_id))
113
+  if (mrc_get_level($user, $planetrow, $unit_id) > 0 && get_unit_param($unit_id))
114 114
   {
115 115
     $level_plain = mrc_get_level($user, $planetrow, $unit_id, false, true);
116 116
     $template->assign_block_vars('production', array(
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
 
93 93
 for ($Option = 10; $Option >= 0; $Option--)
94 94
 {
95
- $template->assign_block_vars('option', array(
96
-   'VALUE' => $Option * 10,
97
- ));
95
+  $template->assign_block_vars('option', array(
96
+    'VALUE' => $Option * 10,
97
+  ));
98 98
 }
99 99
 
100 100
 $caps_real = eco_get_planet_caps($user, $planetrow, 3600);
@@ -163,14 +163,14 @@  discard block
 block discarded – undo
163 163
 int_calc_storage_bar(RES_DEUTERIUM);
164 164
 
165 165
 $template->assign_vars(array(
166
- 'PLANET_NAME'          => $planetrow['name'],
167
- 'PLANET_TYPE'          => $planetrow['planet_type'],
168
- 'PLANET_DENSITY_INDEX' => $planet_density_index,
169
- 'PLANET_CORE_TEXT'     => classLocale::$lang['uni_planet_density_types'][$planet_density_index],
166
+  'PLANET_NAME'          => $planetrow['name'],
167
+  'PLANET_TYPE'          => $planetrow['planet_type'],
168
+  'PLANET_DENSITY_INDEX' => $planet_density_index,
169
+  'PLANET_CORE_TEXT'     => classLocale::$lang['uni_planet_density_types'][$planet_density_index],
170 170
 
171
- 'PRODUCTION_LEVEL'     => floor($caps_real['efficiency'] * 100),
171
+  'PRODUCTION_LEVEL'     => floor($caps_real['efficiency'] * 100),
172 172
 
173
- 'PAGE_HINT'            => classLocale::$lang['res_hint'],
173
+  'PAGE_HINT'            => classLocale::$lang['res_hint'],
174 174
 ));
175 175
 
176 176
 display($template, classLocale::$lang['res_planet_production']);
Please login to merge, or discard this patch.
admin/adm_user_analyze.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,8 +39,8 @@
 block discarded – undo
39 39
     0 => $row['visit_time'], // start
40 40
     1 => $row['visit_time'], // end
41 41
   )
42
-   //: false
43
-   ;
42
+    //: false
43
+    ;
44 44
 }
45 45
 
46 46
 $session_list = array();
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -12,20 +12,20 @@  discard block
 block discarded – undo
12 12
 
13 13
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
14 14
 
15
-if($user['authlevel'] < 3) {
15
+if ($user['authlevel'] < 3) {
16 16
   AdminMessage($lang['adm_err_denied']);
17 17
 }
18 18
 
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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>");
Please login to merge, or discard this patch.
admin/add_moon.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@
 block discarded – undo
14 14
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
15 15
 
16 16
 // if ($user['authlevel'] < 2)
17
-if($user['authlevel'] < 3)
17
+if ($user['authlevel'] < 3)
18 18
 {
19 19
   AdminMessage($lang['adm_err_denied']);
20 20
 }
21 21
 
22 22
 $template = gettemplate("admin/add_moon", true);
23 23
 
24
-if(sys_get_param_str('mode') == 'addit')
24
+if (sys_get_param_str('mode') == 'addit')
25 25
 {
26 26
   $PlanetID = sys_get_param_id('user');
27 27
   $MoonName = sys_get_param_str('name');
Please login to merge, or discard this patch.
admin/planet_edit.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
8 8
 
9 9
 // if($user['authlevel'] < 2)
10
-if($user['authlevel'] < 3)
10
+if ($user['authlevel'] < 3)
11 11
 {
12 12
   AdminMessage($lang['adm_err_denied']);
13 13
 }
@@ -21,30 +21,30 @@  discard block
 block discarded – undo
21 21
 $planet_id = sys_get_param_id('planet_id');
22 22
 
23 23
 $unit_list = sys_get_param('unit_list');
24
-if(sys_get_param('change_data') && !empty($unit_list))
24
+if (sys_get_param('change_data') && !empty($unit_list))
25 25
 {
26 26
   $query_string = array();
27
-  foreach($unit_list as $unit_id => $unit_amount)
27
+  foreach ($unit_list as $unit_id => $unit_amount)
28 28
   {
29
-    if($unit_query_string = admin_planet_edit_query_string($unit_id, $unit_amount, $mode))
29
+    if ($unit_query_string = admin_planet_edit_query_string($unit_id, $unit_amount, $mode))
30 30
     {
31 31
       $query_string[] = $unit_query_string;
32 32
     }
33 33
   }
34 34
 
35
-  if(!empty($query_string))
35
+  if (!empty($query_string))
36 36
   {
37 37
     db_planet_set_by_id($planet_id, implode(', ', $query_string));
38 38
   }
39 39
 }
40 40
 
41
-if($planet_id)
41
+if ($planet_id)
42 42
 {
43 43
   $edit_planet_row = db_planet_by_id($planet_id);
44 44
   admin_planet_edit_template($template, $edit_planet_row, $mode);
45 45
 }
46 46
 
47
-foreach($admin_planet_edit_mode_list as $page_mode => $mode_locale)
47
+foreach ($admin_planet_edit_mode_list as $page_mode => $mode_locale)
48 48
 {
49 49
   $template->assign_block_vars('page_menu', array(
50 50
     'ID' => $page_mode,
Please login to merge, or discard this patch.
admin/adm_quest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-define('INSIDE'  , true);
11
-define('INSTALL' , false);
12
-define('IN_ADMIN'  , true);
10
+define('INSIDE', true);
11
+define('INSTALL', false);
12
+define('IN_ADMIN', true);
13 13
 
14 14
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
15 15
 
16
-if($user['authlevel'] < 2)
16
+if ($user['authlevel'] < 2)
17 17
 {
18 18
   AdminMessage($lang['adm_err_denied']);
19 19
 }
Please login to merge, or discard this patch.
admin/admin_locale.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -7,25 +7,25 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-define('INSIDE'  , true);
11
-define('INSTALL' , false);
12
-define('IN_ADMIN'  , true);
10
+define('INSIDE', true);
11
+define('INSTALL', false);
12
+define('IN_ADMIN', true);
13 13
 
14 14
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
15 15
 
16
-if($user['authlevel'] < 3) {
16
+if ($user['authlevel'] < 3) {
17 17
   AdminMessage($lang['adm_err_denied']);
18 18
 }
19 19
 
20 20
 function adm_lng_assign_string($lang_id, $locale_string_name, $value) {
21 21
   global $locale_string_template, $languages_info, $languages, $domain;
22 22
 
23
-  if(is_array($value)) {
24
-    foreach($value as $sub_key => $sub_value) {
23
+  if (is_array($value)) {
24
+    foreach ($value as $sub_key => $sub_value) {
25 25
       adm_lng_assign_string($lang_id, "{$locale_string_name}[{$sub_key}]", $sub_value);
26 26
     }
27
-  } elseif($value) {
28
-    if(!isset($locale_string_template[$locale_string_name])) {
27
+  } elseif ($value) {
28
+    if (!isset($locale_string_template[$locale_string_name])) {
29 29
       $locale_string_template[$locale_string_name] = array();
30 30
     }
31 31
     $locale_string_template[$locale_string_name] = array_merge($locale_string_template[$locale_string_name], array("[{$lang_id}]" => htmlentities($value, ENT_COMPAT, 'utf-8')));
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
   global $domain, $lang_id;
47 47
 
48 48
   $return = "{$ident}'{$string_name}' => ";
49
-  if(isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) {
49
+  if (isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) {
50 50
     $return .= "'" . str_replace(array("\\", "'"), array('\\\\', "\\'"), $string_value[$lang_id]) . "',";
51 51
   } else {
52 52
     $return .= "array(\r\n";
53
-    foreach($string_value as $arr_name => $arr_data) {
53
+    foreach ($string_value as $arr_name => $arr_data) {
54 54
       $return .= adm_lng_parse_string($arr_name, $arr_data, $ident . '  ');
55 55
     }
56 56
     $return .= "{$ident}),\r\n";
@@ -103,12 +103,12 @@  discard block
 block discarded – undo
103 103
 
104 104
   $string_name_new = false;
105 105
 
106
-  if(isset($honor_constants[$domain][$string_name_prefix])) {
106
+  if (isset($honor_constants[$domain][$string_name_prefix])) {
107 107
     $found_constants = array_keys($constants, $string_name);
108
-    foreach($found_constants as $constant_name) {
108
+    foreach ($found_constants as $constant_name) {
109 109
       $honor_prefix_list = is_array($honor_constants[$domain][$string_name_prefix]) ? $honor_constants[$domain][$string_name_prefix] : array($honor_constants[$domain][$string_name_prefix]);
110
-      foreach($honor_prefix_list as $honor_prefix) {
111
-        if(strpos($constant_name, $honor_prefix) === 0) {
110
+      foreach ($honor_prefix_list as $honor_prefix) {
111
+        if (strpos($constant_name, $honor_prefix) === 0) {
112 112
           $string_name_new = $constant_name;
113 113
           break;
114 114
         }
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
 
119 119
   $string_name_new = $string_name_new ? $string_name_new : "'{$string_name}'";
120 120
   fwrite($file_handler, "{$ident}{$string_name_new} => ");
121
-  if(isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) {
121
+  if (isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) {
122 122
     fwrite($file_handler, "'" . str_replace(array("\\", "'"), array('\\\\', "\\'"), $string_value[$lang_id]) . "',");
123 123
   } else {
124 124
     $string_name_prefix = $string_name_prefix . "[{$string_name}]";
125 125
     fwrite($file_handler, "array(\r\n");
126
-    foreach($string_value as $arr_name => $arr_data) {
126
+    foreach ($string_value as $arr_name => $arr_data) {
127 127
       adm_lng_write_string($arr_name, $arr_data, $ident . '  ', $string_name_prefix);
128 128
     }
129 129
     fwrite($file_handler, "{$ident}),\r\n");
@@ -143,13 +143,13 @@  discard block
 block discarded – undo
143 143
 $languages_info = lng_get_list();
144 144
 $domain = sys_get_param_str('domain');
145 145
 
146
-if($domain) {
146
+if ($domain) {
147 147
   $lang_new = sys_get_param('lang_new');
148
-  if(!empty($lang_new)) {
148
+  if (!empty($lang_new)) {
149 149
     $constants = get_defined_constants(true);
150 150
     $constants = $constants['user'];
151 151
     ksort($constants);
152
-    foreach($languages_info as $lang_id => $land_data) {
152
+    foreach ($languages_info as $lang_id => $land_data) {
153 153
       $file_handler = fopen(SN_ROOT_PHYSICAL . "language/{$lang_id}/{$domain}.mo.php.new", 'w');
154 154
       fwrite($file_handler, "<?php\r\n\r\n/*\r\n#############################################################################
155 155
 #  Filename: {$domain}.mo.php
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 #  Website: http://www.supernova.ws
158 158
 #  Description: Massive Multiplayer Online Browser Space Startegy Game\r\n#\r\n");
159 159
 
160
-      foreach($land_data['LANG_COPYRIGHT'] as $lang_copyright) {
160
+      foreach ($land_data['LANG_COPYRIGHT'] as $lang_copyright) {
161 161
         $lang_copyright = str_replace(array('&copy;', '&quot;', '&lt;', '&gt;'), array('©', '"', '<', '>'), $lang_copyright);
162 162
         fwrite($file_handler, "#  {$lang_copyright}\r\n");
163 163
       }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 /**\r\n*\r\n* @package language\r\n* @system [{$land_data['LANG_NAME_ENGLISH']}]\r\n* @version " . SN_VERSION . "\r\n*\r\n*/\r\n
166 166
 /**\r\n* DO NOT CHANGE\r\n*/\r\n\r\nif (!defined('INSIDE')) die();\r\n
167 167
 \$a_lang_array = array(\r\n");
168
-      foreach($lang_new as $string_name => $string_value) {
168
+      foreach ($lang_new as $string_name => $string_value) {
169 169
         adm_lng_write_string($string_name, $string_value);
170 170
       }
171 171
       fwrite($file_handler, ");\r\n");
@@ -176,21 +176,21 @@  discard block
 block discarded – undo
176 176
     die();
177 177
   }
178 178
 
179
-  foreach($languages_info as $lang_id => $lang_data) {
179
+  foreach ($languages_info as $lang_id => $lang_data) {
180 180
     $template->assign_block_vars('language', $lang_data);
181 181
     $full_filename = SN_ROOT_PHYSICAL . "language/{$lang_id}/{$domain}.mo.php";
182 182
     $languages[$lang_id] = adm_lng_load($full_filename . (file_exists($full_filename . '.new') ? '.new' : ''));
183
-    foreach($languages[$lang_id] as $locale_string_name => $cork) {
183
+    foreach ($languages[$lang_id] as $locale_string_name => $cork) {
184 184
       adm_lng_assign_string($lang_id, "[{$locale_string_name}]", $languages[$lang_id][$locale_string_name]);
185 185
     }
186 186
   }
187 187
 
188
-  foreach($locale_string_template as $locale_string_name => $locale_string_list) {
188
+  foreach ($locale_string_template as $locale_string_name => $locale_string_list) {
189 189
     $template->assign_block_vars('string', array(
190 190
       'NAME' => $locale_string_name,
191 191
     ));
192 192
 
193
-    foreach($languages_info as $lang_id => $cork2) {
193
+    foreach ($languages_info as $lang_id => $cork2) {
194 194
       $template->assign_block_vars('string.locale', array(
195 195
         'LANG' => $lang_id,
196 196
         'VALUE' => $locale_string_list["[{$lang_id}]"],
@@ -206,17 +206,17 @@  discard block
 block discarded – undo
206 206
   $dir = dir($path);
207 207
   while (false !== ($lang_id = $dir->read())) {
208 208
     $full_path = $path . $lang_id;
209
-    if($lang_id[0] != "." && is_dir($full_path)) {
209
+    if ($lang_id[0] != "." && is_dir($full_path)) {
210 210
       $lang_file_list = dir($full_path);
211 211
       while (false !== ($filename = $lang_file_list->read())) {
212 212
         $lang_domain = strtolower(substr($filename, 0, strpos($filename, '.')));
213
-        if(!$lang_domain) {
213
+        if (!$lang_domain) {
214 214
           continue;
215 215
         }
216 216
 
217 217
         $file_ext = strtolower(substr($filename, strpos($filename, '.')));
218
-        if($lang_domain != 'language') {
219
-          if($file_ext == '.mo.php.new' || ($file_ext == '.mo.php' && empty($languages[$lang_id][$lang_domain]))) {
218
+        if ($lang_domain != 'language') {
219
+          if ($file_ext == '.mo.php.new' || ($file_ext == '.mo.php' && empty($languages[$lang_id][$lang_domain]))) {
220 220
             $language_domains[$lang_domain] = $lang_domain;
221 221
             $languages[$lang_id][$lang_domain] = $lang_domain;
222 222
           }
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
   }
227 227
   $dir->close();
228 228
 
229
-  foreach($language_domains as $lang_domain) {
229
+  foreach ($language_domains as $lang_domain) {
230 230
     $template->assign_block_vars('domain', array(
231 231
       'NAME' => $lang_domain,
232 232
     ));
Please login to merge, or discard this patch.
admin/adm_metamatter.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 
16 16
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
17 17
 
18
-if(!sn_module_get_active_count('payment')) {
18
+if (!sn_module_get_active_count('payment')) {
19 19
   sys_redirect(SN_ROOT_VIRTUAL . 'admin/overview.php');
20 20
 }
21 21
 
22
-if($user['authlevel'] < 3) {
22
+if ($user['authlevel'] < 3) {
23 23
   AdminMessage($lang['adm_err_denied']);
24 24
 }
25 25
 
@@ -28,19 +28,19 @@  discard block
 block discarded – undo
28 28
 $message = '';
29 29
 $message_status = ERR_ERROR;
30 30
 
31
-if($points = sys_get_param_float('points')) {
31
+if ($points = sys_get_param_float('points')) {
32 32
   try {
33 33
     $username = sys_get_param_str_unsafe('id_user');
34
-    if(empty($username)) {
34
+    if (empty($username)) {
35 35
       throw new Exception($lang['adm_mm_no_dest']);
36 36
     }
37 37
 
38 38
     $an_account = new Account(classSupernova::$auth->account->db);
39
-    if(!$an_account->db_get_by_id($username) && !$an_account->db_get_by_name($username) && !$an_account->db_get_by_email($username)) {
39
+    if (!$an_account->db_get_by_id($username) && !$an_account->db_get_by_name($username) && !$an_account->db_get_by_email($username)) {
40 40
       throw new Exception(sprintf($lang['adm_mm_user_none'], $username));
41 41
     }
42 42
 
43
-    if(!$an_account->metamatter_change(RPG_ADMIN, $points, sprintf(
43
+    if (!$an_account->metamatter_change(RPG_ADMIN, $points, sprintf(
44 44
       $lang['adm_matter_change_log_record'],
45 45
       $an_account->account_id, db_escape($an_account->account_name),
46 46
       $user['id'], db_escape($user['username']),
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 //  $message = $lang['adm_mm_no_quant'];
60 60
 }
61 61
 
62
-if($message_status == ERR_ERROR) {
62
+if ($message_status == ERR_ERROR) {
63 63
   $template->assign_vars(array(
64 64
     'ID_USER' => $username,
65 65
     'POINTS' => $points,
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
   ));
68 68
 };
69 69
 
70
-if($message) {
70
+if ($message) {
71 71
   $template->assign_block_vars('result', array('MESSAGE' => $message, 'STATUS' => $message_status ? $message_status : ERR_NONE));
72 72
 }
73 73
 
Please login to merge, or discard this patch.
admin/userlist.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
16 16
 
17 17
 global $config, $lang, $user;
18
-if($user['authlevel'] < 3) {
18
+if ($user['authlevel'] < 3) {
19 19
   AdminMessage($lang['adm_err_denied']);
20 20
 }
21 21
 
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
 $sort = sys_get_param_int('sort', SORT_ID);
40 40
 $sort = $sort_fields[$sort] ? $sort : SORT_ID;
41 41
 
42
-if(($action = sys_get_param_int('action')) && ($user_id = sys_get_param_id('uid'))) {
42
+if (($action = sys_get_param_int('action')) && ($user_id = sys_get_param_id('uid'))) {
43 43
   $user_selected = db_user_by_id($user_id, false, 'id, username, authlevel');
44
-  if($user_selected['authlevel'] < $user['authlevel'] && $user['authlevel'] >= 3) {
45
-    switch($action) {
44
+  if ($user_selected['authlevel'] < $user['authlevel'] && $user['authlevel'] >= 3) {
45
+    switch ($action) {
46 46
       case ACTION_DELETE:
47 47
         DeleteSelectedUser($user_id);
48 48
         sys_redirect("{$_SERVER['SCRIPT_NAME']}?sort={$sort}");
@@ -63,20 +63,20 @@  discard block
 block discarded – undo
63 63
 
64 64
 $multi_ip = array();
65 65
 $ip_query = db_user_list_admin_multiaccounts();
66
-while($ip = db_fetch($ip_query)) {
66
+while ($ip = db_fetch($ip_query)) {
67 67
   $multi_ip[$ip['user_lastip']] = $ip['ip_count'];
68 68
 }
69 69
 
70 70
 $geoip = geoip_status();
71 71
 
72 72
 $query = db_user_list_admin_sorted($sort_fields[$sort], $is_players_online_page);
73
-while($user_row = db_fetch($query)) {
74
-  if($user_row['banaday']) {
73
+while ($user_row = db_fetch($query)) {
74
+  if ($user_row['banaday']) {
75 75
     $ban_details = doquery("SELECT * FROM {{banned}} WHERE `ban_user_id` = {$user_row['id']} ORDER BY ban_id DESC LIMIT 1", true);
76 76
   }
77 77
 
78 78
   $geoip_info = $geoip ? geoip_ip_info(ip2longu($user_row['user_lastip'])) : array();
79
-  foreach($geoip_info as $key => $value) {
79
+  foreach ($geoip_info as $key => $value) {
80 80
     $geoip_info[strtoupper($key)] = $value;
81 81
     unset($geoip_info[$key]);
82 82
   }
Please login to merge, or discard this patch.