Completed
Push — work-fleets ( f81083...2b6e2a )
by SuperNova.WS
06:05
created
includes/pages/options.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
   $language_new = sys_get_param_str('langer', $user['lang']);
14 14
 
15
-  if($language_new != $user['lang']) {
15
+  if ($language_new != $user['lang']) {
16 16
     classLocale::$lang->lng_switch($language_new);
17 17
   }
18 18
 
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 
22 22
   $FMT_DATE = preg_replace(array('/d/', '/m/', '/Y/'), array('DD', 'MM', 'YYYY'), FMT_DATE);
23 23
 
24
-  if(sys_get_param_str('mode') == 'change') {
25
-    if($user['authlevel'] > 0) {
24
+  if (sys_get_param_str('mode') == 'change') {
25
+    if ($user['authlevel'] > 0) {
26 26
       $planet_protection = sys_get_param_int('adm_pl_prot') ? $user['authlevel'] : 0;
27 27
       DBStaticPlanet::db_planet_set_by_owner(
28 28
         $user['id'],
@@ -39,27 +39,27 @@  discard block
 block discarded – undo
39 39
       );
40 40
     }
41 41
 
42
-    if(sys_get_param_int('vacation') && !classSupernova::$config->user_vacation_disable) {
42
+    if (sys_get_param_int('vacation') && !classSupernova::$config->user_vacation_disable) {
43 43
       sn_db_transaction_start();
44
-      if($user['authlevel'] < 3) {
45
-        if($user['vacation_next'] > SN_TIME_NOW) {
44
+      if ($user['authlevel'] < 3) {
45
+        if ($user['vacation_next'] > SN_TIME_NOW) {
46 46
           message(classLocale::$lang['opt_vacation_err_timeout'], classLocale::$lang['Error'], 'index.php?page=options', 5);
47 47
           die();
48 48
         }
49 49
 
50
-        if(FleetList::fleet_count_flying($user['id'])) {
50
+        if (FleetList::fleet_count_flying($user['id'])) {
51 51
           message(classLocale::$lang['opt_vacation_err_your_fleet'], classLocale::$lang['Error'], 'index.php?page=options', 5);
52 52
           die();
53 53
         }
54 54
 
55 55
         $que = que_get($user['id'], false);
56
-        if(!empty($que)) {
56
+        if (!empty($que)) {
57 57
           message(classLocale::$lang['opt_vacation_err_que'], classLocale::$lang['Error'], 'index.php?page=options', 5);
58 58
           die();
59 59
         }
60 60
 
61 61
         $query = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_PLANET, "`id_owner` = {$user['id']}");
62
-        foreach($query as $planet) {
62
+        foreach ($query as $planet) {
63 63
           $classConfig = classSupernova::$config;
64 64
           DBStaticPlanet::db_planet_update_set_by_id(
65 65
             $planet['id'],
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
       sn_db_transaction_commit();
88 88
     }
89 89
 
90
-    foreach($user_option_list as $option_group_id => $option_group) {
91
-      foreach($option_group as $option_name => $option_value) {
92
-        if($user[$option_name] !== null) {
90
+    foreach ($user_option_list as $option_group_id => $option_group) {
91
+      foreach ($option_group as $option_name => $option_value) {
92
+        if ($user[$option_name] !== null) {
93 93
           $user[$option_name] = sys_get_param_str($option_name);
94 94
         } else {
95 95
           $user[$option_name] = $option_value;
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 
101 101
 
102 102
     $player_options = sys_get_param('options');
103
-    if(!empty($player_options)) {
104
-      array_walk($player_options, function (&$value) {
103
+    if (!empty($player_options)) {
104
+      array_walk($player_options, function(&$value) {
105 105
         // TODO - Когда будет больше параметров - сделать больше проверок
106 106
         $value = intval($value);
107 107
       });
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
 
113 113
     $username = substr(sys_get_param_str_unsafe('username'), 0, 32);
114 114
     $username_safe = db_escape($username);
115
-    if($username && $user['username'] != $username && classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
115
+    if ($username && $user['username'] != $username && classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
116 116
       // проверка на корректность
117 117
       sn_db_transaction_start();
118 118
       $name_check = db_player_name_history_get_name_by_name($username_safe);
119
-      if(!$name_check || $name_check['player_id'] == $user['id']) {
119
+      if (!$name_check || $name_check['player_id'] == $user['id']) {
120 120
         $user = DBStaticUser::db_user_by_id($user['id'], true);
121
-        switch(classSupernova::$config->game_user_changename) {
121
+        switch (classSupernova::$config->game_user_changename) {
122 122
           case SERVER_PLAYER_NAME_CHANGE_PAY:
123
-            if(mrc_get_level($user, $planetrow, RES_DARK_MATTER) < classSupernova::$config->game_user_changename_cost) {
123
+            if (mrc_get_level($user, $planetrow, RES_DARK_MATTER) < classSupernova::$config->game_user_changename_cost) {
124 124
               $template_result['.']['result'][] = array(
125 125
                 'STATUS'  => ERR_ERROR,
126 126
                 'MESSAGE' => classLocale::$lang['opt_msg_name_change_err_no_dm'],
@@ -156,18 +156,18 @@  discard block
 block discarded – undo
156 156
       sn_db_transaction_commit();
157 157
     }
158 158
 
159
-    if($new_password = sys_get_param('newpass1')) {
159
+    if ($new_password = sys_get_param('newpass1')) {
160 160
       try {
161
-        if($new_password != sys_get_param('newpass2')) {
161
+        if ($new_password != sys_get_param('newpass2')) {
162 162
           throw new Exception(classLocale::$lang['opt_err_pass_unmatched'], ERR_WARNING);
163 163
         }
164 164
 
165
-        if(!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) {
165
+        if (!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) {
166 166
           throw new Exception(classLocale::$lang['opt_err_pass_wrong'], ERR_WARNING);
167 167
         }
168 168
 
169 169
         throw new Exception(classLocale::$lang['opt_msg_pass_changed'], ERR_NONE);
170
-      } catch(Exception $e) {
170
+      } catch (Exception $e) {
171 171
         $template_result['.']['result'][] = array(
172 172
           'STATUS'  => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR,
173 173
           'MESSAGE' => $e->getMessage()
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
     $user['gender'] = $user['gender'] == GENDER_UNKNOWN ? $gender : $user['gender'];
190 190
 
191 191
     try {
192
-      if($user['birthday']) {
192
+      if ($user['birthday']) {
193 193
         throw new exception();
194 194
       }
195 195
 
196 196
       $user_birthday = sys_get_param_str_unsafe('user_birthday');
197
-      if(!$user_birthday || $user_birthday == $FMT_DATE) {
197
+      if (!$user_birthday || $user_birthday == $FMT_DATE) {
198 198
         throw new exception();
199 199
       }
200 200
 
@@ -204,16 +204,16 @@  discard block
 block discarded – undo
204 204
       $pos['Y'] = strpos(FMT_DATE, 'Y');
205 205
       asort($pos);
206 206
       $i = 0;
207
-      foreach($pos as &$position) {
207
+      foreach ($pos as &$position) {
208 208
         $position = ++$i;
209 209
       }
210 210
 
211
-      $regexp = "/" . preg_replace(array('/\\\\/', '/\//', '/\./', '/\-/', '/d/', '/m/', '/Y/'), array('\\\\\\', '\/', '\.', '\-', '(\d?\d)', '(\d?\d)', '(\d{4})'), FMT_DATE) . "/";
212
-      if(!preg_match($regexp, $user_birthday, $match)) {
211
+      $regexp = "/".preg_replace(array('/\\\\/', '/\//', '/\./', '/\-/', '/d/', '/m/', '/Y/'), array('\\\\\\', '\/', '\.', '\-', '(\d?\d)', '(\d?\d)', '(\d{4})'), FMT_DATE)."/";
212
+      if (!preg_match($regexp, $user_birthday, $match)) {
213 213
         throw new exception();
214 214
       }
215 215
 
216
-      if(!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) {
216
+      if (!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) {
217 217
         throw new exception();
218 218
       }
219 219
 
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
       // EOF black magic! Now we have valid SQL date in $user['user_birthday'] - independent of date format
222 222
 
223 223
       $year = date('Y', SN_TIME_NOW);
224
-      if(mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) {
224
+      if (mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) {
225 225
         $year--;
226 226
       }
227 227
       $user['user_birthday_celebrated'] = "{$year}-{$match[$pos['m']]}-{$match[$pos['d']]}";
228 228
 
229
-    } catch(Exception $e) {
229
+    } catch (Exception $e) {
230 230
     }
231 231
 
232 232
     require_once('includes/includes/sys_avatar.php');
@@ -235,14 +235,14 @@  discard block
 block discarded – undo
235 235
     $template_result['.']['result'][] = $avatar_upload_result;
236 236
 
237 237
     $user_time_diff = playerTimeDiff::user_time_diff_get();
238
-    if(sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) {
238
+    if (sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) {
239 239
       playerTimeDiff::user_time_diff_set(array(
240 240
         PLAYER_OPTION_TIME_DIFF              => sys_get_param_int('PLAYER_OPTION_TIME_DIFF'),
241 241
         PLAYER_OPTION_TIME_DIFF_UTC_OFFSET   => 0,
242 242
         PLAYER_OPTION_TIME_DIFF_FORCED       => 1,
243 243
         PLAYER_OPTION_TIME_DIFF_MEASURE_TIME => SN_TIME_SQL,
244 244
       ));
245
-    } elseif(sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) {
245
+    } elseif (sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) {
246 246
       playerTimeDiff::user_time_diff_set(array(
247 247
         PLAYER_OPTION_TIME_DIFF              => '',
248 248
         PLAYER_OPTION_TIME_DIFF_UTC_OFFSET   => 0,
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
       'STATUS'  => ERR_NONE,
274 274
       'MESSAGE' => classLocale::$lang['opt_msg_saved']
275 275
     );
276
-  } elseif(sys_get_param_str('result') == 'ok') {
276
+  } elseif (sys_get_param_str('result') == 'ok') {
277 277
     $template_result['.']['result'][] = array(
278 278
       'STATUS'  => ERR_NONE,
279 279
       'MESSAGE' => classLocale::$lang['opt_msg_saved']
@@ -296,9 +296,9 @@  discard block
 block discarded – undo
296 296
 
297 297
   $template = gettemplate('options', $template);
298 298
 
299
-  $dir = dir(SN_ROOT_PHYSICAL . 'skins');
300
-  while(($entry = $dir->read()) !== false) {
301
-    if(is_dir("skins/{$entry}") && $entry[0] != '.') {
299
+  $dir = dir(SN_ROOT_PHYSICAL.'skins');
300
+  while (($entry = $dir->read()) !== false) {
301
+    if (is_dir("skins/{$entry}") && $entry[0] != '.') {
302 302
       $template_result['.']['skin_list'][] = array(
303 303
         'VALUE'    => $entry,
304 304
         'NAME'     => $entry,
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
   }
309 309
   $dir->close();
310 310
 
311
-  foreach(classLocale::$lang['opt_planet_sort_options'] as $key => &$value) {
311
+  foreach (classLocale::$lang['opt_planet_sort_options'] as $key => &$value) {
312 312
     $template_result['.']['planet_sort_options'][] = array(
313 313
       'VALUE'    => $key,
314 314
       'NAME'     => $value,
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
     );
317 317
   }
318 318
 
319
-  foreach(classLocale::$lang['sys_gender_list'] as $key => $value) {
319
+  foreach (classLocale::$lang['sys_gender_list'] as $key => $value) {
320 320
     $template_result['.']['gender_list'][] = array(
321 321
       'VALUE'    => $key,
322 322
       'NAME'     => $value,
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
   }
326 326
 
327 327
   $lang_list = lng_get_list();
328
-  foreach($lang_list as $lang_id => $lang_data) {
328
+  foreach ($lang_list as $lang_id => $lang_data) {
329 329
     $template_result['.']['languages'][] = array(
330 330
       'VALUE'    => $lang_id,
331 331
       'NAME'     => $lang_data['LANG_NAME_NATIVE'],
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
   }
335 335
 
336 336
 
337
-  if(isset(classLocale::$lang['menu_customize_show_hide_button_state'])) {
338
-    foreach(classLocale::$lang['menu_customize_show_hide_button_state'] as $key => $value) {
337
+  if (isset(classLocale::$lang['menu_customize_show_hide_button_state'])) {
338
+    foreach (classLocale::$lang['menu_customize_show_hide_button_state'] as $key => $value) {
339 339
       $template->assign_block_vars('menu_customize_show_hide_button_state', array(
340 340
         'ID'   => $key,
341 341
         'NAME' => $value,
@@ -442,10 +442,10 @@  discard block
 block discarded – undo
442 442
     'PAGE_HEADER' => classLocale::$lang['opt_header'],
443 443
   ));
444 444
 
445
-  foreach($user_option_list as $option_group_id => $option_group) {
446
-    if($option_group_id == OPT_MESSAGE) {
447
-      foreach(DBStaticMessages::$snMessageClassList as $message_class_id => $message_class_data) {
448
-        if($message_class_data['switchable'] || ($message_class_data['email'] && classSupernova::$config->game_email_pm)) {
445
+  foreach ($user_option_list as $option_group_id => $option_group) {
446
+    if ($option_group_id == OPT_MESSAGE) {
447
+      foreach (DBStaticMessages::$snMessageClassList as $message_class_id => $message_class_data) {
448
+        if ($message_class_data['switchable'] || ($message_class_data['email'] && classSupernova::$config->game_email_pm)) {
449 449
           $option_name = $message_class_data['name'];
450 450
 
451 451
           $template->assign_block_vars("options_{$option_group_id}", array(
@@ -457,8 +457,8 @@  discard block
 block discarded – undo
457 457
         }
458 458
       }
459 459
     } else {
460
-      foreach($option_group as $option_name => $option_value) {
461
-        if(array_key_exists($option_name, $user_option_types)) {
460
+      foreach ($option_group as $option_name => $option_value) {
461
+        if (array_key_exists($option_name, $user_option_types)) {
462 462
           $option_type = $user_option_types[$option_name];
463 463
         } else {
464 464
           $option_type = 'switch';
Please login to merge, or discard this patch.
includes/includes/market_fleeter.inc 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -2,11 +2,11 @@  discard block
 block discarded – undo
2 2
 
3 3
 $classLocale = classLocale::$lang;
4 4
 
5
-if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) {
5
+if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) {
6 6
   classSupernova::$debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403);
7 7
 }
8 8
 
9
-$page_title .= ' - ' . classLocale::$lang["eco_mrk_{$submode}"];
9
+$page_title .= ' - '.classLocale::$lang["eco_mrk_{$submode}"];
10 10
 
11 11
 $template = gettemplate('market_fleet', true);
12 12
 $template->assign_vars(array(
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
   'rpg_cost' => $rpg_cost,
15 15
 ));
16 16
 
17
-if(is_array($shipList)) {
18
-  if(mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) {
17
+if (is_array($shipList)) {
18
+  if (mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) {
19 19
     $intError = MARKET_NO_DM;
20 20
   }
21 21
 
@@ -28,32 +28,32 @@  discard block
 block discarded – undo
28 28
   // Блокируем запись о запасах кораблей у трейдера
29 29
   db_config_get_stockman_fleet();
30 30
 
31
-  $message .= classLocale::$lang["eco_mrk_{$submode}_ships"] . '<ul>';
31
+  $message .= classLocale::$lang["eco_mrk_{$submode}_ships"].'<ul>';
32 32
   $total = array();
33
-  foreach($shipList as $shipID => &$shipCount) {
33
+  foreach ($shipList as $shipID => &$shipCount) {
34 34
     $shipCount = ceil(floatval($shipCount));
35
-    if(!$shipCount) {
35
+    if (!$shipCount) {
36 36
       continue;
37 37
     }
38 38
 
39
-    if($shipCount < 0) {
39
+    if ($shipCount < 0) {
40 40
       classSupernova::$debug->warning('User supplied negative ship count on Black Market page', 'Hack Attempt', 307);
41 41
       $intError = MARKET_NEGATIVE_SHIPS;
42 42
       break;
43 43
     }
44 44
 
45
-    if($mode == MARKET_SCRAPPER) {
45
+    if ($mode == MARKET_SCRAPPER) {
46 46
       $amount = mrc_get_level($user, $planetrow, $shipID, true, true); // $planetrow[get_unit_param($shipID, P_NAME)];
47
-    } elseif($mode == MARKET_STOCKMAN) {
47
+    } elseif ($mode == MARKET_STOCKMAN) {
48 48
       $amount = $stock[$shipID];
49 49
     }
50 50
 
51
-    if($amount < $shipCount) {
51
+    if ($amount < $shipCount) {
52 52
       $intError = $error_no_stock;
53 53
       break;
54 54
     }
55 55
 
56
-    if(!in_array($shipID, Fleet::$snGroupFleet)) {
56
+    if (!in_array($shipID, Fleet::$snGroupFleet)) {
57 57
       classSupernova::$debug->warning('Hack Attempt', 'User supplied non-ship unit ID on Black Market page', 306);
58 58
       $intError = MARKET_NOT_A_SHIP;
59 59
       break;
@@ -69,16 +69,16 @@  discard block
 block discarded – undo
69 69
     $resTemp[RES_CRYSTAL] = floor($build_data[BUILD_CREATE][RES_CRYSTAL] * $shipCount * $config_rpg_scrape_crystal * (-$multiplier));
70 70
     $resTemp[RES_DEUTERIUM] = floor($build_data[BUILD_CREATE][RES_DEUTERIUM] * $shipCount * $config_rpg_scrape_deuterium * (-$multiplier));
71 71
 
72
-    foreach($resTemp as $resID => $resCount) {
72
+    foreach ($resTemp as $resID => $resCount) {
73 73
       $total[$resID] += $resCount;
74 74
     }
75 75
 
76
-    $message .= "<li>{$classLocale['tech'][$shipID]}: " . pretty_number($shipCount);
76
+    $message .= "<li>{$classLocale['tech'][$shipID]}: ".pretty_number($shipCount);
77 77
   }
78 78
 
79
-  if($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) {
80
-    foreach($total as $resID => $resCount) {
81
-      if(mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) {
79
+  if ($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) {
80
+    foreach ($total as $resID => $resCount) {
81
+      if (mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) {
82 82
         $intError = MARKET_NO_RESOURCES;
83 83
         classSupernova::$debug->warning('Trying to use bug in s/h market', 'S/H Ship Market', 301);
84 84
         break;
@@ -89,15 +89,15 @@  discard block
 block discarded – undo
89 89
   $intError = ($intError == MARKET_DEAL) && (array_sum($total) == 0) ? $error_zero_res : $intError;
90 90
 
91 91
   $qry = array();
92
-  if($intError == MARKET_DEAL) {
93
-    $message .= '</ul>' . classLocale::$lang["eco_mrk_{$submode}_res"] . '<ul>';
94
-    foreach($total as $resID => $resCount) {
95
-      if(!$resCount) {
92
+  if ($intError == MARKET_DEAL) {
93
+    $message .= '</ul>'.classLocale::$lang["eco_mrk_{$submode}_res"].'<ul>';
94
+    foreach ($total as $resID => $resCount) {
95
+      if (!$resCount) {
96 96
         continue;
97 97
       }
98 98
 
99 99
       $qry[pname_resource_name($resID)] = $resCount;
100
-      $message .= "<li>" . classLocale::$lang['sys_' . pname_resource_name($resID)] . ": " . pretty_number(abs($resCount));
100
+      $message .= "<li>".classLocale::$lang['sys_'.pname_resource_name($resID)].": ".pretty_number(abs($resCount));
101 101
     }
102 102
     $message .= "</ul>";
103 103
 
@@ -125,38 +125,38 @@  discard block
 block discarded – undo
125 125
       'MESSAGE' => classLocale::$lang['eco_mrk_errors'][$intError],
126 126
     ));
127 127
 
128
-    foreach($shipList as $shipID => $shipCount) {
128
+    foreach ($shipList as $shipID => $shipCount) {
129 129
       $data['ships'][$shipID] = max(0, intval($shipCount));
130 130
     }
131 131
   }
132 132
 }
133 133
 $message = '';
134 134
 
135
-if(!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) {
136
-  classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item){return mt_rand(1, 1000);}, Fleet::$snGroupFleet)));
135
+if (!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) {
136
+  classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item) {return mt_rand(1, 1000); }, Fleet::$snGroupFleet)));
137 137
 }
138 138
 
139 139
 tpl_set_resource_info($template, $planetrow, array());
140 140
 
141
-if(!$array) {
141
+if (!$array) {
142 142
   $array = array();
143 143
 }
144 144
 
145 145
 $group_fleet = Fleet::$snGroupFleet;
146
-foreach($array as $key => $value) {
147
-  if($mode == MARKET_SCRAPPER) {
146
+foreach ($array as $key => $value) {
147
+  if ($mode == MARKET_SCRAPPER) {
148 148
     $shipID = $value;
149 149
     $amount = mrc_get_level($user, $planetrow, $shipID, false, true); // $planetrow[get_unit_param($shipID, P_NAME)];
150
-  } elseif($mode == MARKET_STOCKMAN) {
150
+  } elseif ($mode == MARKET_STOCKMAN) {
151 151
     $shipID = $key;
152 152
     $amount = $value;
153 153
   }
154 154
 
155
-  if(!in_array($shipID, $group_fleet)) {
155
+  if (!in_array($shipID, $group_fleet)) {
156 156
     continue;
157 157
   }
158 158
 
159
-  if($amount > 0) {
159
+  if ($amount > 0) {
160 160
     $build_data = eco_get_build_data($user, $planetrow, $shipID);
161 161
     $template->assign_block_vars('ships', array(
162 162
       'ID'        => $shipID,
Please login to merge, or discard this patch.
includes/classes/db_mysql.php 2 patches
Doc Comments   +31 added lines, -5 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
   /**
158 158
    * @param string $query
159 159
    *
160
-   * @return mixed|string
160
+   * @return string
161 161
    */
162 162
   public function replaceTablePlaceholders($query) {
163 163
     $sql = $query;
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
   }
172 172
 
173 173
   /**
174
-   * @param $query
174
+   * @param string $query
175 175
    */
176 176
   protected function logQuery($query) {
177 177
     if (!classSupernova::$config->debug) {
@@ -286,6 +286,7 @@  discard block
 block discarded – undo
286 286
    * @param array  $fields
287 287
    * @param array  $where
288 288
    * @param bool   $isOneRecord
289
+   * @param boolean $forUpdate
289 290
    *
290 291
    * @return array|bool|mysqli_result|null
291 292
    */
@@ -332,6 +333,11 @@  discard block
 block discarded – undo
332 333
 
333 334
 
334 335
   // INSERT/REPLACE
336
+
337
+  /**
338
+   * @param string $table
339
+   * @param integer $replace
340
+   */
335 341
   protected function doSet($table, $fieldsAndValues, $replace = DB_INSERT_PLAIN) {
336 342
     $query = DbQuery::build($this)
337 343
       ->setTable($table)
@@ -369,6 +375,10 @@  discard block
 block discarded – undo
369 375
 
370 376
 
371 377
   // INSERTERS
378
+
379
+  /**
380
+   * @param string $query
381
+   */
372 382
   public function doInsertComplex($query) {
373 383
     return $this->doSql($query);
374 384
   }
@@ -386,7 +396,7 @@  discard block
 block discarded – undo
386 396
    * Values should be passed as-is
387 397
    *
388 398
    * @param string   $table
389
-   * @param array    $fields
399
+   * @param string[]    $fields
390 400
    * @param string[] $values
391 401
    *
392 402
    * @return array|bool|mysqli_result|null
@@ -438,7 +448,7 @@  discard block
 block discarded – undo
438 448
    * Self-contained - means no params used
439 449
    * Such queries usually used to make large amount of in-base calculations
440 450
    *
441
-   * @param $query
451
+   * @param string $query
442 452
    *
443 453
    * @return array|bool|mysqli_result|null
444 454
    */
@@ -456,13 +466,16 @@  discard block
 block discarded – undo
456 466
   }
457 467
 
458 468
   /**
459
-   * @param $DbQuery DbQuery
469
+   * @param DbQuery $DbQuery DbQuery
460 470
    */
461 471
   public function doUpdateDbQueryAdjust($DbQuery) {
462 472
     return $this->doUpdateDbQuery($DbQuery);
463 473
   }
464 474
 
465 475
 
476
+  /**
477
+   * @param boolean $isOneRecord
478
+   */
466 479
   protected function doUpdateWhere($table, $fieldsSet, $fieldsAdjust = array(), $where = array(), $isOneRecord = DB_RECORDS_ALL, $whereDanger = array()) {
467 480
 //    $query = DbQuery::build($this)
468 481
 //      ->setTable($table)
@@ -498,10 +511,16 @@  discard block
 block discarded – undo
498 511
     return $this->doSql($query);
499 512
   }
500 513
 
514
+  /**
515
+   * @param string $table
516
+   */
501 517
   public function doUpdateRowSet($table, $fieldsAndValues, $where) {
502 518
     return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORD_ONE);
503 519
   }
504 520
 
521
+  /**
522
+   * @param string $table
523
+   */
505 524
   public function doUpdateTableSet($table, $fieldsAndValues, $where = array()) {
506 525
     return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORDS_ALL);
507 526
   }
@@ -708,6 +727,10 @@  discard block
 block discarded – undo
708 727
   }
709 728
 
710 729
   // TODO Заменить это на новый логгер
730
+
731
+  /**
732
+   * @param string $query
733
+   */
711 734
   protected function security_watch_user_queries($query) {
712 735
     global $user;
713 736
 
@@ -731,6 +754,9 @@  discard block
 block discarded – undo
731 754
   }
732 755
 
733 756
 
757
+  /**
758
+   * @param string $query
759
+   */
734 760
   public function security_query_check_bad_words($query) {
735 761
     if ($this->skipQueryCheck) {
736 762
       return;
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
   public function load_db_settings($configFile = '') {
92 92
     $dbsettings = array();
93 93
 
94
-    empty($configFile) ? $configFile = SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX : false;
94
+    empty($configFile) ? $configFile = SN_ROOT_PHYSICAL."config".DOT_PHP_EX : false;
95 95
 
96 96
     require $configFile;
97 97
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     }
112 112
 
113 113
     if (empty($this->dbsettings)) {
114
-      $this->load_db_settings(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX);
114
+      $this->load_db_settings(SN_ROOT_PHYSICAL."config".DOT_PHP_EX);
115 115
     }
116 116
 
117 117
     // TODO - фатальные (?) ошибки на каждом шагу. Хотя - скорее Эксепшны
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
     $sql = $query;
164 164
     if (strpos($sql, '{{') !== false) {
165 165
       foreach ($this->table_list as $tableName) {
166
-        $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql);
166
+        $sql = str_replace("{{{$tableName}}}", $this->db_prefix.$tableName, $sql);
167 167
       }
168 168
     }
169 169
 
@@ -234,12 +234,12 @@  discard block
 block discarded – undo
234 234
 
235 235
     $queryResult = null;
236 236
     try {
237
-      $queryResult = $this->db_sql_query($stringQuery . DbSqlHelper::quoteComment($queryTrace));
237
+      $queryResult = $this->db_sql_query($stringQuery.DbSqlHelper::quoteComment($queryTrace));
238 238
       if (!$queryResult) {
239 239
         throw new Exception();
240 240
       }
241 241
     } catch (Exception $e) {
242
-      classSupernova::$debug->error($this->db_error() . "<br />{$query}<br />", 'SQL Error');
242
+      classSupernova::$debug->error($this->db_error()."<br />{$query}<br />", 'SQL Error');
243 243
     }
244 244
 
245 245
     return $queryResult;
@@ -291,19 +291,19 @@  discard block
 block discarded – undo
291 291
    */
292 292
   public function doSelectDanger($table, $fields, $where = array(), $isOneRecord = DB_RECORDS_ALL, $forUpdate = DB_SELECT_PLAIN) {
293 293
     // TODO - TEMPORARY UNTIL DbQuery
294
-    if(!empty($where)) {
294
+    if (!empty($where)) {
295 295
       foreach ($where as $key => &$value) {
296
-        if(!is_int($key)) {
297
-          $value = "`$key` = '" . $this->db_escape($value). "'";
296
+        if (!is_int($key)) {
297
+          $value = "`$key` = '".$this->db_escape($value)."'";
298 298
         }
299 299
       }
300 300
     }
301 301
 
302 302
     $query =
303
-      "SELECT " . implode(',', $fields) .
304
-      " FROM `{{{$table}}}`" .
305
-      (!empty($where) ? ' WHERE ' . implode(' AND ', $where) : '') .
306
-      ($isOneRecord == DB_RECORD_ONE ? ' LIMIT 1' : '') .
303
+      "SELECT ".implode(',', $fields).
304
+      " FROM `{{{$table}}}`".
305
+      (!empty($where) ? ' WHERE '.implode(' AND ', $where) : '').
306
+      ($isOneRecord == DB_RECORD_ONE ? ' LIMIT 1' : '').
307 307
       ($forUpdate == DB_SELECT_FOR_UPDATE ? ' FOR UPDATE' : '')
308 308
     ;
309 309
 
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
       case TYPE_EMPTY:
607 607
         // No-type defaults to string
608 608
       default:
609
-        $value = "'" . $this->db_escape((string)$value) . "'";
609
+        $value = "'".$this->db_escape((string) $value)."'";
610 610
       break;
611 611
     }
612 612
 
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
       if (is_int($fieldName)) {
635 635
         $result[$fieldName] = $fieldValue;
636 636
       } else {
637
-        $result[$fieldName] = "`{$fieldName}` = " . $this->castAsDbValue($fieldValue);
637
+        $result[$fieldName] = "`{$fieldName}` = ".$this->castAsDbValue($fieldValue);
638 638
       }
639 639
     }
640 640
 
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
       if (is_int($fieldName)) {
664 664
         $result[$fieldName] = $fieldValue;
665 665
       } else {
666
-        $result[$fieldName] = "`{$fieldName}` = `{$fieldName}` + (" . $this->castAsDbValue($fieldValue) . ")";
666
+        $result[$fieldName] = "`{$fieldName}` = `{$fieldName}` + (".$this->castAsDbValue($fieldValue).")";
667 667
       }
668 668
     }
669 669
 
@@ -720,10 +720,10 @@  discard block
 block discarded – undo
720 720
       $this->isWatching = true;
721 721
       $msg = "\$query = \"{$query}\"\n\r";
722 722
       if (!empty($_POST)) {
723
-        $msg .= "\n\r" . dump($_POST, '$_POST');
723
+        $msg .= "\n\r".dump($_POST, '$_POST');
724 724
       }
725 725
       if (!empty($_GET)) {
726
-        $msg .= "\n\r" . dump($_GET, '$_GET');
726
+        $msg .= "\n\r".dump($_GET, '$_GET');
727 727
       }
728 728
       classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true));
729 729
       $this->isWatching = false;
@@ -749,37 +749,37 @@  discard block
 block discarded – undo
749 749
       case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit:
750 750
       case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit:
751 751
       case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0:
752
-        $report = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n";
752
+        $report = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n";
753 753
         $report .= ">Database Inforamation\n";
754
-        $report .= "\tID - " . $user['id'] . "\n";
755
-        $report .= "\tUser - " . $user['username'] . "\n";
756
-        $report .= "\tAuth level - " . $user['authlevel'] . "\n";
757
-        $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n";
758
-        $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n";
759
-        $report .= "\tUser IP - " . $user['user_lastip'] . "\n";
760
-        $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n";
761
-        $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n";
762
-        $report .= "\tCurrent Page - " . $user['current_page'] . "\n";
763
-        $report .= "\tRegister Time - " . $user['register_time'] . "\n";
754
+        $report .= "\tID - ".$user['id']."\n";
755
+        $report .= "\tUser - ".$user['username']."\n";
756
+        $report .= "\tAuth level - ".$user['authlevel']."\n";
757
+        $report .= "\tAdmin Notes - ".$user['adminNotes']."\n";
758
+        $report .= "\tCurrent Planet - ".$user['current_planet']."\n";
759
+        $report .= "\tUser IP - ".$user['user_lastip']."\n";
760
+        $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n";
761
+        $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n";
762
+        $report .= "\tCurrent Page - ".$user['current_page']."\n";
763
+        $report .= "\tRegister Time - ".$user['register_time']."\n";
764 764
         $report .= "\n";
765 765
 
766 766
         $report .= ">Query Information\n";
767
-        $report .= "\tQuery - " . $query . "\n";
767
+        $report .= "\tQuery - ".$query."\n";
768 768
         $report .= "\n";
769 769
 
770 770
         $report .= ">\$_SERVER Information\n";
771
-        $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n";
772
-        $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n";
773
-        $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n";
774
-        $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n";
775
-        $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n";
776
-        $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n";
777
-        $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n";
778
-        $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n";
771
+        $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n";
772
+        $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n";
773
+        $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n";
774
+        $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n";
775
+        $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n";
776
+        $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n";
777
+        $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n";
778
+        $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n";
779 779
 
780 780
         $report .= "\n--------------------------------------------------------------------------------------------------\n";
781 781
 
782
-        $fp = fopen(SN_ROOT_PHYSICAL . 'badqrys.txt', 'a');
782
+        $fp = fopen(SN_ROOT_PHYSICAL.'badqrys.txt', 'a');
783 783
         fwrite($fp, $report);
784 784
         fclose($fp);
785 785
 
Please login to merge, or discard this patch.
includes/classes/DBAL/DbQuery.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
    * @return string
312 312
    */
313 313
   protected function stringValue($value) {
314
-    return "'" . $this->escape((string)$value) . "'";
314
+    return "'".$this->escape((string) $value)."'";
315 315
   }
316 316
 
317 317
   /**
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
    * @return string
323 323
    */
324 324
   protected function quote($fieldName) {
325
-    return "`" . $this->escape((string)$fieldName) . "`";
325
+    return "`".$this->escape((string) $fieldName)."`";
326 326
   }
327 327
 
328 328
   /**
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
    * @return string
334 334
    */
335 335
   protected function quoteTable($tableName) {
336
-    return "`{{" . $this->escape((string)$tableName) . "}}`";
336
+    return "`{{".$this->escape((string) $tableName)."}}`";
337 337
   }
338 338
 
339 339
   protected function castAsDbValue($value) {
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
     foreach ($fieldValues as $fieldName => $fieldValue) {
415 415
       // Integer $fieldName is DANGER! They skipped there!
416 416
       if (!is_int($fieldName)) {
417
-        $result[$fieldName] = $this->quote($fieldName) . " = " . $this->castAsDbValue($fieldValue);
417
+        $result[$fieldName] = $this->quote($fieldName)." = ".$this->castAsDbValue($fieldValue);
418 418
       }
419 419
     }
420 420
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
     foreach ($fields as $fieldName => $fieldValue) {
471 471
       // Integer $fieldName means "leave as is" - for expressions and already processed fields
472 472
       if (is_string($fieldName)) {
473
-        $result[$fieldName] = "`{$fieldName}` = `{$fieldName}` + (" . $this->castAsDbValue($fieldValue) . ")";
473
+        $result[$fieldName] = "`{$fieldName}` = `{$fieldName}` + (".$this->castAsDbValue($fieldValue).")";
474 474
       }
475 475
     }
476 476
 
@@ -481,21 +481,21 @@  discard block
 block discarded – undo
481 481
   protected function buildCommand() {
482 482
     switch ($this->command) {
483 483
       case static::UPDATE:
484
-        $this->build[] = $this->command . " " . $this->quoteTable($this->table);
484
+        $this->build[] = $this->command." ".$this->quoteTable($this->table);
485 485
       break;
486 486
 
487 487
       case static::DELETE:
488
-        $this->build[] = $this->command . " FROM " . $this->quoteTable($this->table);
488
+        $this->build[] = $this->command." FROM ".$this->quoteTable($this->table);
489 489
       break;
490 490
 
491 491
       case static::REPLACE:
492 492
       case static::INSERT_IGNORE:
493 493
       case static::INSERT:
494
-        $this->build[] = $this->command . " INTO " . $this->quoteTable($this->table);
494
+        $this->build[] = $this->command." INTO ".$this->quoteTable($this->table);
495 495
       break;
496 496
 
497 497
       case static::SELECT:
498
-        $this->build[] = $this->command . " ";
498
+        $this->build[] = $this->command." ";
499 499
       break;
500 500
     }
501 501
   }
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
     $compiled = array();
548 548
 
549 549
     foreach ($this->values as $valuesVector) {
550
-      $compiled[] = '(' . implode(',', $this->safeValuesScalar($valuesVector)) . ')';
550
+      $compiled[] = '('.implode(',', $this->safeValuesScalar($valuesVector)).')';
551 551
     }
552 552
 
553 553
     $this->build[] = implode(',', $compiled);
Please login to merge, or discard this patch.