Completed
Push — work-fleets ( 45d3a1...6724fd )
by SuperNova.WS
09:14 queued 03:18
created
includes/classes/DBStaticMessages.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         sys_user_options_unpack($owner_row);
114 114
 
115 115
         if ($force || !$message_class['switchable'] || $owner_row["opt_{$message_class_name}"]) {
116
-          $insert_values[] = "('" . idval($owner) . "', '{$sender}', '{$timestamp}', '{$message_type}', '" . db_escape($from_unsafe) . "', '" . db_escape($subject_unsafe) . "', '" . db_escape($text_unsafe) . "')";
116
+          $insert_values[] = "('".idval($owner)."', '{$sender}', '{$timestamp}', '{$message_type}', '".db_escape($from_unsafe)."', '".db_escape($subject_unsafe)."', '".db_escape($text_unsafe)."')";
117 117
         }
118 118
 
119 119
         // TODO - allow sending HTML email only from admin
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         array(),
154 154
         array(
155 155
           // TODO DANGER
156
-          '`id` IN (' . implode(',', $owners) . ')',
156
+          '`id` IN ('.implode(',', $owners).')',
157 157
         )
158 158
       );
159 159
     }
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     $sendList = array();
173 173
     $list = '';
174 174
     $query = DBStaticUser::db_user_list(
175
-      "ally_id = '{$ally_id}'" . ($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''),
175
+      "ally_id = '{$ally_id}'".($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''),
176 176
       false, 'id, username');
177 177
     foreach ($query as $u) {
178 178
       $sendList[] = $u['id'];
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
       $subject_unsafe = substr($subject_unsafe, strlen(classLocale::$lang['msg_answer_prefix']));
262 262
       $re++;
263 263
     }
264
-    $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'] . $subject_unsafe : false;
264
+    $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'].$subject_unsafe : false;
265 265
 
266 266
     $subject_unsafe = $subject_unsafe ? $subject_unsafe : classLocale::$lang['msg_subject_default'];
267 267
 
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
     return classSupernova::$db->doSelect(
438 438
       "SELECT * FROM {{messages}}
439 439
         WHERE
440
-          `message_type` = '" . MSG_TYPE_PLAYER . "' AND
440
+          `message_type` = '" . MSG_TYPE_PLAYER."' AND
441 441
           ((`message_owner` = '{$user['id']}' AND `message_sender` = '{$recipient_id}')
442 442
           OR
443 443
           (`message_sender` = '{$user['id']}' AND `message_owner` = '{$recipient_id}')) ORDER BY `message_time` DESC LIMIT 20;");
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 FROM
482 482
   {{messages}} AS m
483 483
   LEFT JOIN {{users}} AS u ON u.id = m.message_owner " .
484
-      ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : '') .
484
+      ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : '').
485 485
       "ORDER BY
486 486
   `message_id` DESC
487 487
 LIMIT
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
     $subject_safe = db_escape($subject_unsafe);
495 495
     $text_safe = db_escape($text_unsafe);
496 496
 
497
-    return classSupernova::$db->doInsertComplex('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' .
497
+    return classSupernova::$db->doInsertComplex('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) '.
498 498
       "SELECT `id`, 0, unix_timestamp(now()), {$message_type_safe}, '{$from_safe}', '{$subject_safe}', '{$text_safe}' FROM {{users}}");
499 499
   }
500 500
 
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
    * @return array|bool|mysqli_result|null
505 505
    */
506 506
   public static function db_message_count_by_type($int_type_selected) {
507
-    $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM `{{messages}}`' . ($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : ''));
507
+    $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM `{{messages}}`'.($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : ''));
508 508
 
509 509
     return $page_max;
510 510
   }
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
    */
540 540
   public static function db_message_list_delete_by_date($delete_date, $int_type_selected) {
541 541
     $where = array();
542
-    if($int_type_selected >= 0) {
542
+    if ($int_type_selected >= 0) {
543 543
       $where['message_type'] = $int_type_selected;
544 544
     }
545 545
     classSupernova::$db->doDeleteDanger(
Please login to merge, or discard this patch.
includes/classes/core_auth.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
       // Проверить наличие такого имени в истории имён
223 223
       do {
224 224
         sn_db_transaction_rollback();
225
-        $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000);
225
+        $this->player_suggested_name = 'Emperor '.mt_rand($max_user_id + 1, $max_user_id + 1000);
226 226
         sn_db_transaction_start();
227 227
       } while (db_player_name_exists($this->player_suggested_name));
228 228
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
     if ($player_name_submitted) {
232 232
       $this->register_player_db_create($this->player_suggested_name); // OK 4.5
233 233
       if ($this->register_status == LOGIN_SUCCESS) {
234
-        sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
234
+        sys_redirect(SN_ROOT_VIRTUAL.'overview.php');
235 235
       } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) {
236 236
         // self::$player_suggested_name .= ' ' . $this->account->account_id;
237 237
       }
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
       );
258 258
 
259 259
     if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
260
-      $prohibited_characters = array_map(function ($value) {
261
-        return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
260
+      $prohibited_characters = array_map(function($value) {
261
+        return "'".htmlentities($value, ENT_QUOTES, 'UTF-8')."'";
262 262
       }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
263 263
       $template_result[F_PLAYER_REGISTER_MESSAGE] .= implode(', ', $prohibited_characters);
264 264
     }
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 
306 306
     foreach ($this->providers as $provider_id => $provider) {
307 307
       $login_status = $provider->login(); // OK v4.5
308
-      self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider)));
308
+      self::flog(($provider->manifest['name'].'->'.'login_try - ').(empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider)));
309 309
       if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) {
310 310
         $this->providers_authorised[$provider_id] = &$this->providers[$provider_id];
311 311
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
         if (!$this->is_player_register) {
346 346
           // Нет - отправляем на процесс регистрации
347 347
           $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id'));
348
-          sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : ''));
348
+          sys_redirect(SN_ROOT_VIRTUAL.'index.php?page=player_register&player_register=1'.($partner_id ? '&id_ref='.$partner_id : ''));
349 349
         }
350 350
       } else {
351 351
         // Да, есть доступные игроки, которые так же прописаны в базе
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
     }
406 406
 
407 407
     if ($redirect === true) {
408
-      sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php'));
408
+      sys_redirect(SN_ROOT_RELATIVE.(empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php'));
409 409
     } elseif ($redirect !== false) {
410 410
       sys_redirect($redirect);
411 411
     }
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
    */
802 802
   // OK v4
803 803
   public static function password_encode($password, $salt) {
804
-    return md5($password . $salt);
804
+    return md5($password.$salt);
805 805
   }
806 806
   /**
807 807
    * Генерирует соль
@@ -827,10 +827,10 @@  discard block
 block discarded – undo
827 827
     }
828 828
     list($called, $caller) = debug_backtrace(false);
829 829
     $caller_name =
830
-      (!empty($caller['class']) ? $caller['class'] : '') .
831
-      (!empty($caller['type']) ? $caller['type'] : '') .
832
-      (!empty($caller['function']) ? $caller['function'] : '') .
833
-      (!empty($called['line']) ? ':' . $called['line'] : '');
830
+      (!empty($caller['class']) ? $caller['class'] : '').
831
+      (!empty($caller['type']) ? $caller['type'] : '').
832
+      (!empty($caller['function']) ? $caller['function'] : '').
833
+      (!empty($called['line']) ? ':'.$called['line'] : '');
834 834
 
835 835
     $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false;
836 836
 
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
     if ($die) {
839 839
       // pdump($caller);
840 840
       // pdump(debug_backtrace(false));
841
-      $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>");
841
+      $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в ".get_called_class()." (располагается в ".get_class()."). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>");
842 842
     }
843 843
   }
844 844
 
Please login to merge, or discard this patch.
includes/classes/DBStaticUser.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
         ->where('`user_as_ally` IS NULL')
24 24
         ->orderBy(array('`id` DESC'));
25 25
 
26
-    return (string)$query->selectValue();
26
+    return (string) $query->selectValue();
27 27
   }
28 28
 
29 29
   /**
@@ -48,15 +48,15 @@  discard block
 block discarded – undo
48 48
       static::buildDBQ()
49 49
         ->field('id')
50 50
         ->where("`user_as_ally` IS NULL")
51
-        ->where("`user_bot` = " . USER_BOT_PLAYER)
51
+        ->where("`user_bot` = ".USER_BOT_PLAYER)
52 52
         ->setForUpdate();
53 53
 
54 54
     return $query->selectIterator();
55 55
   }
56 56
 
57 57
   public static function db_user_lock_with_target_owner_and_acs($user, $planet = array()) {
58
-    $query = "SELECT 1 FROM `{{users}}` WHERE `id` = " . idval($user['id']) .
59
-      (!empty($planet['id_owner']) ? ' OR `id` = ' . idval($planet['id_owner']) : '')
58
+    $query = "SELECT 1 FROM `{{users}}` WHERE `id` = ".idval($user['id']).
59
+      (!empty($planet['id_owner']) ? ' OR `id` = '.idval($planet['id_owner']) : '')
60 60
       . " FOR UPDATE";
61 61
 
62 62
     static::getDb()->doSelect($query);
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
       FROM `{{users}}` 
74 74
       WHERE 
75 75
         `user_as_ally` IS NULL" .
76
-        ($online ? ' AND `onlinetime` > ' . (SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '')
76
+        ($online ? ' AND `onlinetime` > '.(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '')
77 77
     ));
78 78
   }
79 79
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
       ->fieldCount('r.id', 'referral_count')
96 96
       ->fieldSingleFunction('sum', 'r.dark_matter', 'referral_dm')
97 97
       ->join('LEFT JOIN {{referrals}} as r on r.id_partner = u.id')
98
-      ->where($online ? "`onlinetime` >= " . intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL')
98
+      ->where($online ? "`onlinetime` >= ".intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL')
99 99
       ->groupBy('u.id')
100 100
       ->orderBy("user_as_ally, {$sort} ASC");
101 101
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
       ->where('(`user_birthday_celebrated` IS NULL OR DATE_ADD(`user_birthday_celebrated`, INTERVAL 1 YEAR) < CURRENT_DATE)')
114 114
       ->where('`user_as_ally` IS NULL')
115 115
       ->having('`days_after_birthday` >= 0')
116
-      ->having('`days_after_birthday` < ' . intval($config_user_birthday_range))
116
+      ->having('`days_after_birthday` < '.intval($config_user_birthday_range))
117 117
       ->setForUpdate();
118 118
 
119 119
     $result = $query->selectIterator();
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
       $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет
223 223
 
224 224
       $user = classSupernova::$db->doSelectFetch(
225
-        "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'"
225
+        "SELECT * FROM {{users}} WHERE `username` ".($like ? 'LIKE' : '=')." '{$username_safe}'"
226 226
         . " FOR UPDATE"
227 227
       );
228 228
       classSupernova::$gc->snCache->cache_set(LOC_USER, $user); // В кэш-юзер так же заполнять индексы
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
    * @param array $playerArray
314 314
    */
315 315
   public static function renderNameAndCoordinates($playerArray) {
316
-    return "{$playerArray['username']} " . uni_render_coordinates($playerArray);
316
+    return "{$playerArray['username']} ".uni_render_coordinates($playerArray);
317 317
   }
318 318
 
319 319
   /**
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
     foreach ($playerRowFieldChanges as $resourceId => $value) {
348 348
       $fields[pname_resource_name($resourceId)] = $value;
349 349
     }
350
-    if(!empty($fields)) {
350
+    if (!empty($fields)) {
351 351
       classSupernova::$gc->db->doUpdateRowAdjust(
352 352
         TABLE_USERS,
353 353
         array(),
Please login to merge, or discard this patch.
includes/functions/sys_user.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use Vector\Vector;
8 8
 
9 9
 function sys_user_vacation($user) {
10
-  if(sys_get_param_str('vacation') == 'leave') {
10
+  if (sys_get_param_str('vacation') == 'leave') {
11 11
     if ($user['vacation'] < SN_TIME_NOW) {
12 12
       $user['vacation'] = 0;
13 13
       $user['vacation_next'] = SN_TIME_NOW + classSupernova::$config->player_vacation_timeout;
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     }
22 22
   }
23 23
 
24
-  if($user['vacation']) {
24
+  if ($user['vacation']) {
25 25
     // sn_sys_logout(false, true);
26 26
     // core_auth::logout(false, true);
27 27
 
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
   // TODO: Full rewrite
52 52
   sn_db_transaction_start();
53 53
   $TheUser = DBStaticUser::db_user_by_id($UserID);
54
-  if ( $TheUser['ally_id'] != 0 ) {
55
-    $TheAlly = classSupernova::$db->doSelectFetch("SELECT * FROM `{{alliance}}` WHERE `id` = '" . $TheUser['ally_id'] . "';");
54
+  if ($TheUser['ally_id'] != 0) {
55
+    $TheAlly = classSupernova::$db->doSelectFetch("SELECT * FROM `{{alliance}}` WHERE `id` = '".$TheUser['ally_id']."';");
56 56
     $TheAlly['ally_members'] -= 1;
57
-    if ( $TheAlly['ally_members'] > 0 ) {
57
+    if ($TheAlly['ally_members'] > 0) {
58 58
       classSupernova::$db->doUpdateRowSet(
59 59
         TABLE_ALLIANCE,
60 60
         array(
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
 
76 76
   classSupernova::$gc->db->doDeleteWhere(TABLE_MESSAGES, array('message_owner' => $UserID,));
77 77
   classSupernova::$gc->db->doDeleteWhere(TABLE_MESSAGES, array('message_sender' => $UserID,));
78
-  classSupernova::$gc->db->doDeleteWhere(TABLE_NOTES, array('owner' => $UserID ,));
78
+  classSupernova::$gc->db->doDeleteWhere(TABLE_NOTES, array('owner' => $UserID,));
79 79
   FleetList::db_fleet_list_delete_by_owner($UserID);
80
-  classSupernova::$gc->db->doDeleteWhere(TABLE_BUDDY, array('BUDDY_SENDER_ID' => $UserID ,));
81
-  classSupernova::$gc->db->doDeleteWhere(TABLE_BUDDY, array('BUDDY_OWNER_ID' => $UserID ,));
80
+  classSupernova::$gc->db->doDeleteWhere(TABLE_BUDDY, array('BUDDY_SENDER_ID' => $UserID,));
81
+  classSupernova::$gc->db->doDeleteWhere(TABLE_BUDDY, array('BUDDY_OWNER_ID' => $UserID,));
82 82
 
83 83
 
84 84
   classSupernova::$gc->cacheOperator->db_del_record_by_id(LOC_USER, $UserID);
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 
179 179
     'total_points' => $options['total_points'] = empty($options['total_points']) ? 0 : $options['total_points'],
180 180
 
181
-    'options' => (empty($options['options']) ? $player_options_string : $options['options']) . (empty($options['options_extra']) ? '' : $options['options_extra']),
181
+    'options' => (empty($options['options']) ? $player_options_string : $options['options']).(empty($options['options_extra']) ? '' : $options['options_extra']),
182 182
 
183 183
     'galaxy' => $options['galaxy'] = intval($options['galaxy'] ? $options['galaxy'] : 0),
184 184
     'system' => $options['system'] = intval($options['system'] ? $options['system'] : 0),
@@ -189,28 +189,28 @@  discard block
 block discarded – undo
189 189
   !empty($options['password_encoded_unsafe']) ? $field_set['password'] = $options['password_encoded_unsafe'] : false;
190 190
 
191 191
   $user_new = classSupernova::$gc->cacheOperator->db_ins_field_set(LOC_USER, $field_set);
192
-  if(!($options['galaxy'] && $options['system'] && $options['planet'])) {
192
+  if (!($options['galaxy'] && $options['system'] && $options['planet'])) {
193 193
     $options['galaxy'] = classSupernova::$config->LastSettedGalaxyPos;
194 194
     $options['system'] = classSupernova::$config->LastSettedSystemPos;
195
-    $segment_size = floor(Vector::$knownPlanets/ 3);
195
+    $segment_size = floor(Vector::$knownPlanets / 3);
196 196
     $segment = floor(classSupernova::$config->LastSettedPlanetPos / $segment_size);
197 197
     $segment++;
198 198
     $options['planet'] = mt_rand(1 + $segment * $segment_size, ($segment + 1) * $segment_size);
199 199
 
200 200
     // $new_planet_id = 0;
201
-    while(true) {
202
-      if($options['planet'] > Vector::$knownPlanets) {
201
+    while (true) {
202
+      if ($options['planet'] > Vector::$knownPlanets) {
203 203
         $options['planet'] = mt_rand(0, $segment_size - 1) + 1;
204 204
         $options['system']++;
205 205
       }
206
-      if($options['system'] > Vector::$knownSystems) {
206
+      if ($options['system'] > Vector::$knownSystems) {
207 207
         $options['system'] = 1;
208 208
         $options['galaxy']++;
209 209
       }
210
-      $options['galaxy'] > Vector::$knownGalaxies? $options['galaxy'] = 1 : false;
210
+      $options['galaxy'] > Vector::$knownGalaxies ? $options['galaxy'] = 1 : false;
211 211
 
212 212
       $galaxy_row = DBStaticPlanet::db_planet_by_gspt($options['galaxy'], $options['system'], $options['planet'], PT_PLANET, true, 'id');
213
-      if(!$galaxy_row['id']) {
213
+      if (!$galaxy_row['id']) {
214 214
         classSupernova::$config->db_saveItem(array(
215 215
           'LastSettedGalaxyPos' => $options['galaxy'],
216 216
           'LastSettedSystemPos' => $options['system'],
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 
239 239
   db_player_name_history_replace($user_new['id'], $username_unsafe);
240 240
 
241
-  if(!empty($options['partner_id']) && ($referral_row = DBStaticUser::db_user_by_id($options['partner_id'], true))) {
241
+  if (!empty($options['partner_id']) && ($referral_row = DBStaticUser::db_user_by_id($options['partner_id'], true))) {
242 242
     db_referral_insert($options['partner_id'], $user_new['id']);
243 243
   }
244 244
 
Please login to merge, or discard this patch.
includes/functions/rpg_points.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,16 +54,16 @@
 block discarded – undo
54 54
           $comment = call_user_func_array('sprintf', $comment);
55 55
         }
56 56
 //        mm_points_change($user_id, $change_type, -$metamatter_to_reduce, 'ММ в ТМ: ' . (-$dark_matter) . ' ТМ = ' . $dark_matter_exists . ' ТМ + ' . $metamatter_to_reduce . ' ММ. ' . $comment);
57
-        classSupernova::$auth->account->metamatter_change($change_type, -$metamatter_to_reduce, 'ММ в ТМ: ' . (-$dark_matter) . ' ТМ = ' . $dark_matter_exists . ' ТМ + ' . $metamatter_to_reduce . ' ММ. ' . $comment);
57
+        classSupernova::$auth->account->metamatter_change($change_type, -$metamatter_to_reduce, 'ММ в ТМ: '.(-$dark_matter).' ТМ = '.$dark_matter_exists.' ТМ + '.$metamatter_to_reduce.' ММ. '.$comment);
58 58
         $dark_matter = -$dark_matter_exists;
59 59
       }
60 60
     } else {
61 61
       $changeset['dark_matter_total'] = +$dark_matter;
62 62
     }
63
-    if($dark_matter) {
63
+    if ($dark_matter) {
64 64
       $changeset[$sn_data_dark_matter_db_name] = +$dark_matter;
65 65
     }
66
-    if(!empty($changeset)) {
66
+    if (!empty($changeset)) {
67 67
       DBStaticUser::db_user_adjust_by_id($user_id, $changeset);
68 68
     }
69 69
     $rows_affected = classSupernova::$db->db_affected_rows();
Please login to merge, or discard this patch.
includes/functions/uni_functions.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
 
10 10
   $possible_cores = array();
11 11
   $probability = 0;
12
-  foreach($density_list as $possible_core_id => $core_data) {
13
-    if(!$core_data[UNIT_PLANET_DENSITY_RARITY]) {
12
+  foreach ($density_list as $possible_core_id => $core_data) {
13
+    if (!$core_data[UNIT_PLANET_DENSITY_RARITY]) {
14 14
       continue;
15 15
     }
16 16
 
17
-    if(
17
+    if (
18 18
       // Core type exists
19 19
       in_array($possible_core_id, $position_data['core_types'])
20 20
       // Limit core type with planet sector count
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 
36 36
   $random = mt_rand(1, $probability);
37 37
   $selected_core = null;
38
-  foreach($possible_cores as $core_type => $core_info) {
39
-    if($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) {
38
+  foreach ($possible_cores as $core_type => $core_info) {
39
+    if ($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) {
40 40
       $selected_core = $core_info;
41 41
       break;
42 42
     }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 function uni_create_planet($Galaxy, $System, $Position, $PlanetOwnerID, $planet_name_unsafe = '', $HomeWorld = false, $options = array()) {
60 60
   $Position = intval($Position);
61 61
 
62
-  if(!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) {
62
+  if (!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) {
63 63
     return false;
64 64
   }
65 65
 
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 
69 69
   $planet_generator = sn_get_groups('planet_generator');
70 70
 
71
-  if($HomeWorld) {
71
+  if ($HomeWorld) {
72 72
     $position_data = $planet_generator[0];
73 73
   } else {
74 74
     $position_data = $planet_generator[$Position >= UNIVERSE_RANDOM_PLANET_START || $Position < 1 ? UNIVERSE_RANDOM_PLANET_START : $Position];
75
-    if($Position >= UNIVERSE_RANDOM_PLANET_START) {
75
+    if ($Position >= UNIVERSE_RANDOM_PLANET_START) {
76 76
       // Корректируем температуру для планеты-странника
77 77
       $position_data['t_max_max'] -= UNIVERSE_RANDOM_PLANET_TEMPERATURE_DECREASE * ($Position - UNIVERSE_RANDOM_PLANET_START);
78 78
     }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
   $planet_images = sn_get_groups('planet_images');
82 82
   $planet_image = $position_data['planet_images'][mt_rand(0, count($position_data['planet_images']) - 1)];
83
-  $planet_image .= 'planet' . $planet_images[$planet_image][mt_rand(0, count($planet_images[$planet_image]) - 1)];
83
+  $planet_image .= 'planet'.$planet_images[$planet_image][mt_rand(0, count($planet_images[$planet_image]) - 1)];
84 84
 
85 85
   $t_max = sn_rand_gauss_range($position_data['t_max_min'], $position_data['t_max_max'], true, 1.3, true);
86 86
   $t_min = $t_max - sn_rand_gauss_range($position_data['t_delta_min'], $position_data['t_delta_max'], true, 1.3, true);
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
   $core_info = uni_create_planet_get_density($position_data, $user_row, $planet_sectors);
93 93
 
94
-  $planet_name_unsafe = $user_row['username'] . ' ' . ($planet_name_unsafe ? $planet_name_unsafe : classLocale::$lang['sys_colo_defaultname']);
94
+  $planet_name_unsafe = $user_row['username'].' '.($planet_name_unsafe ? $planet_name_unsafe : classLocale::$lang['sys_colo_defaultname']);
95 95
 
96 96
   $planet['name'] = trim(strip_tags($planet_name_unsafe));
97 97
   $planet['id_owner'] = $PlanetOwnerID;
@@ -163,15 +163,15 @@  discard block
 block discarded – undo
163 163
   $moon_name = '';
164 164
   $moon_row = array();
165 165
   $moon = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_MOON, false, 'id');
166
-  if(!$moon['id']) {
166
+  if (!$moon['id']) {
167 167
     $moon_planet = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_PLANET, true, '`id`, `temp_min`, `temp_max`, `name`, `debris_metal`, `debris_crystal`');
168 168
 
169
-    if($moon_planet['id']) {
169
+    if ($moon_planet['id']) {
170 170
       $base_storage_size = BASE_STORAGE_SIZE;
171 171
 
172
-      if(!$moon_chance) {
172
+      if (!$moon_chance) {
173 173
         $size = mt_rand(1100, 8999);
174
-      } elseif($moon_chance <= 100) {
174
+      } elseif ($moon_chance <= 100) {
175 175
         $size = mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999);
176 176
       } else {
177 177
         $size = $moon_chance;
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 
187 187
       $field_max = ceil($size / 1000);
188 188
 
189
-      if(isset($options['image']) && $options['image']) {
189
+      if (isset($options['image']) && $options['image']) {
190 190
         $moon_image = $options['image'];
191 191
       } else {
192 192
         $moon_image = 'mond';
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         'deuterium_max'     => $base_storage_size,
220 220
       ));
221 221
 
222
-      if($update_debris) {
222
+      if ($update_debris) {
223 223
         $debris_spent = $moon_chance * 1000000;
224 224
         $metal_spent = round(min($moon_planet['debris_metal'], $debris_spent * mt_rand(50, 75) / 100));
225 225
         $crystal_spent = min($moon_planet['debris_crystal'], $debris_spent - $metal_spent);
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
         DBStaticPlanet::db_planet_update_adjust_by_id(
228 228
           $moon_planet['id'],
229 229
           array(
230
-            'debris_metal'   => -$metal_spent,    // `debris_metal` = GREATEST(0, `debris_metal` - {$metal_spent})
231
-            'debris_crystal' => -$crystal_spent,  // `debris_crystal` = GREATEST(0, `debris_crystal` - {$crystal_spent})
230
+            'debris_metal'   => -$metal_spent, // `debris_metal` = GREATEST(0, `debris_metal` - {$metal_spent})
231
+            'debris_crystal' => -$crystal_spent, // `debris_crystal` = GREATEST(0, `debris_crystal` - {$crystal_spent})
232 232
           )
233 233
         );
234 234
       }
@@ -260,28 +260,28 @@  discard block
 block discarded – undo
260 260
   $planet_row['id'] = $user['current_planet'];
261 261
 
262 262
   // Пытаемся переключить на новую планету
263
-  if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) {
263
+  if (($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) {
264 264
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id');
265 265
   } else {
266 266
     $planet_row = DBStaticPlanet::db_planet_by_id($planet_row['id']);
267 267
   }
268 268
 
269 269
   // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету
270
-  if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet']
270
+  if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet']
271 271
   {
272 272
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id');
273 273
     // Если текущей планеты не существует - выставляем Столицу
274
-    if(!isset($planet_row['id'])) {
274
+    if (!isset($planet_row['id'])) {
275 275
       $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id');
276 276
       // Если и столицы не существует - значит что-то очень не так с записью пользователя
277
-      if(!isset($planet_row['id'])) {
277
+      if (!isset($planet_row['id'])) {
278 278
         classSupernova::$debug->error("User ID {$user['id']} has Capital planet {$user['id_planet']} but this planet does not exists", 'User record error', 502);
279 279
       }
280 280
     }
281 281
   }
282 282
 
283 283
   // Если производилось переключение планеты - делаем запись в юзере
284
-  if($user['current_planet'] != $planet_row['id']) {
284
+  if ($user['current_planet'] != $planet_row['id']) {
285 285
     $user['current_planet'] = $planet_row['id'];
286 286
     DBStaticUser::db_user_set_by_id(
287 287
       $user['id'],
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 
304 304
 // ----------------------------------------------------------------------------------------------------------------
305 305
 function uni_render_coordinates($from, $prefix = '') {
306
-  return "[{$from[$prefix . 'galaxy']}:{$from[$prefix . 'system']}:{$from[$prefix . 'planet']}]";
306
+  return "[{$from[$prefix.'galaxy']}:{$from[$prefix.'system']}:{$from[$prefix.'planet']}]";
307 307
 }
308 308
 
309 309
 function uni_render_planet($from) {
@@ -311,17 +311,17 @@  discard block
 block discarded – undo
311 311
 }
312 312
 
313 313
 function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false) {
314
-  if(!$from['id']) {
314
+  if (!$from['id']) {
315 315
     $result = classLocale::$lang['sys_planet_expedition'];
316 316
   } else {
317 317
     $from_planet_id = $include_id ? (
318
-      'ID {' . ($from['id'] ? $from['id'] : ($from[$prefix . 'planet_id'] ? $from[$prefix . 'planet_id'] : 0)) . '} '
318
+      'ID {'.($from['id'] ? $from['id'] : ($from[$prefix.'planet_id'] ? $from[$prefix.'planet_id'] : 0)).'} '
319 319
     ) : '';
320 320
 
321
-    $from_planet_type = $from['planet_type'] ? $from['planet_type'] : ($from[$prefix . 'type'] ? $from[$prefix . 'type'] : 0);
322
-    $from_planet_type = ($from_planet_type ? ' ' . classLocale::$lang['sys_planet_type_sh'][$from_planet_type] : '');
321
+    $from_planet_type = $from['planet_type'] ? $from['planet_type'] : ($from[$prefix.'type'] ? $from[$prefix.'type'] : 0);
322
+    $from_planet_type = ($from_planet_type ? ' '.classLocale::$lang['sys_planet_type_sh'][$from_planet_type] : '');
323 323
 
324
-    $result = $from_planet_id . uni_render_coordinates($from, $prefix) . $from_planet_type . ($from['name'] ? ' ' . $from['name'] : '');
324
+    $result = $from_planet_id.uni_render_coordinates($from, $prefix).$from_planet_type.($from['name'] ? ' '.$from['name'] : '');
325 325
     $result = $html_safe ? str_replace(' ', '&nbsp;', htmlentities($result, ENT_COMPAT, 'UTF-8')) : $result;
326 326
   }
327 327
 
@@ -329,11 +329,11 @@  discard block
 block discarded – undo
329 329
 }
330 330
 
331 331
 function uni_render_coordinates_url($from, $prefix = '', $page = 'galaxy.php') {
332
-  return $page . (strpos($page, '?') === false ? '?' : '&') . "galaxy={$from[$prefix . 'galaxy']}&system={$from[$prefix . 'system']}&planet={$from[$prefix . 'planet']}";
332
+  return $page.(strpos($page, '?') === false ? '?' : '&')."galaxy={$from[$prefix.'galaxy']}&system={$from[$prefix.'system']}&planet={$from[$prefix.'planet']}";
333 333
 }
334 334
 
335 335
 function uni_render_coordinates_href($from, $prefix = '', $mode = 0, $fleet_type = '') {
336
-  return '<a href="' . uni_render_coordinates_url($from, $prefix, "galaxy.php?mode={$mode}") . '"' . ($fleet_type ? " {$fleet_type}" : '') . '>' . uni_render_coordinates($from, $prefix) . '</a>';
336
+  return '<a href="'.uni_render_coordinates_url($from, $prefix, "galaxy.php?mode={$mode}").'"'.($fleet_type ? " {$fleet_type}" : '').'>'.uni_render_coordinates($from, $prefix).'</a>';
337 337
 }
338 338
 
339 339
 function uni_get_time_to_jump($moon_row) {
@@ -361,30 +361,30 @@  discard block
 block discarded – undo
361 361
   $coordinates["{$prefix}planet"] = intval($coordinates["{$prefix}planet"]);
362 362
 
363 363
   return
364
-    isset($coordinates["{$prefix}galaxy"]) && $coordinates["{$prefix}galaxy"] > 0 && $coordinates["{$prefix}galaxy"] <= Vector::$knownGalaxies&&
365
-    isset($coordinates["{$prefix}system"]) && $coordinates["{$prefix}system"] > 0 && $coordinates["{$prefix}system"] <= Vector::$knownSystems&&
364
+    isset($coordinates["{$prefix}galaxy"]) && $coordinates["{$prefix}galaxy"] > 0 && $coordinates["{$prefix}galaxy"] <= Vector::$knownGalaxies &&
365
+    isset($coordinates["{$prefix}system"]) && $coordinates["{$prefix}system"] > 0 && $coordinates["{$prefix}system"] <= Vector::$knownSystems &&
366 366
     isset($coordinates["{$prefix}planet"]) && $coordinates["{$prefix}planet"] > 0 && $coordinates["{$prefix}planet"] <= Vector::$knownPlanets;
367 367
 }
368 368
 
369 369
 function uni_planet_teleport_check($user, $planetrow, $new_coordinates = null) {
370 370
   try {
371
-    if($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) {
371
+    if ($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) {
372 372
       throw new exception(classLocale::$lang['ov_teleport_err_cooldown'], ERR_ERROR);
373 373
     }
374 374
 
375
-    if(mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->planet_teleport_cost) {
375
+    if (mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->planet_teleport_cost) {
376 376
       throw new exception(classLocale::$lang['ov_teleport_err_no_dark_matter'], ERR_ERROR);
377 377
     }
378 378
 
379 379
     // TODO: Replace quick-check with using gathered flying fleet data
380
-    if(FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) {
380
+    if (FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) {
381 381
       throw new exception(classLocale::$lang['ov_teleport_err_fleet'], ERR_ERROR);
382 382
     }
383 383
 
384
-    if(is_array($new_coordinates)) {
384
+    if (is_array($new_coordinates)) {
385 385
       $new_coordinates['planet_type'] = PT_PLANET;
386 386
       $incoming = DBStaticPlanet::db_planet_by_vector($new_coordinates, '', true, 'id');
387
-      if($incoming['id']) {
387
+      if ($incoming['id']) {
388 388
         throw new exception(classLocale::$lang['ov_teleport_err_destination_busy'], ERR_ERROR);
389 389
       }
390 390
     }
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
       'result'  => ERR_NONE,
394 394
       'message' => '',
395 395
     );
396
-  } catch(exception $e) {
396
+  } catch (exception $e) {
397 397
     $response = array(
398 398
       'result'  => $e->getCode(),
399 399
       'message' => $e->getMessage(),
Please login to merge, or discard this patch.
includes/db.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,22 +24,22 @@
 block discarded – undo
24 24
   $locationType = sys_get_unit_location($user, $planet, key($unit_list));
25 25
 
26 26
   $resourcesChange = array();
27
-  foreach($unit_list as $unit_id => $unit_amount) {
28
-    if(!in_array($unit_id, $group)) {
27
+  foreach ($unit_list as $unit_id => $unit_amount) {
28
+    if (!in_array($unit_id, $group)) {
29 29
       // TODO - remove later
30 30
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: db_change_resources() вызван для не-ресурсов!</h1>');
31 31
       pdump(debug_backtrace());
32 32
       die('db_change_resources() вызван для не-ресурсов!');
33 33
     }
34 34
 
35
-    if(empty($unit_amount)) {
35
+    if (empty($unit_amount)) {
36 36
       continue;
37 37
     }
38 38
 
39 39
     $resourcesChange[pname_resource_name($unit_id)] += $unit_amount;
40 40
   }
41 41
 
42
-  if($locationType == LOC_USER) {
42
+  if ($locationType == LOC_USER) {
43 43
     $locationId = $user['id'];
44 44
   } else {
45 45
     $locationId = $planet['id'];
Please login to merge, or discard this patch.
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.