Completed
Push — work-fleets ( abbbcf...8b8b7f )
by SuperNova.WS
05:13
created
includes/includes/mrc_mercenary.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@  discard block
 block discarded – undo
7 7
   global $config;
8 8
 
9 9
   $mercenary_info = get_unit_param($mercenary_id);
10
-  if($config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS)
10
+  if ($config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS)
11 11
   {
12 12
     return true;
13 13
   }
14 14
 
15
-  if(isset($mercenary_info[P_REQUIRE]))
15
+  if (isset($mercenary_info[P_REQUIRE]))
16 16
   {
17
-    foreach($mercenary_info[P_REQUIRE] as $unit_id => $unit_level)
17
+    foreach ($mercenary_info[P_REQUIRE] as $unit_id => $unit_level)
18 18
     {
19
-      if(mrc_get_level($user, null, $unit_id) < $unit_level)
19
+      if (mrc_get_level($user, null, $unit_id) < $unit_level)
20 20
       {
21 21
         return false;
22 22
       }
@@ -33,35 +33,35 @@  discard block
 block discarded – undo
33 33
     $is_permanent = $mode == UNIT_PLANS || !$config->empire_mercenary_temporary;
34 34
     $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? $config->ali_bonus_members : 1);
35 35
     $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1;
36
-    if(!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) {
36
+    if (!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) {
37 37
       throw new Exception($lang['mrc_msg_error_wrong_mercenary'], ERR_ERROR);
38 38
     }
39 39
 
40
-    if(!mrc_officer_accessible($user, $mercenary_id)) {
40
+    if (!mrc_officer_accessible($user, $mercenary_id)) {
41 41
       throw new Exception($lang['mrc_msg_error_requirements'], ERR_ERROR);
42 42
     }
43 43
 
44 44
     $mercenary_level = sys_get_param_int('mercenary_level');
45
-    if($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) {
45
+    if ($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) {
46 46
       throw new Exception($lang['mrc_msg_error_wrong_level'], ERR_ERROR);
47 47
     }
48 48
 
49
-    if($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) {
49
+    if ($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) {
50 50
       throw new Exception($lang['mrc_msg_error_wrong_period'], ERR_ERROR);
51 51
     }
52 52
 
53 53
     sn_db_transaction_start();
54 54
 
55 55
     $mercenary_level_old = mrc_get_level($user, $planetrow, $mercenary_id, true, true);
56
-    if($config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) {
56
+    if ($config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) {
57 57
       throw new Exception($lang['mrc_msg_error_already_hired'], ERR_ERROR); // Can't hire already hired temp mercenary - dismiss first
58
-    } elseif($config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) {
58
+    } elseif ($config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) {
59 59
       throw new Exception('', ERR_NONE); // Can't dismiss (!$mercenary_level) not hired (!$mercenary_level_old) temp mercenary. But no error
60 60
     }
61 61
 
62
-    if($mercenary_level) {
62
+    if ($mercenary_level) {
63 63
       $darkmater_cost = eco_get_total_cost($mercenary_id, $mercenary_level);
64
-      if(!$config->empire_mercenary_temporary && $mercenary_level_old) {
64
+      if (!$config->empire_mercenary_temporary && $mercenary_level_old) {
65 65
        $darkmater_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level_old);
66 66
        $darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] -= $darkmater_cost_old[BUILD_CREATE][RES_DARK_MATTER];
67 67
       }
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
     }
72 72
     $darkmater_cost *= $cost_alliance_multiplyer;
73 73
 
74
-    if(mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) {
74
+    if (mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) {
75 75
       throw new Exception($lang['mrc_msg_error_no_resource'], ERR_ERROR);
76 76
     }
77 77
 
78
-    if(($darkmater_cost && $mercenary_level) || !$is_permanent) {
78
+    if (($darkmater_cost && $mercenary_level) || !$is_permanent) {
79 79
       $unit_row = db_unit_by_location($user['id'], LOC_USER, $user['id'], $mercenary_id);
80
-      if(is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) {
80
+      if (is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) {
81 81
         $dismiss_full_cost = eco_get_total_cost($mercenary_id, $unit_row['unit_level']);
82 82
         $dismiss_full_cost = $dismiss_full_cost[BUILD_CREATE][RES_DARK_MATTER];
83 83
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
       db_unit_list_delete($user['id'], LOC_USER, $user['id'], $mercenary_id);
96 96
     }
97 97
 
98
-    if($darkmater_cost && $mercenary_level) {
98
+    if ($darkmater_cost && $mercenary_level) {
99 99
       db_unit_set_insert(
100 100
         "unit_player_id = {$user['id']},
101 101
         unit_location_type = " . LOC_USER . ",
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
   $mode = in_array($mode, array(UNIT_MERCENARIES, UNIT_PLANS)) ? $mode : UNIT_MERCENARIES;
131 131
   $is_permanent = $mode == UNIT_PLANS || !$config->empire_mercenary_temporary;
132 132
 
133
-  if($mercenary_id = sys_get_param_int('mercenary_id'))
133
+  if ($mercenary_id = sys_get_param_int('mercenary_id'))
134 134
   {
135 135
     $operation_result = mrc_mercenary_hire($mode, $user, $mercenary_id);
136 136
   }
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
 
140 140
   $template = gettemplate('mrc_mercenary_hire', true);
141 141
 
142
-  if(!empty($operation_result))
142
+  if (!empty($operation_result))
143 143
   {
144 144
     $template->assign_block_vars('result', $operation_result);
145 145
   }
146 146
 
147
-  foreach($sn_powerup_buy_discounts as $hire_period => $hire_discount)
147
+  foreach ($sn_powerup_buy_discounts as $hire_period => $hire_discount)
148 148
   {
149 149
     $template->assign_block_vars('period', array(
150 150
       'LENGTH'   => $hire_period,
@@ -157,13 +157,13 @@  discard block
 block discarded – undo
157 157
   $user_dark_matter = mrc_get_level($user, '', RES_DARK_MATTER);
158 158
   $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? $config->ali_bonus_members : 1);
159 159
   $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1;
160
-  foreach(sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id)
160
+  foreach (sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id)
161 161
   {
162 162
     {
163 163
       $mercenary = get_unit_param($mercenary_id);
164 164
       $mercenary_bonus = $mercenary['bonus'];
165 165
       $mercenary_bonus = $mercenary_bonus >= 0 ? "+{$mercenary_bonus}" : "{$mercenary_bonus}";
166
-      switch($mercenary['bonus_type'])
166
+      switch ($mercenary['bonus_type'])
167 167
       {
168 168
         case BONUS_PERCENT:
169 169
           $mercenary_bonus = "{$mercenary_bonus}% ";
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
       $mercenary_level = mrc_get_level($user, null, $mercenary_id, false, true);
182 182
       $mercenary_level_bonus = max(0, mrc_get_level($user, null, $mercenary_id) - $mercenary_level);
183 183
       $total_cost_old = 0;
184
-      if($is_permanent)
184
+      if ($is_permanent)
185 185
       {
186 186
         $total_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level);
187 187
         $total_cost_old = $total_cost_old[BUILD_CREATE][RES_DARK_MATTER] * $cost_alliance_multiplyer;
@@ -205,13 +205,13 @@  discard block
 block discarded – undo
205 205
         'BONUS_TYPE'  => $mercenary['bonus_type'],
206 206
         'HIRE_END'    => $mercenary_time_finish && $mercenary_time_finish >= SN_TIME_NOW ? date(FMT_DATE_TIME, $mercenary_time_finish) : '',
207 207
         'HIRE_LEFT_PERCENT'    => $mercenary_time_finish && $mercenary_time_finish >= SN_TIME_NOW
208
-          ? round(($mercenary_time_finish - SN_TIME_NOW)/($mercenary_time_finish - $mercenary_time_start) * 100, 1)
208
+          ? round(($mercenary_time_finish - SN_TIME_NOW) / ($mercenary_time_finish - $mercenary_time_start) * 100, 1)
209 209
           : 0,
210 210
         'CAN_BUY'     => mrc_officer_accessible($user, $mercenary_id),
211 211
       ));
212 212
 
213 213
       $upgrade_cost = 1;
214
-      for($i = $config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++)
214
+      for ($i = $config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++)
215 215
       {
216 216
         $total_cost = eco_get_total_cost($mercenary_id, $i);
217 217
         $total_cost[BUILD_CREATE][RES_DARK_MATTER] *= $cost_alliance_multiplyer;
Please login to merge, or discard this patch.
includes/includes/flt_page2.inc 1 patch
Spacing   +10 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     'START_NAME'         => $planetrow['name'],
28 28
   );
29 29
 
30
-  if(!empty($TargetPlanet)) {
30
+  if (!empty($TargetPlanet)) {
31 31
     $template_route += array(
32 32
       'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$TargetPlanet['planet_type']],
33 33
       'END_COORDS'       => uni_render_coordinates($TargetPlanet),
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
   $template->assign_block_vars('fleets', $template_route);
39 39
 
40 40
   $sn_groups_fleet = sn_get_groups('fleet');
41
-  foreach($fleetarray as $ship_id => $ship_count) {
42
-    if(in_array($ship_id, $sn_groups_fleet) && $ship_count) {
41
+  foreach ($fleetarray as $ship_id => $ship_count) {
42
+    if (in_array($ship_id, $sn_groups_fleet) && $ship_count) {
43 43
 //      $ship_base_data = get_ship_data($ship_id, $user);
44 44
       $template->assign_block_vars('fleets.ships', array(
45 45
         'ID'          => $ship_id,
@@ -57,11 +57,10 @@  discard block
 block discarded – undo
57 57
     $fleet_capacity += get_unit_param($Ship, P_CAPACITY) * $Count;
58 58
   }
59 59
 
60
-  $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) :
61
-    (isset($missiontype[MT_HOLD]) ? 12 : 0);
62
-  if($max_duration) {
60
+  $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : (isset($missiontype[MT_HOLD]) ? 12 : 0);
61
+  if ($max_duration) {
63 62
     $config_game_speed_expedition = ($target_mission == MT_EXPLORE && $config->game_speed_expedition ? $config->game_speed_expedition : 1);
64
-    for($i = 1; $i <= $max_duration; $i++) {
63
+    for ($i = 1; $i <= $max_duration; $i++) {
65 64
       $template->assign_block_vars('duration', array(
66 65
         'ID' => $i,
67 66
         'TIME' => pretty_time(ceil($i * 3600 / $config_game_speed_expedition)),
@@ -80,7 +79,7 @@  discard block
 block discarded – undo
80 79
   // $TableTitle = uni_render_planet_full($planetrow) . '&nbsp;=&gt;&nbsp;' . uni_render_planet_full($temp);
81 80
 
82 81
   $sn_group_resources = sn_get_groups('resources');
83
-  for($i = 0; $i<3; $i++) {
82
+  for ($i = 0; $i < 3; $i++) {
84 83
     $amount = $planetrow[$sn_group_resources[$i]] - ($i == 2 ? $consumption : 0);
85 84
     $template->assign_block_vars('resources', array(
86 85
       'ID' => $i,
@@ -90,7 +89,7 @@  discard block
 block discarded – undo
90 89
     ));
91 90
   }
92 91
 
93
-  if($sn_module['unit_captain']->manifest['active'] && ($captain = $sn_module['unit_captain']->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) {
92
+  if ($sn_module['unit_captain']->manifest['active'] && ($captain = $sn_module['unit_captain']->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) {
94 93
     $template->assign_vars(array(
95 94
       'CAPTAIN_ID' => $captain['unit_id'],
96 95
       'CAPTAIN_LEVEL' => $captain['captain_level'],
@@ -111,9 +110,9 @@  discard block
 block discarded – undo
111 110
     // 'TableTitle' => $TableTitle,
112 111
 
113 112
     'speedallsmin' => sys_get_param_float('speedallsmin'),
114
-    'speed' => sys_get_param_int('speed') ,
113
+    'speed' => sys_get_param_int('speed'),
115 114
 
116
-    'fleet_group' => sys_get_param_id('fleet_group') ,
115
+    'fleet_group' => sys_get_param_id('fleet_group'),
117 116
     'acs_target_mr' => sys_get_param_str('acs_target_mr'),
118 117
 
119 118
     'MAX_DURATION' => $max_duration,
Please login to merge, or discard this patch.
includes/includes/eco_bld_structures.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 function sn_eco_build($que_type, &$auser, &$planet) {
19 19
   global $lang, $config, $template_result;
20 20
 
21
-  if($ally_id = sys_get_param_id('ally_id')) {
21
+  if ($ally_id = sys_get_param_id('ally_id')) {
22 22
     define('SN_IN_ALLY', true);
23 23
     $ranks = ally_get_ranks($auser['ally']);
24
-    if($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) {
24
+    if ($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) {
25 25
       $user = &$auser['ally']['player'];
26 26
       $planet = array(
27 27
         'metal'     => $user['metal'],
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
     }
32 32
   }
33 33
 
34
-  if(!$user) {
34
+  if (!$user) {
35 35
     $user = &$auser;
36 36
   }
37 37
 
38
-  switch($action = sys_get_param_escaped('action')) {
38
+  switch ($action = sys_get_param_escaped('action')) {
39 39
     case 'create': // Add unit to que for build
40 40
     case 'create_autoconvert': // Add unit to que for build
41 41
     case 'destroy': // Add unit to que for remove
@@ -52,23 +52,23 @@  discard block
 block discarded – undo
52 52
 
53 53
   $group_missile = sn_get_groups('missile');
54 54
   $silo_capacity_free = 0;
55
-  if($que_type == QUE_STRUCTURES) {
55
+  if ($que_type == QUE_STRUCTURES) {
56 56
     $build_unit_list = sn_get_groups('build_allow');
57 57
     $build_unit_list = $build_unit_list[$planet['planet_type']];
58 58
     $artifact_id = ART_NANO_BUILDER;
59 59
     $page_header = $lang['tech'][UNIT_STRUCTURES];
60
-  } elseif($que_type == QUE_RESEARCH) {
61
-    if(!mrc_get_level($user, $planet, STRUC_LABORATORY)) {
60
+  } elseif ($que_type == QUE_RESEARCH) {
61
+    if (!mrc_get_level($user, $planet, STRUC_LABORATORY)) {
62 62
       message($lang['no_laboratory'], $lang['tech'][UNIT_TECHNOLOGIES]);
63 63
     }
64 64
 
65
-    if(eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) {
65
+    if (eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) {
66 66
       message($lang['eco_bld_msg_err_laboratory_upgrading'], $lang['tech'][UNIT_TECHNOLOGIES]);
67 67
     }
68 68
     $build_unit_list = sn_get_groups('tech');
69 69
     $artifact_id = ART_HEURISTIC_CHIP;
70 70
     $page_header = $lang['tech'][UNIT_TECHNOLOGIES] . ($user['user_as_ally'] ? "&nbsp;{$lang['sys_of_ally']}&nbsp;{$user['username']}" : '');
71
-  } elseif($que_type == QUE_MERCENARY) {
71
+  } elseif ($que_type == QUE_MERCENARY) {
72 72
 //    if(!mrc_get_level($user, $planet, STRUC_LABORATORY)) {
73 73
 //      message($lang['no_laboratory'], $lang['tech'][UNIT_TECHNOLOGIES]);
74 74
 //    }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     $artifact_id = 0;
81 81
     $page_header = $lang['tech'][UNIT_MERCENARIES] . ($user['user_as_ally'] ? "&nbsp;{$lang['sys_of_ally']}&nbsp;{$user['username']}" : '');
82 82
   } else {
83
-    if(mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) {
83
+    if (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) {
84 84
       message($lang['need_hangar'], $lang['tech'][STRUC_FACTORY_HANGAR]);
85 85
     }
86 86
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     $artifact_id = 0;
90 90
 
91 91
     $silo_capacity_free = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY);
92
-    foreach($group_missile as $unit_id) {
92
+    foreach ($group_missile as $unit_id) {
93 93
       $silo_capacity_free -= (mrc_get_level($user, $planet, $unit_id, false, true) + (isset($in_que[$unit_id]) && $in_que[$unit_id] ? $in_que[$unit_id] : 0)) * get_unit_param($unit_id, P_UNIT_SIZE);
94 94
     }
95 95
     $silo_capacity_free = max(0, $silo_capacity_free);
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
   */
107 107
 
108 108
   $template = gettemplate('buildings_builds', true);
109
-  if(!empty($operation_result)) {
109
+  if (!empty($operation_result)) {
110 110
     $template_result['.']['result'][] = $operation_result;
111 111
   }
112 112
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
   $record_index = 0;
138 138
 
139
-  foreach($build_unit_list as $unit_id) {
139
+  foreach ($build_unit_list as $unit_id) {
140 140
     $level_base = mrc_get_level($user, $planet, $unit_id, false, true);
141 141
     $level_effective = mrc_get_level($user, $planet, $unit_id);
142 142
     $level_in_que = $in_que[$unit_id];
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
     $can_build = $unit_info[P_MAX_STACK] ? max(0, $unit_info[P_MAX_STACK] - $level_in_que - $level_effective) : $build_data['CAN'][BUILD_CREATE];
160 160
     // Restricting $can_build by free silo capacity
161 161
     $can_build = ($unit_is_missile = in_array($unit_id, $group_missile)) ? min($can_build, floor($silo_capacity_free / $unit_info[P_UNIT_SIZE])) : $can_build;
162
-    if(!$can_build) {
163
-      if(!$build_data['CAN'][BUILD_CREATE]) {
162
+    if (!$can_build) {
163
+      if (!$build_data['CAN'][BUILD_CREATE]) {
164 164
         $build_data['RESULT'][BUILD_CREATE] = BUILD_NO_RESOURCES;
165
-      } elseif($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) {
165
+      } elseif ($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) {
166 166
         $build_data['RESULT'][BUILD_CREATE] = BUILD_SILO_FULL;
167
-      } elseif($unit_info[P_MAX_STACK]) {
167
+      } elseif ($unit_info[P_MAX_STACK]) {
168 168
         $build_data['RESULT'][BUILD_CREATE] = BUILD_MAX_REACHED;
169 169
       }
170 170
     }
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
       'MAP_IS_RESOURCE' => !empty($unit_info[P_UNIT_PRODUCTION]),
232 232
     );
233 233
 
234
-    if($unit_stackable) {
234
+    if ($unit_stackable) {
235 235
       $level_production_base = array(
236 236
         'ACTUAL_SHIELD' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_SHIELD), $unit_info['shield'])),
237 237
         'ACTUAL_ARMOR'  => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_ARMOR), $unit_info['armor'])),
238 238
         'ACTUAL_WEAPON' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_WEAPON), $unit_info['attack'])),
239 239
       );
240 240
 
241
-      if($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) {
241
+      if ($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) {
242 242
         $ship_data = get_ship_data($unit_id, $user);
243 243
 
244 244
         $level_production_base += array(
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
         );
249 249
       }
250 250
 
251
-      if($unit_info[P_UNIT_PRODUCTION]) {
252
-        foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) {
253
-          if($resource_income =
251
+      if ($unit_info[P_UNIT_PRODUCTION]) {
252
+        foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) {
253
+          if ($resource_income =
254 254
             floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc(1, 10, $user, $planet)
255 255
               * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier)
256 256
               * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1)))
@@ -260,11 +260,11 @@  discard block
 block discarded – undo
260 260
         }
261 261
       }
262 262
       $production['.']['resource'][] = $level_production_base;
263
-    } elseif($unit_info[P_UNIT_PRODUCTION]) {
263
+    } elseif ($unit_info[P_UNIT_PRODUCTION]) {
264 264
       $level_production_base = array();
265 265
       $element_level_start = $level_effective + $in_que[$unit_id];
266
-      foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) {
267
-        if($resource_income =
266
+      foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) {
267
+        if ($resource_income =
268 268
           floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($element_level_start, 10, $user, $planet)
269 269
             * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier)
270 270
             * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1)))
@@ -274,10 +274,10 @@  discard block
 block discarded – undo
274 274
       }
275 275
 
276 276
       $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1;
277
-      for($i = 0; $i < 6; $i++) {
277
+      for ($i = 0; $i < 6; $i++) {
278 278
         $level_production = array('LEVEL' => $level_start + $i);
279
-        foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) {
280
-          if(
279
+        foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) {
280
+          if (
281 281
           $resource_income = floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($level_start + $i, 10, $user, $planet)
282 282
             * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier)
283 283
             * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1)))
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
         }
289 289
         $production['.']['resource'][] = $level_production;
290 290
       }
291
-    } elseif($unit_id == TECH_ASTROTECH) {
291
+    } elseif ($unit_id == TECH_ASTROTECH) {
292 292
       $element_level_start = $level_effective + $in_que[$unit_id];
293 293
       $level_production_base = array(
294 294
         UNIT_PLAYER_EXPEDITIONS_MAX => get_player_max_expeditons($user, $element_level_start),
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
       );
297 297
 
298 298
       $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1;
299
-      for($i = 0; $i < 6; $i++) {
299
+      for ($i = 0; $i < 6; $i++) {
300 300
         $level_production = array('LEVEL' => $level_start + $i);
301 301
         $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] = get_player_max_expeditons($user, $level_start + $i);
302 302
         $level_production['D' . UNIT_PLAYER_EXPEDITIONS_MAX] = $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] - $level_production_base[UNIT_PLAYER_EXPEDITIONS_MAX];
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
     $template_result['.']['production'][] = $production;
318 318
   }
319 319
 
320
-  foreach($lang['player_option_building_sort'] as $sort_id => $sort_text) {
320
+  foreach ($lang['player_option_building_sort'] as $sort_id => $sort_text) {
321 321
     $template->assign_block_vars('sort_values', array(
322 322
       'VALUE' => $sort_id,
323 323
       'TEXT'  => $sort_text,
@@ -326,8 +326,8 @@  discard block
 block discarded – undo
326 326
 
327 327
   $sort_option = classSupernova::$user_options[array(PLAYER_OPTION_BUILDING_SORT, $que_type)];
328 328
   $sort_option_inverse = classSupernova::$user_options[array(PLAYER_OPTION_BUILDING_SORT_INVERSE, $que_type)];
329
-  if($sort_option || $sort_option_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) {
330
-    switch($sort_option) {
329
+  if ($sort_option || $sort_option_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) {
330
+    switch ($sort_option) {
331 331
       case PLAYER_OPTION_SORT_NAME:
332 332
         $sort_option_field = 'NAME';
333 333
       break;
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
       break;
343 343
     }
344 344
     $sort_option_inverse_closure = $sort_option_inverse ? -1 : 1;
345
-    usort($template_result['.']['production'], function ($a, $b) use ($sort_option_field, $sort_option_inverse_closure) {
345
+    usort($template_result['.']['production'], function($a, $b) use ($sort_option_field, $sort_option_inverse_closure) {
346 346
       return $a[$sort_option_field] < $b[$sort_option_field] ? -1 * $sort_option_inverse_closure : (
347 347
       $a[$sort_option_field] > $b[$sort_option_field] ? 1 * $sort_option_inverse_closure : 0
348 348
       );
Please login to merge, or discard this patch.
includes/includes/sys_avatar.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -9,28 +9,28 @@  discard block
 block discarded – undo
9 9
     $avatar_filename = $fullsize_filename = SN_ROOT_PHYSICAL . 'images/avatar/' . $prefix . '_' . $subject_id;
10 10
     $avatar_filename .= '.png';
11 11
     $fullsize_filename .= '_full.png';
12
-    if(sys_get_param_int('avatar_remove'))
12
+    if (sys_get_param_int('avatar_remove'))
13 13
     {
14
-      if(file_exists($avatar_filename) && !unlink($avatar_filename))
14
+      if (file_exists($avatar_filename) && !unlink($avatar_filename))
15 15
       {
16 16
         throw new Exception($lang['opt_msg_avatar_error_delete'], ERR_ERROR);
17 17
       }
18 18
       $avatar_field = 0;
19 19
       throw new Exception($lang['opt_msg_avatar_removed'], ERR_NONE);
20 20
     }
21
-    elseif($_FILES['avatar']['size'])
21
+    elseif ($_FILES['avatar']['size'])
22 22
     {
23
-      if(!in_array($_FILES['avatar']['type'], array('image/gif', 'image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png')) || $_FILES['avatar']['size'] > 204800)
23
+      if (!in_array($_FILES['avatar']['type'], array('image/gif', 'image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png')) || $_FILES['avatar']['size'] > 204800)
24 24
       {
25 25
         throw new Exception($lang['opt_msg_avatar_error_unsupported'], ERR_WARNING);
26 26
       }
27 27
 
28
-      if($_FILES['avatar']['error'])
28
+      if ($_FILES['avatar']['error'])
29 29
       {
30 30
         throw new Exception(sprintf($lang['opt_msg_avatar_error_upload'], $_FILES['avatar']['error']), ERR_ERROR);
31 31
       }
32 32
 
33
-      if(!($avatar_image = imagecreatefromstring(file_get_contents($_FILES['avatar']['tmp_name']))))
33
+      if (!($avatar_image = imagecreatefromstring(file_get_contents($_FILES['avatar']['tmp_name']))))
34 34
       {
35 35
         throw new Exception($lang['opt_msg_avatar_error_unsupported'], ERR_WARNING);
36 36
       }
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
       $avatar_size = getimagesize($_FILES['avatar']['tmp_name']);
39 39
       $avatar_max_width  = $config-> avatar_max_width;
40 40
       $avatar_max_height = $config-> avatar_max_height;
41
-      if($avatar_size[0] > $avatar_max_width || $avatar_size[1] > $avatar_max_height)
41
+      if ($avatar_size[0] > $avatar_max_width || $avatar_size[1] > $avatar_max_height)
42 42
       {
43 43
         $aspect_ratio = min($avatar_max_width / $avatar_size[0], $avatar_max_height / $avatar_size[1]);
44 44
         $avatar_image_new = imagecreatetruecolor($avatar_size[0] * $aspect_ratio, $avatar_size[0] * $aspect_ratio);
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
         $avatar_image = $avatar_image_new;
48 48
       }
49 49
 
50
-      if(file_exists($avatar_filename) && !unlink($avatar_filename))
50
+      if (file_exists($avatar_filename) && !unlink($avatar_filename))
51 51
       {
52 52
         throw new Exception($lang['opt_msg_avatar_error_delete'], ERR_ERROR);
53 53
       }
54 54
 
55
-      if(!imagepng($avatar_image, $avatar_filename, 9))
55
+      if (!imagepng($avatar_image, $avatar_filename, 9))
56 56
       {
57 57
         throw new Exception($lang['opt_msg_avatar_error_writing'], ERR_ERROR);
58 58
       }
Please login to merge, or discard this patch.
includes/classes/core_auth.php 1 patch
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -199,18 +199,18 @@  discard block
 block discarded – undo
199 199
     // TODO Хотя тут может получится вечный цикл - ПОДУМАТЬ
200 200
     // TODO Тут же можно пробовать провести попытку слияния аккаунтов - хотя это и очень небезопасно
201 201
 
202
-    if(sys_get_param('login_player_register_logout')) {
202
+    if (sys_get_param('login_player_register_logout')) {
203 203
       $this->logout();
204 204
     }
205 205
 
206 206
     $original_suggest = '';
207 207
     // Смотрим - есть ли у нас данные от пользователя
208
-    if(($player_name_submitted = sys_get_param('submit_player_name'))) {
208
+    if (($player_name_submitted = sys_get_param('submit_player_name'))) {
209 209
       // Попытка регистрации нового игрока из данных, введенных пользователем
210 210
       $this->player_suggested_name = sys_get_param_str_unsafe('player_suggested_name');
211 211
     } else {
212
-      foreach($this->providers_authorised as $provider) {
213
-        if($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5
212
+      foreach ($this->providers_authorised as $provider) {
213
+        if ($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5
214 214
           $original_suggest = $provider->player_name_suggest();
215 215
           break;
216 216
         }
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
     }
219 219
 
220 220
     // Если у нас провайдеры не дают имени и пользователь не дал свой вариант - это у нас первый логин в игру
221
-    if(!$this->player_suggested_name) {
221
+    if (!$this->player_suggested_name) {
222 222
       $max_user_id = db_player_get_max_id(); // 4.5
223 223
       // TODO - предлагать имя игрока по локали
224 224
 
@@ -227,15 +227,15 @@  discard block
 block discarded – undo
227 227
         sn_db_transaction_rollback();
228 228
         $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000);
229 229
         sn_db_transaction_start();
230
-      } while(db_player_name_exists($this->player_suggested_name));
230
+      } while (db_player_name_exists($this->player_suggested_name));
231 231
 
232 232
     }
233 233
 
234
-    if($player_name_submitted) {
234
+    if ($player_name_submitted) {
235 235
       $this->register_player_db_create($this->player_suggested_name); // OK 4.5
236
-      if($this->register_status == LOGIN_SUCCESS) {
236
+      if ($this->register_status == LOGIN_SUCCESS) {
237 237
         sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
238
-      } elseif($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) {
238
+      } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) {
239 239
         // self::$player_suggested_name .= ' ' . $this->account->account_id;
240 240
       }
241 241
 //      if(self::$login_status != LOGIN_SUCCESS) {
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
         : false
260 260
       );
261 261
 
262
-    if($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
262
+    if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
263 263
       $prohibited_characters = array_map(function($value) {
264 264
         return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
265 265
       }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
@@ -293,27 +293,27 @@  discard block
 block discarded – undo
293 293
     global $sn_module_list, $lang;
294 294
 
295 295
     // !self::$is_init ? self::init() : false;
296
-    if(empty($sn_module_list['auth'])) {
296
+    if (empty($sn_module_list['auth'])) {
297 297
       die('{Не обнаружено ни одного провайдера авторизации в core_auth::login()!}');
298 298
     }
299 299
 
300 300
     !empty($_POST) ? self::flog(dump($_POST, '$_POST')) : false;
301 301
     !empty($_GET) ? self::flog(dump($_GET, '$_GET')) : false;
302
-    !empty($_COOKIE) ? self::flog(dump($_COOKIE,'$_COOKIE')) : false;
302
+    !empty($_COOKIE) ? self::flog(dump($_COOKIE, '$_COOKIE')) : false;
303 303
 
304 304
     $this->auth_reset(); // OK v4.5
305 305
 
306 306
     $this->providers = array();
307
-    foreach($sn_module_list['auth'] as $module_name => $module) {
307
+    foreach ($sn_module_list['auth'] as $module_name => $module) {
308 308
       $this->providers[$module->provider_id] = $module;
309 309
     }
310 310
 
311 311
     // $this->providers = array_reverse($this->providers, true); // НИНАДА! СН-аккаунт должен всегда авторизироваться первым!
312 312
 
313
-    foreach($this->providers as $provider_id => $provider) {
313
+    foreach ($this->providers as $provider_id => $provider) {
314 314
       $login_status = $provider->login(); // OK v4.5
315 315
       self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? $lang['sys_login_messages'][$provider->account_login_status] : dump($provider)));
316
-      if($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) {
316
+      if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) {
317 317
         $this->providers_authorised[$provider_id] = &$this->providers[$provider_id];
318 318
 
319 319
         $this->user_id_to_provider = array_replace_recursive(
@@ -321,15 +321,15 @@  discard block
 block discarded – undo
321 321
           // static::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5
322 322
           PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5
323 323
         );
324
-      } elseif($login_status != LOGIN_UNDEFINED) {
324
+      } elseif ($login_status != LOGIN_UNDEFINED) {
325 325
         $this->provider_error_list[$provider_id] = $login_status;
326 326
       }
327 327
     }
328 328
 
329
-    if(empty($this->providers_authorised)) {
329
+    if (empty($this->providers_authorised)) {
330 330
       // Ни один аккаунт не авторизирован
331 331
       // Проверяем - есть ли у нас ошибки в аккаунтах?
332
-      if(!empty($this->provider_error_list)) {
332
+      if (!empty($this->provider_error_list)) {
333 333
         // Если есть - выводим их
334 334
         self::$login_status = reset($this->provider_error_list);
335 335
       }
@@ -344,12 +344,12 @@  discard block
 block discarded – undo
344 344
       // В self::$accessible_user_row_list - список доступных игроков для данных аккаунтов с соответствующими записями из таблицы `users`
345 345
 
346 346
       // Остались ли у нас в списке доступные игроки?
347
-      if(empty($this->accessible_user_row_list)) {
347
+      if (empty($this->accessible_user_row_list)) {
348 348
         // Нет ни одного игрока ни на одном авторизированном аккаунте
349 349
         // Надо регать нового игрока
350 350
 
351 351
         // Сейчас происходит процесс регистрации игрока?
352
-        if(!$this->is_player_register) {
352
+        if (!$this->is_player_register) {
353 353
           // Нет - отправляем на процесс регистрации
354 354
           $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id'));
355 355
           sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : ''));
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
         // Да, есть доступные игроки, которые так же прописаны в базе
359 359
         $this->get_active_user(); // 4.5
360 360
 
361
-        if($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) {
361
+        if ($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) {
362 362
           $a_user = db_user_by_id($this->is_impersonating);
363 363
           $this->impersonator_username = $a_user['username'];
364 364
         }
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
 
367 367
         //Прописываем текущего игрока на все авторизированные аккаунты
368 368
         // TODO - ИЛИ ВСЕХ ИГРОКОВ??
369
-        if(empty($this->is_impersonating)) {
370
-          foreach($this->providers_authorised as $provider_id => $provider) {
371
-            if(empty($this->user_id_to_provider[self::$user['id']][$provider_id])) {
369
+        if (empty($this->is_impersonating)) {
370
+          foreach ($this->providers_authorised as $provider_id => $provider) {
371
+            if (empty($this->user_id_to_provider[self::$user['id']][$provider_id])) {
372 372
               // self::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']);
373 373
               PlayerToAccountTranslate::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']);
374 374
               $this->user_id_to_provider[self::$user['id']][$provider_id][$provider->account->account_id] = true;
@@ -378,9 +378,9 @@  discard block
 block discarded – undo
378 378
       }
379 379
     }
380 380
 
381
-    if(empty(self::$user['id'])) {
381
+    if (empty(self::$user['id'])) {
382 382
       self::cookie_set(''); // OK 4.5
383
-    } elseif(self::$user['id'] != $_COOKIE[SN_COOKIE_U]) {
383
+    } elseif (self::$user['id'] != $_COOKIE[SN_COOKIE_U]) {
384 384
       self::cookie_set(self::$user['id']); // OK 4.5
385 385
     }
386 386
 
@@ -399,21 +399,21 @@  discard block
 block discarded – undo
399 399
    */
400 400
   // OK v4.7
401 401
   public function logout($redirect = true) {
402
-    if(!empty($_COOKIE[SN_COOKIE_U_I])) {
402
+    if (!empty($_COOKIE[SN_COOKIE_U_I])) {
403 403
       self::cookie_set($_COOKIE[SN_COOKIE_U_I]);
404 404
       self::cookie_set(0, true);
405 405
       self::$main_provider->logout();
406 406
     } else {
407
-      foreach($this->providers as $provider_name => $provider) {
407
+      foreach ($this->providers as $provider_name => $provider) {
408 408
         $provider->logout();
409 409
       }
410 410
 
411 411
       self::cookie_set(0);
412 412
     }
413 413
 
414
-    if($redirect === true) {
414
+    if ($redirect === true) {
415 415
       sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php'));
416
-    } elseif($redirect !== false) {
416
+    } elseif ($redirect !== false) {
417 417
       sys_redirect($redirect);
418 418
     }
419 419
   }
@@ -424,15 +424,15 @@  discard block
 block discarded – undo
424 424
    * @param $user_selected
425 425
    */
426 426
   public function impersonate($user_selected) {
427
-    if($_COOKIE[SN_COOKIE_U_I]) {
427
+    if ($_COOKIE[SN_COOKIE_U_I]) {
428 428
       die('You already impersonating someone. Go back to living other\'s life! Or clear your cookies and try again'); // TODO: Log it
429 429
     }
430 430
 
431
-    if($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) {
431
+    if ($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) {
432 432
       die('You can\'t impersonate - too low level'); // TODO: Log it
433 433
     }
434 434
 
435
-    if($this->auth_level_max_local <= $user_selected['authlevel']) {
435
+    if ($this->auth_level_max_local <= $user_selected['authlevel']) {
436 436
       die('You can\'t impersonate this account - level is greater or equal to yours'); // TODO: Log it
437 437
     }
438 438
 
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
     $account_translate = reset($account_translate[$user_selected['id']][self::$main_provider->provider_id]);
441 441
     $account_to_impersonate = new Account(self::$main_provider->db);
442 442
     $account_to_impersonate->db_get_by_id($account_translate['provider_account_id']);
443
-    if(!$account_to_impersonate->is_exists) {
443
+    if (!$account_to_impersonate->is_exists) {
444 444
       die('Какая-то ошибка - не могу найти аккаунт для имперсонации'); // TODO: Log it
445 445
     }
446 446
     self::$main_provider->impersonate($account_to_impersonate);
@@ -466,12 +466,12 @@  discard block
 block discarded – undo
466 466
   public function password_check($password_unsafe) {
467 467
     $result = false;
468 468
 
469
-    if(empty($this->providers_authorised)) {
469
+    if (empty($this->providers_authorised)) {
470 470
       // TODO - такого быть не может!
471 471
       self::flog("password_check: Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true);
472 472
     } else {
473
-      foreach($this->providers_authorised as $provider_id => $provider) {
474
-        if($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) {
473
+      foreach ($this->providers_authorised as $provider_id => $provider) {
474
+        if ($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) {
475 475
           $result = $result || $provider->password_check($password_unsafe);
476 476
         }
477 477
       }
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
   public function password_change($old_password_unsafe, $new_password_unsafe) {
493 493
     global $lang;
494 494
 
495
-    if(empty($this->providers_authorised)) {
495
+    if (empty($this->providers_authorised)) {
496 496
       // TODO - такого быть не может!
497 497
       self::flog("Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true);
498 498
       return false;
@@ -505,8 +505,8 @@  discard block
 block discarded – undo
505 505
     $salt_unsafe = self::password_salt_generate();
506 506
 
507 507
     $providers_changed_password = array();
508
-    foreach($this->providers_authorised as $provider_id => $provider) {
509
-      if(
508
+    foreach ($this->providers_authorised as $provider_id => $provider) {
509
+      if (
510 510
         !$provider->is_feature_supported(AUTH_FEATURE_PASSWORD_CHANGE)
511 511
         || !$provider->password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe)
512 512
       ) {
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
       $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id);
519 519
 
520 520
       // Рассылаем уведомления о смене пароля в ЛС
521
-      foreach($account_translation as $user_id => $provider_info) {
521
+      foreach ($account_translation as $user_id => $provider_info) {
522 522
         // TODO - УКазывать тип аккаунта, на котором сменён пароль
523 523
         msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN,
524 524
           $lang['sys_administration'], $lang['sys_login_register_message_title'],
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
       sn_db_transaction_start();
566 566
       // Проверить наличие такого имени в истории имён
567 567
 
568
-      if(db_player_name_exists($player_name_unsafe)) {
568
+      if (db_player_name_exists($player_name_unsafe)) {
569 569
         throw new Exception(REGISTER_ERROR_PLAYER_NAME_EXISTS, ERR_ERROR);
570 570
       }
571 571
 
@@ -573,11 +573,11 @@  discard block
 block discarded – undo
573 573
       $player_language = '';
574 574
       $player_email = '';
575 575
       // TODO - порнография - работа должна происходить над списком аккаунтов, а не только на одном аккаунте...
576
-      foreach($this->providers_authorised as $provider) {
577
-        if(!$player_language && $provider->account->account_language) {
576
+      foreach ($this->providers_authorised as $provider) {
577
+        if (!$player_language && $provider->account->account_language) {
578 578
           $player_language = $provider->account->account_language;
579 579
         }
580
-        if(!$player_email && $provider->account->account_email) {
580
+        if (!$player_email && $provider->account->account_email) {
581 581
           $player_email = $provider->account->account_email;
582 582
         }
583 583
       }
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
       ));
594 594
       // Зарегестрировать на него аккаунты из self::$accounts_authorised
595 595
       $a_user = self::$user;
596
-      foreach($this->providers_authorised as $provider) {
596
+      foreach ($this->providers_authorised as $provider) {
597 597
         // TODO - порнография. Должен быть отдельный класс трансляторов - в т.ч. и кэширующий транслятор
598 598
         // TODO - ну и работа должна происходить над списком аккаунтов, а не только на одном аккаунте...
599 599
         // self::db_translate_register_user($provider->provider_id, $provider->account->account_id, $a_user['id']);
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 
606 606
       sn_db_transaction_commit();
607 607
       $this->register_status = LOGIN_SUCCESS;
608
-    } catch(Exception $e) {
608
+    } catch (Exception $e) {
609 609
       sn_db_transaction_rollback();
610 610
 
611 611
       // Если старое имя занято
@@ -624,10 +624,10 @@  discard block
 block discarded – undo
624 624
     // Пробиваем все ИД игроков по базе - есть ли вообще такие записи
625 625
     // Вообще-то это не особо нужно - у нас по определению стоят констраинты
626 626
     // Зато так мы узнаем максимальный authlevel, проверим права имперсонейта и вытащим все записи юзеров
627
-    foreach($this->user_id_to_provider as $user_id => $cork) {
627
+    foreach ($this->user_id_to_provider as $user_id => $cork) {
628 628
       $user = db_user_by_id($user_id);
629 629
       // Если записи игрока в БД не существует?
630
-      if(empty($user['id'])) {
630
+      if (empty($user['id'])) {
631 631
         // Удаляем этого и переходим к следующему
632 632
         unset($this->user_id_to_provider[$user_id]);
633 633
         // Де-регистрируем игрока из таблицы трансляции игроков
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
   // OK v4.5
649 649
   protected function get_active_user() {
650 650
     // Проверяем куку "текущего игрока" из браузера
651
-    if(
651
+    if (
652 652
       // Кука не пустая
653 653
       ($_COOKIE[SN_COOKIE_U] = trim($_COOKIE[SN_COOKIE_U])) && !empty($_COOKIE[SN_COOKIE_U])
654 654
       // И в куке находится ID
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
     }
674 674
 
675 675
     // В куке нет валидного ИД записи игрока, доступной с текущих аккаунтов
676
-    if(empty(self::$user['id'])) {
676
+    if (empty(self::$user['id'])) {
677 677
       // Берем первого из доступных
678 678
       // TODO - default_user
679 679
       self::$user = reset($this->accessible_user_row_list);
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 
698 698
     $result = array();
699 699
 
700
-    if($user_id && empty($this->is_impersonating)) {
700
+    if ($user_id && empty($this->is_impersonating)) {
701 701
       // self::db_counter_insert();
702 702
       self::$device->db_counter_insert($user_id);
703 703
 
@@ -705,12 +705,12 @@  discard block
 block discarded – undo
705 705
 
706 706
       sys_user_options_unpack($user);
707 707
 
708
-      if($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) {
708
+      if ($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) {
709 709
         $user['banaday'] = 0;
710 710
         $user['vacation'] = SN_TIME_NOW;
711 711
       }
712 712
 
713
-      $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip'];
713
+      $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip'];
714 714
       $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain'];
715 715
 
716 716
       $result[F_BANNED_STATUS] = $user['banaday'];
@@ -724,9 +724,9 @@  discard block
 block discarded – undo
724 724
       );
725 725
     }
726 726
 
727
-    if($extra = $config->security_ban_extra) {
727
+    if ($extra = $config->security_ban_extra) {
728 728
       $extra = explode(',', $extra);
729
-      array_walk($extra,'trim');
729
+      array_walk($extra, 'trim');
730 730
       in_array(self::$device->device_id, $extra) and die();
731 731
     }
732 732
 
@@ -762,21 +762,21 @@  discard block
 block discarded – undo
762 762
   protected function register_player_name_validate($player_name_unsafe) {
763 763
     // TODO - переделать под RAW-строки
764 764
     // Если имя игрока пустое - NO GO!
765
-    if(trim($player_name_unsafe) == '') {
765
+    if (trim($player_name_unsafe) == '') {
766 766
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_EMPTY, ERR_ERROR);
767 767
     }
768 768
     // Проверяем, что бы в начале и конце не было пустых символов
769
-    if($player_name_unsafe != trim($player_name_unsafe)) {
769
+    if ($player_name_unsafe != trim($player_name_unsafe)) {
770 770
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_TRIMMED, ERR_ERROR);
771 771
     }
772 772
     // Если логин имеет запрещенные символы - NO GO!
773
-    if(strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
773
+    if (strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
774 774
       // TODO - выдавать в сообщение об ошибке список запрещенных символов
775 775
       // TODO - заранее извещать игрока, какие символы являются запрещенными
776 776
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_RESTRICTED_CHARACTERS, ERR_ERROR);
777 777
     }
778 778
     // Если логин меньше минимальной длины - NO GO!
779
-    if(strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) {
779
+    if (strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) {
780 780
       // TODO - выдавать в сообщение об ошибке минимальную длину имени игрока
781 781
       // TODO - заранее извещать игрока, какая минимальная и максимальная длина имени
782 782
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_SHORT, ERR_ERROR);
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
   }
835 835
 
836 836
   protected static function flog($message, $die = false) {
837
-    if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
837
+    if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
838 838
       return;
839 839
     }
840 840
     list($called, $caller) = debug_backtrace(false);
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
     $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false;
848 848
 
849 849
     classSupernova::log_file("$message - $caller_name");
850
-    if($die) {
850
+    if ($die) {
851 851
       // pdump($caller);
852 852
       // pdump(debug_backtrace(false));
853 853
       $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>");
Please login to merge, or discard this patch.
includes/classes/RequestInfo.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -89,15 +89,15 @@  discard block
 block discarded – undo
89 89
     // Инфа об устройстве и браузере - общая для всех
90 90
     sn_db_transaction_start();
91 91
     $this->device_cypher = $_COOKIE[SN_COOKIE_D];
92
-    if($this->device_cypher) {
92
+    if ($this->device_cypher) {
93 93
       $cypher_safe = db_escape($this->device_cypher);
94 94
       $device_id = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true);
95
-      if(!empty($device_id['device_id'])) {
95
+      if (!empty($device_id['device_id'])) {
96 96
         $this->device_id = $device_id['device_id'];
97 97
       }
98 98
     }
99 99
 
100
-    if($this->device_id <= 0) {
100
+    if ($this->device_id <= 0) {
101 101
       do {
102 102
         $cypher_safe = db_escape($this->device_cypher = sys_random_string());
103 103
         $row = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true);
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
     $this->page_address_id = db_get_set_unique_id_value($this->page_address, 'url_id', 'security_url', 'url_string');
119 119
     sn_db_transaction_commit();
120 120
 
121
-    if($this->write_full_url) {
121
+    if ($this->write_full_url) {
122 122
       sn_db_transaction_start();
123 123
       $this->page_url = substr($_SERVER['REQUEST_URI'], strlen(SN_ROOT_RELATIVE));
124
-      if(strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) {
124
+      if (strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) {
125 125
         $this->page_url = '/simulator.php';
126 126
       }
127 127
       $this->page_url_id = db_get_set_unique_id_value($this->page_url, 'url_id', 'security_url', 'url_string');
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
    */
145 145
   public function db_security_entry_insert($user_id_unsafe) {
146 146
     // TODO $user_id = !empty(self::$user['id']) ? self::$user['id'] : 'NULL';
147
-    if(empty($user_id_unsafe)) {
147
+    if (empty($user_id_unsafe)) {
148 148
       // self::flog('Нет ИД пользователя');
149 149
       return true;
150 150
     }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
   public function db_counter_insert($user_id_unsafe) {
168 168
     global $config, $sys_stop_log_hit, $is_watching;
169 169
 
170
-    if($sys_stop_log_hit || !$config->game_counter) {
170
+    if ($sys_stop_log_hit || !$config->game_counter) {
171 171
       return;
172 172
     }
173 173
 
@@ -183,14 +183,14 @@  discard block
 block discarded – undo
183 183
 //      $this->ip_v4_int . ", '{$proxy_safe}', " . $this->page_address_id . ", " . $this->page_url_id . ");");
184 184
     doquery(
185 185
       "INSERT INTO {{counter}} SET
186
-        `visit_time` = '" . SN_TIME_SQL. "',
186
+        `visit_time` = '" . SN_TIME_SQL . "',
187 187
         `user_id` = {$user_id_safe},
188 188
         `device_id` = {$this->device_id},
189 189
         `browser_id` = {$this->browser_id},
190 190
         `user_ip` = {$this->ip_v4_int},
191 191
         `user_proxy` = '{$proxy_safe}',
192 192
         `page_url_id` = {$this->page_address_id}" .
193
-        ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '' ).
193
+        ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '') .
194 194
       ";");
195 195
 
196 196
     $is_watching = false;
Please login to merge, or discard this patch.
includes/classes/core_classes.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
     !is_array($offset) ? $offset = array($offset) : false;
39 39
 
40 40
     $current_leaf = $this->__get(reset($offset));
41
-    while(($leaf_index = next($offset)) !== false) {
42
-      if(!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) {
41
+    while (($leaf_index = next($offset)) !== false) {
42
+      if (!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) {
43 43
         unset($current_leaf);
44 44
         break;
45 45
       }
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 
65 65
     !is_array($offset) ? $offset = array($offset) : false;
66 66
 
67
-    if($this->offsetExists($offset)) {
67
+    if ($this->offsetExists($offset)) {
68 68
       $result = $this->__get(reset($offset));
69
-      while(($leaf_index = next($offset)) !== false) {
69
+      while (($leaf_index = next($offset)) !== false) {
70 70
         $result = $result[$leaf_index];
71 71
       }
72 72
     }
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
    */
92 92
   public function offsetSet($offset, $value = null) {
93 93
     // Если нет никакого индекса - значит нечего записывать
94
-    if(!isset($offset) || (is_array($offset) && empty($offset))) {
94
+    if (!isset($offset) || (is_array($offset) && empty($offset))) {
95 95
       return;
96 96
     }
97 97
 
98 98
     // Если в массиве индекса только один элемент - значит это просто индекс
99
-    if(is_array($offset) && count($offset) == 1) {
99
+    if (is_array($offset) && count($offset) == 1) {
100 100
       // Разворачиваем его в индекс
101 101
       $offset = array(reset($offset) => $value);
102 102
       unset($value);
@@ -104,20 +104,20 @@  discard block
 block discarded – undo
104 104
     }
105 105
 
106 106
     // Адресация многомерного массива через массив индексов в $option
107
-    if(is_array($offset) && isset($value)) {
107
+    if (is_array($offset) && isset($value)) {
108 108
       // TODO - а не переделать ли это всё на __isset() ??
109 109
 //pdump($offset, '$offset');
110 110
 //pdump($value, '$value');
111 111
       // Вытаскиваем корневой элемент
112 112
       $root = $this->__get(reset($offset));
113 113
       $current_leaf = &$root;
114
-      while(($leaf_index = next($offset)) !== false) {
114
+      while (($leaf_index = next($offset)) !== false) {
115 115
         !is_array($current_leaf[$leaf_index]) ? $current_leaf[$leaf_index] = array() : false;
116 116
         $current_leaf = &$current_leaf[$leaf_index];
117 117
       }
118 118
 //pdump($current_leaf, '$current_leaf');
119 119
 //pdump($value, '$value');
120
-      if($current_leaf != $value) {
120
+      if ($current_leaf != $value) {
121 121
         $current_leaf = $value;
122 122
 //pdump(reset($offset), 'reset($offset)');
123 123
 //pdump($root, '$root');
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
       // Пакетная запись из массива ключ -> значение
129 129
       !is_array($offset) ? $offset = array($offset => $value) : false;
130 130
 
131
-      foreach($offset as $key => $value) {
131
+      foreach ($offset as $key => $value) {
132 132
         $this->__get($key) !== $value ? $this->__set($key, $value) : false;
133 133
       }
134 134
     }
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
    */
150 150
   public function offsetUnset($offset) {
151 151
     // Если нет никакого индекса - значит нечего записывать
152
-    if(!isset($offset) || (is_array($offset) && empty($offset))) {
152
+    if (!isset($offset) || (is_array($offset) && empty($offset))) {
153 153
       return;
154 154
     }
155 155
 
156 156
     !is_array($offset) ? $offset = array($offset) : false;
157 157
 
158
-    if($this->offsetExists($offset)) {
158
+    if ($this->offsetExists($offset)) {
159 159
 //pdump($offset);
160 160
       // Перематываем массив в конец
161 161
       $key_to_delete = end($offset);
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 //pdump($key_to_delete, '$key_to_delete');
164 164
       $parent_offset = $offset;
165 165
       array_pop($parent_offset);
166
-      if(!count($parent_offset)) {
166
+      if (!count($parent_offset)) {
167 167
         // В массиве был один элемент - мы удаляем в корне. Просто удаляем элемент
168 168
         $this->__unset($key_to_delete);
169 169
       } else {
Please login to merge, or discard this patch.
includes/classes/cache.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@  discard block
 block discarded – undo
13 13
 * Defining some constants
14 14
 */
15 15
 define('CACHER_NOT_INIT', -1);
16
-define('CACHER_NO_CACHE',  0);
17
-define('CACHER_XCACHE'  ,  1);
16
+define('CACHER_NO_CACHE', 0);
17
+define('CACHER_XCACHE', 1);
18 18
 
19 19
 define('CACHER_LOCK_WAIT', 5); // maximum cacher wait for table unlock in seconds. Can be float
20 20
 
@@ -46,19 +46,19 @@  discard block
 block discarded – undo
46 46
   protected static $cacheObject;
47 47
 
48 48
   public function __construct($prefIn = 'CACHE_', $init_mode = false) {
49
-    if( !($init_mode === false || $init_mode === CACHER_NO_CACHE || ($init_mode === CACHER_XCACHE && extension_loaded('xcache')) )) {
49
+    if (!($init_mode === false || $init_mode === CACHER_NO_CACHE || ($init_mode === CACHER_XCACHE && extension_loaded('xcache')))) {
50 50
       throw new UnexpectedValueException('Wrong work mode or current mode does not supported on your server');
51 51
     }
52 52
 
53 53
     $this->prefix = $prefIn;
54
-    if(extension_loaded('xcache') && ($init_mode === CACHER_XCACHE || $init_mode === false)) {
55
-      if(self::$mode === CACHER_NOT_INIT) {
54
+    if (extension_loaded('xcache') && ($init_mode === CACHER_XCACHE || $init_mode === false)) {
55
+      if (self::$mode === CACHER_NOT_INIT) {
56 56
         self::$mode = CACHER_XCACHE;
57 57
       }
58 58
     } else {
59
-      if(self::$mode === CACHER_NOT_INIT) {
59
+      if (self::$mode === CACHER_NOT_INIT) {
60 60
         self::$mode = CACHER_NO_CACHE;
61
-        if(!self::$data) {
61
+        if (!self::$data) {
62 62
          self::$data = array();
63 63
         }
64 64
       }
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
       default:
95 95
         switch (self::$mode) {
96 96
           case CACHER_NO_CACHE:
97
-            self::$data[$this->prefix.$name] = $value;
97
+            self::$data[$this->prefix . $name] = $value;
98 98
           break;
99 99
 
100 100
           case CACHER_XCACHE:
101
-            xcache_set($this->prefix.$name, $value);
101
+            xcache_set($this->prefix . $name, $value);
102 102
           break;
103 103
         }
104 104
       break;
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
       default:
119 119
         switch (self::$mode) {
120 120
           case CACHER_NO_CACHE:
121
-            return self::$data[$this->prefix.$name];
121
+            return self::$data[$this->prefix . $name];
122 122
           break;
123 123
 
124 124
           case CACHER_XCACHE:
125
-            return xcache_get($this->prefix.$name);
125
+            return xcache_get($this->prefix . $name);
126 126
           break;
127 127
 
128 128
         }
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
   public function __isset($name) {
136 136
     switch (self::$mode) {
137 137
       case CACHER_NO_CACHE:
138
-        return isset(self::$data[$this->prefix.$name]);
138
+        return isset(self::$data[$this->prefix . $name]);
139 139
       break;
140 140
 
141 141
       case CACHER_XCACHE:
142
-        return xcache_isset($this->prefix.$name) && ($this->__get($name) !== null);
142
+        return xcache_isset($this->prefix . $name) && ($this->__get($name) !== null);
143 143
       break;
144 144
     }
145 145
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 
161 161
   public function unset_by_prefix($prefix_unset = '') {
162 162
     static $array_clear;
163
-    !$array_clear ? $array_clear = function(&$v,$k,$p) {
163
+    !$array_clear ? $array_clear = function(&$v, $k, $p) {
164 164
       strpos($k, $p) === 0 ? $v = NULL : false;
165 165
     } : false;
166 166
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
       break;
173 173
 
174 174
       case CACHER_XCACHE:
175
-        if(!function_exists('xcache_unset_by_prefix')) {
175
+        if (!function_exists('xcache_unset_by_prefix')) {
176 176
           return false;
177 177
         }
178 178
         return xcache_unset_by_prefix($this->prefix . $prefix_unset);
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
   protected function make_element_name($args, $diff = 0) {
189 189
     $num_args = count($args);
190 190
 
191
-    if($num_args < 1) {
191
+    if ($num_args < 1) {
192 192
       return false;
193 193
     }
194 194
 
195 195
     $name = '';
196 196
     $aName = array();
197
-    for($i = 0; $i <= $num_args - 1 - $diff; $i++) {
197
+    for ($i = 0; $i <= $num_args - 1 - $diff; $i++) {
198 198
       $name .= "[{$args[$i]}]";
199 199
       array_unshift($aName, $name);
200 200
     }
@@ -206,15 +206,15 @@  discard block
 block discarded – undo
206 206
     $args = func_get_args();
207 207
     $name = $this->make_element_name($args, 1);
208 208
 
209
-    if(!$name) {
209
+    if (!$name) {
210 210
       return NULL;
211 211
     }
212 212
 
213
-    if($this->$name[0] === NULL) {
214
-      for($i = count($name) - 1; $i > 0; $i--) {
213
+    if ($this->$name[0] === NULL) {
214
+      for ($i = count($name) - 1; $i > 0; $i--) {
215 215
         $cName = "{$name[$i]}_COUNT";
216
-        $cName1 = "{$name[$i-1]}_COUNT";
217
-        if($this->$cName1 == NULL || $i == 1) {
216
+        $cName1 = "{$name[$i - 1]}_COUNT";
217
+        if ($this->$cName1 == NULL || $i == 1) {
218 218
           $this->$cName++;
219 219
         }
220 220
       }
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 
227 227
   public function array_get() {
228 228
     $name = $this->make_element_name(func_get_args());
229
-    if(!$name) {
229
+    if (!$name) {
230 230
       return NULL;
231 231
     }
232 232
     return $this->$name[0];
@@ -234,12 +234,12 @@  discard block
 block discarded – undo
234 234
 
235 235
   public function array_count() {
236 236
     $name = $this->make_element_name(func_get_args());
237
-    if(!$name) {
237
+    if (!$name) {
238 238
       return 0;
239 239
     }
240 240
     $cName = "{$name[0]}_COUNT";
241 241
     $retVal = $this->$cName;
242
-    if(!$retVal) {
242
+    if (!$retVal) {
243 243
       $retVal = NULL;
244 244
     }
245 245
     return $retVal;
@@ -248,18 +248,18 @@  discard block
 block discarded – undo
248 248
   public function array_unset() {
249 249
     $name = $this->make_element_name(func_get_args());
250 250
 
251
-    if(!$name) {
251
+    if (!$name) {
252 252
       return false;
253 253
     }
254 254
     $this->unset_by_prefix($name[0]);
255 255
 
256
-    for($i = 1; $i < count($name); $i++) {
256
+    for ($i = 1; $i < count($name); $i++) {
257 257
       $cName = "{$name[$i]}_COUNT";
258
-      $cName1 = "{$name[$i-1]}_COUNT";
258
+      $cName1 = "{$name[$i - 1]}_COUNT";
259 259
 
260
-      if($i == 1 || $this->$cName1 === NULL) {
260
+      if ($i == 1 || $this->$cName1 === NULL) {
261 261
         $this->$cName--;
262
-        if($this->$cName <= 0) {
262
+        if ($this->$cName <= 0) {
263 263
           unset($this->$cName);
264 264
         }
265 265
       }
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
     $this->sql_index_field = "{$table_name}_name";
320 320
     $this->sql_value_field = "{$table_name}_value";
321 321
 
322
-    if(!$this->_DB_LOADED) {
322
+    if (!$this->_DB_LOADED) {
323 323
       $this->db_loadAll();
324 324
     }
325 325
   }
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 
335 335
   public function db_loadItem($index) {
336 336
     $result = null;
337
-    if($index) {
337
+    if ($index) {
338 338
       $index_safe = db_escape($index);
339 339
       $result = doquery("SELECT `{$this->sql_value_field}` FROM `{{{$this->table_name}}}` WHERE `{$this->sql_index_field}` = '{$index_safe}' FOR UPDATE", true);
340 340
       // В две строки - что бы быть уверенным в порядке выполнения
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
     $this->loadDefaults();
349 349
 
350 350
     $query = doquery("SELECT * FROM {{{$this->table_name}}} FOR UPDATE;");
351
-    while($row = db_fetch($query)) {
351
+    while ($row = db_fetch($query)) {
352 352
       $this->$row[$this->sql_index_field] = $row[$this->sql_value_field];
353 353
     }
354 354
 
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
   }
357 357
 
358 358
   public function loadDefaults() {
359
-    foreach($this->defaults as $defName => $defValue) {
359
+    foreach ($this->defaults as $defName => $defValue) {
360 360
       $this->$defName = $defValue;
361 361
     }
362 362
   }
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
   }
373 373
 
374 374
   public function db_saveItem($item_list, $value = NULL) {
375
-    if(empty($item_list)) {
375
+    if (empty($item_list)) {
376 376
       return;
377 377
     }
378 378
 
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
 
381 381
     // Сначала записываем данные в базу - что бы поймать все блокировки
382 382
     $qry = array();
383
-    foreach($item_list as $item_name => $item_value) {
384
-      if($item_name) {
383
+    foreach ($item_list as $item_name => $item_value) {
384
+      if ($item_name) {
385 385
         $item_value = db_escape($item_value === NULL ? $this->$item_name : $item_value);
386 386
         $item_name = db_escape($item_name);
387 387
         $qry[] = "('{$item_name}', '{$item_value}')";
@@ -390,8 +390,8 @@  discard block
 block discarded – undo
390 390
     doquery("REPLACE INTO `{{" . $this->table_name . "}}` (`{$this->sql_index_field}`, `{$this->sql_value_field}`) VALUES " . implode(',', $qry) . ";");
391 391
 
392 392
     // И только после взятия блокировок - меняем значения в кэше
393
-    foreach($item_list as $item_name => $item_value) {
394
-      if($item_name && $item_value !== NULL) {
393
+    foreach ($item_list as $item_name => $item_value) {
394
+      if ($item_name && $item_value !== NULL) {
395 395
         $this->$item_name = $item_value;
396 396
       }
397 397
     }
@@ -419,9 +419,9 @@  discard block
 block discarded – undo
419 419
     'advGoogleLeftMenuCode'        => '(Place here code for banner)',
420 420
 
421 421
     // Alliance bonus calculations
422
-    'ali_bonus_algorithm'          => 0,  // Bonus calculation algorithm
422
+    'ali_bonus_algorithm'          => 0, // Bonus calculation algorithm
423 423
     'ali_bonus_brackets'           => 10, // Brackets count for ALI_BONUS_BY_RANK
424
-    'ali_bonus_brackets_divisor'   => 10,// Bonus divisor for ALI_BONUS_BY_RANK
424
+    'ali_bonus_brackets_divisor'   => 10, // Bonus divisor for ALI_BONUS_BY_RANK
425 425
     'ali_bonus_divisor'            => 10000000, // Rank divisor for ALI_BONUS_BY_POINTS
426 426
     'ali_bonus_members'            => 10, // Minumum alliace size to start using bonus
427 427
 
@@ -452,25 +452,25 @@  discard block
 block discarded – undo
452 452
     'deuterium_basic_income'       => 0,
453 453
     'eco_scale_storage'            => 1,
454 454
     'eco_stockman_fleet'           => '', // Black Market - Starting amount of s/h ship merchant to sell
455
-    'eco_stockman_fleet_populate'  => 1,  // Populate empty Stockman fleet with ships or not
455
+    'eco_stockman_fleet_populate'  => 1, // Populate empty Stockman fleet with ships or not
456 456
     'empire_mercenary_base_period' => PERIOD_MONTH, // Base
457 457
     'empire_mercenary_temporary'   => 0, // Temporary empire-wide mercenaries
458 458
     'energy_basic_income'          => 0,
459 459
 
460 460
     // Bashing protection settings
461
-    'fleet_bashing_attacks'        => 3,      // Max amount of attack per wave - 3 by default
462
-    'fleet_bashing_interval'       => 1800,   // Maximum interval between attacks when they still count as one wave - 30m by default
463
-    'fleet_bashing_scope'          => 86400,  // Interval on which bashing waves counts - 24h by default
464
-    'fleet_bashing_war_delay'      => 43200,  // Delay before start bashing after declaring war to alliance - 12h by default
465
-    'fleet_bashing_waves'          => 3,      // Max amount of waves per day - 3 by default
461
+    'fleet_bashing_attacks'        => 3, // Max amount of attack per wave - 3 by default
462
+    'fleet_bashing_interval'       => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default
463
+    'fleet_bashing_scope'          => 86400, // Interval on which bashing waves counts - 24h by default
464
+    'fleet_bashing_war_delay'      => 43200, // Delay before start bashing after declaring war to alliance - 12h by default
465
+    'fleet_bashing_waves'          => 3, // Max amount of waves per day - 3 by default
466 466
 
467 467
     'Fleet_Cdr'                    => 30,
468 468
     'fleet_speed'                  => 1,
469 469
 
470 470
     'fleet_update_interval'        => 4,
471 471
 
472
-    'game_adminEmail'              => 'root@localhost',    // Admin's email to show to users
473
-    'game_counter'                 => 0,  // Does built-in page hit counter is on?
472
+    'game_adminEmail'              => 'root@localhost', // Admin's email to show to users
473
+    'game_counter'                 => 0, // Does built-in page hit counter is on?
474 474
     // Defaults
475 475
     'game_default_language'        => 'ru',
476 476
     'game_default_skin'            => 'skins/EpicBlue/',
@@ -484,13 +484,13 @@  discard block
 block discarded – undo
484 484
     'game_maxSystem'               => 199,
485 485
     'game_maxPlanet'               => 15,
486 486
     // Game global settings
487
-    'game_mode'                    => 0,           // 0 - SuperNova, 1 - oGame
487
+    'game_mode'                    => 0, // 0 - SuperNova, 1 - oGame
488 488
     'game_name'                    => 'SuperNova', // Server name (would be on banners and on top of left menu)
489 489
 
490 490
     'game_news_actual'             => 259200, // How long announcement would be marked as "New". In seconds. Default - 3 days
491
-    'game_news_overview'           => 3,    // How much last news to show in Overview page
491
+    'game_news_overview'           => 3, // How much last news to show in Overview page
492 492
     // Noob protection
493
-    'game_noob_factor'             => 5,    // Multiplier to divide "stronger" and "weaker" users
493
+    'game_noob_factor'             => 5, // Multiplier to divide "stronger" and "weaker" users
494 494
     'game_noob_points'             => 5000, // Below this point user threated as noob. 0 to disable
495 495
 
496 496
     'game_multiaccount_enabled'    => 0, // 1 - allow interactions for players with same IP (multiaccounts)
@@ -539,8 +539,8 @@  discard block
 block discarded – undo
539 539
     'payment_currency_exchange_wmu' => 30,
540 540
     'payment_currency_exchange_wmz' => 1,
541 541
 
542
-    'payment_lot_price'             => 1,     // Lot price in default currency
543
-    'payment_lot_size'              => 2500,  // Lot size. Also service as minimum amount of DM that could be bought with one transaction
542
+    'payment_lot_price'             => 1, // Lot price in default currency
543
+    'payment_lot_size'              => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction
544 544
 
545 545
     'planet_teleport_cost'         => 50000, // 
546 546
     'planet_teleport_timeout'      => 86400, // 
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
     'resource_multiplier'          => 1,
559 559
 
560 560
     //Roleplay system
561
-    'rpg_bonus_divisor'            => 10,    // Amount of DM referral shoud get for partner have 1 DM bonus
561
+    'rpg_bonus_divisor'            => 10, // Amount of DM referral shoud get for partner have 1 DM bonus
562 562
     'rpg_bonus_minimum'            => 10000, // Minimum DM ammount for starting paying bonuses to affiliate
563 563
 
564 564
     // Black Market - General
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
   }
645 645
 
646 646
   public static function getInstance($gamePrefix = 'sn_', $table_name = 'config') {
647
-    if(!isset(self::$cacheObject)) {
647
+    if (!isset(self::$cacheObject)) {
648 648
       $className = get_class();
649 649
       self::$cacheObject = new $className($gamePrefix, $table_name);
650 650
     }
Please login to merge, or discard this patch.
includes/classes/Account.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
     $this->reset();
79 79
     $this->db = is_object($db) ? $db : classSupernova::$db;
80 80
 
81
-    foreach($this->table_check as $table_name) {
82
-      if(empty($this->db->table_list[$table_name])) {
81
+    foreach ($this->table_check as $table_name) {
82
+      if (empty($this->db->table_list[$table_name])) {
83 83
         die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br />
84 84
               В противном случае - сообщите Администрации сервера об ошибке.<br/>
85 85
               Не хватает таблицы для работы системы авторизации: ' . $table_name);
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
    */
104 104
   // OK v4.6
105 105
   public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) {
106
-    if(!$this->password_check($old_password_unsafe)) {
106
+    if (!$this->password_check($old_password_unsafe)) {
107 107
       return false;
108 108
     }
109 109
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
   // OK v4.5
125 125
   public function assign_from_db_row($row) {
126 126
     $this->reset();
127
-    if(empty($row) || !is_array($row)) {
127
+    if (empty($row) || !is_array($row)) {
128 128
       return false;
129 129
     }
130 130
     $this->account_id = $row['account_id'];
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
         `account_email` = LOWER('{$email_safe}'),
238 238
         `account_language` = '{$language_safe}'"
239 239
     );
240
-    if(!$result) {
240
+    if (!$result) {
241 241
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
242 242
     }
243 243
 
244
-    if(!($account_id = $this->db->db_insert_id())) {
244
+    if (!($account_id = $this->db->db_insert_id())) {
245 245
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
246 246
     }
247 247
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
       WHERE `account_id` = '{$account_id_safe}'"
272 272
     ) ? true : false;
273 273
 
274
-    if($result) {
274
+    if ($result) {
275 275
       $result = $this->db_get_by_id($this->account_id);
276 276
     }
277 277
 
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
   public function metamatter_change($change_type, $metamatter, $comment = false, $already_changed = false) {
352 352
     global $debug, $mm_change_legit, $config;
353 353
 
354
-    if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
354
+    if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
355 355
       $debug->error('Ошибка при попытке манипуляции с ММ');
356 356
       return false;
357 357
     }
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 
361 361
     $mm_change_legit = true;
362 362
     // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER);
363
-    if($already_changed) {
363
+    if ($already_changed) {
364 364
       $metamatter_total_delta = 0;
365 365
       $result = -1;
366 366
     } else {
@@ -373,13 +373,13 @@  discard block
 block discarded – undo
373 373
           ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$config->player_metamatter_immortal}, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '') .
374 374
         " WHERE `account_id` = {$account_id_safe}"
375 375
       );
376
-      if(!$result) {
376
+      if (!$result) {
377 377
         $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
378 378
       }
379 379
       $result = classSupernova::$db->db_affected_rows();
380 380
     }
381 381
 
382
-    if(empty(core_auth::$user['id'])) {
382
+    if (empty(core_auth::$user['id'])) {
383 383
       $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id);
384 384
       reset($user_list);
385 385
       $user_id_unsafe = key($user_list);
@@ -388,30 +388,30 @@  discard block
 block discarded – undo
388 388
     }
389 389
     $user_id_safe = $this->db->db_escape($user_id_unsafe);
390 390
 
391
-    if(!$result) {
391
+    if (!$result) {
392 392
       $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
393 393
     }
394 394
 
395
-    if(!$already_changed) {
395
+    if (!$already_changed) {
396 396
       $this->account_metamatter += $metamatter;
397 397
       $this->account_metamatter_total += $metamatter_total_delta;
398 398
     }
399 399
 
400
-    if(is_array($comment)) {
400
+    if (is_array($comment)) {
401 401
       $comment = call_user_func_array('sprintf', $comment);
402 402
     }
403 403
 
404 404
     $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe);
405 405
 
406
-    if($metamatter > 0 && !empty($user_id_safe)) {
406
+    if ($metamatter > 0 && !empty($user_id_safe)) {
407 407
       $old_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;", '', true);
408
-      if($old_referral['id']) {
408
+      if ($old_referral['id']) {
409 409
         $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM;
410 410
         doquery("UPDATE {{referrals}} SET dark_matter = dark_matter + '{$dark_matter_from_metamatter}' WHERE `id` = {$user_id_safe} LIMIT 1;");
411 411
         $new_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1;", '', true);
412 412
 
413 413
         $partner_bonus = floor($new_referral['dark_matter'] / $config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= $config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / $config->rpg_bonus_divisor) : 0);
414
-        if($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) {
414
+        if ($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) {
415 415
           rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}");
416 416
         }
417 417
       }
Please login to merge, or discard this patch.