Completed
Push — work-fleets ( 9e446e...674b8a )
by SuperNova.WS
12:48 queued 05:50
created
classes/sn_module.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     require SN_ROOT_PHYSICAL . 'config.php';
76 76
 
77 77
     $module_config_array = get_class($this) . '_config';
78
-    if(!empty($$module_config_array) && is_array($$module_config_array)) {
78
+    if (!empty($$module_config_array) && is_array($$module_config_array)) {
79 79
       $this->config = $$module_config_array;
80 80
 
81 81
       return true;
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 
94 94
     // TODO: Load configuration from DB. Manifest setting
95 95
     // Trying to load configuration from file
96
-    if(!$config_exists = $this->loadModuleRootConfig()) {
96
+    if (!$config_exists = $this->loadModuleRootConfig()) {
97 97
       // Конфигурация может лежать в config_path в манифеста или в корне модуля
98
-      if(isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) {
98
+      if (isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) {
99 99
         $config_exists = true;
100
-      } elseif(file_exists($config_filename = dirname($filename) . '/config.php')) {
100
+      } elseif (file_exists($config_filename = dirname($filename) . '/config.php')) {
101 101
         $config_exists = true;
102 102
       }
103 103
 
104
-      if($config_exists) {
104
+      if ($config_exists) {
105 105
         include($config_filename);
106 106
         $module_config_array = $class_module_name . '_config';
107 107
         $this->config = $$module_config_array;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
     // Checking module status - is it installed and active
120 120
     $this->check_status();
121
-    if(!$this->manifest['active']) {
121
+    if (!$this->manifest['active']) {
122 122
       return;
123 123
     }
124 124
 
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
 
139 139
   protected function setSystemConstants() {
140 140
     // Setting constants - if any
141
-    if(empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) {
141
+    if (empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) {
142 142
       return;
143 143
     }
144 144
 
145
-    foreach($this->manifest['constants'] as $constant_name => $constant_value) {
145
+    foreach ($this->manifest['constants'] as $constant_name => $constant_value) {
146 146
       !defined($constant_name) ? define($constant_name, $constant_value) : false;
147 147
     }
148 148
   }
@@ -154,48 +154,48 @@  discard block
 block discarded – undo
154 154
     // New values from module variables will overwrite previous values (for root variables) and array elements with corresponding indexes (for arrays)
155 155
     // Constants as array indexes are honored - it's make valid such declarations as 'sn_data[ques][QUE_STRUCTURES]'
156 156
     $this->manifest['vars'] = $this->__assign_vars();
157
-    if(empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) {
157
+    if (empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) {
158 158
       return;
159 159
     }
160 160
 
161 161
     $vars_assigned = array();
162
-    foreach($this->manifest['vars'] as $var_name => $var_value) {
162
+    foreach ($this->manifest['vars'] as $var_name => $var_value) {
163 163
       $sub_vars = explode('[', str_replace(']', '', $var_name));
164 164
       $var_name = $sub_vars[0];
165 165
 
166
-      if(!isset($vars_assigned[$var_name])) {
166
+      if (!isset($vars_assigned[$var_name])) {
167 167
         $vars_assigned[$var_name] = true;
168 168
         global $$var_name;
169 169
       }
170 170
 
171 171
       $pointer = &$$var_name;
172
-      if(($n = count($sub_vars)) > 1) {
173
-        for($i = 1; $i < $n; $i++) {
174
-          if(defined($sub_vars[$i])) {
172
+      if (($n = count($sub_vars)) > 1) {
173
+        for ($i = 1; $i < $n; $i++) {
174
+          if (defined($sub_vars[$i])) {
175 175
             $sub_vars[$i] = constant($sub_vars[$i]);
176 176
           }
177 177
 
178
-          if(!isset($pointer[$sub_vars[$i]]) && $i != $n) {
178
+          if (!isset($pointer[$sub_vars[$i]]) && $i != $n) {
179 179
             $pointer[$sub_vars[$i]] = array();
180 180
           }
181 181
           $pointer = &$pointer[$sub_vars[$i]];
182 182
         }
183 183
       }
184 184
 
185
-      if(!isset($pointer) || !is_array($pointer)) {
185
+      if (!isset($pointer) || !is_array($pointer)) {
186 186
         $pointer = $var_value;
187
-      } elseif(is_array($$var_name)) {
187
+      } elseif (is_array($$var_name)) {
188 188
         $pointer = array_merge_recursive_numeric($pointer, $var_value);
189 189
       }
190 190
     }
191 191
   }
192 192
 
193 193
   protected function mergeMenu(&$sn_menu_extra, &$menu_patch) {
194
-    if(!is_array($menu_patch)) {
194
+    if (!is_array($menu_patch)) {
195 195
       return;
196 196
     }
197 197
 
198
-    foreach($menu_patch as $menu_item_name => $menu_item_data) {
198
+    foreach ($menu_patch as $menu_item_name => $menu_item_data) {
199 199
       $sn_menu_extra[$menu_item_name] = $menu_item_data;
200 200
     }
201 201
   }
@@ -204,34 +204,34 @@  discard block
 block discarded – undo
204 204
     // Overriding function if any
205 205
     sn_sys_handler_add(classSupernova::$functions, $this->manifest['functions'], $this);
206 206
 
207
-    foreach(classSupernova::$sn_mvc as $handler_type => &$handler_data) {
207
+    foreach (classSupernova::$sn_mvc as $handler_type => &$handler_data) {
208 208
       sn_sys_handler_add($handler_data, $this->manifest['mvc'][$handler_type], $this, $handler_type);
209 209
     }
210 210
   }
211 211
 
212 212
   protected function mergeNavbarButton() {
213
-    if(empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) {
213
+    if (empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) {
214 214
       return;
215 215
     }
216 216
 
217
-    foreach($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) {
217
+    foreach ($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) {
218 218
       classSupernova::$sn_mvc['navbar_prefix_button'][$button_image] = $button_url_relative;
219 219
     }
220 220
   }
221 221
 
222 222
   protected function mergeI18N() {
223 223
     $arrayName = 'i18n';
224
-    if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) {
224
+    if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) {
225 225
       return;
226 226
     }
227 227
 
228
-    foreach($this->manifest[$arrayName] as $pageName => &$contentList) {
229
-      foreach($contentList as &$i18n_file_data) {
230
-        if(is_array($i18n_file_data) && !$i18n_file_data['path']) {
228
+    foreach ($this->manifest[$arrayName] as $pageName => &$contentList) {
229
+      foreach ($contentList as &$i18n_file_data) {
230
+        if (is_array($i18n_file_data) && !$i18n_file_data['path']) {
231 231
           $i18n_file_data['path'] = $this->manifest['root_relative'];
232 232
         }
233 233
       }
234
-      if(!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) {
234
+      if (!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) {
235 235
         classSupernova::$sn_mvc[$arrayName][$pageName] = array();
236 236
       }
237 237
       classSupernova::$sn_mvc[$arrayName][$pageName] += $contentList;
@@ -239,13 +239,13 @@  discard block
 block discarded – undo
239 239
   }
240 240
 
241 241
   protected function mergeArraySpecial($arrayName) {
242
-    if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) {
242
+    if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) {
243 243
       return;
244 244
     }
245 245
 
246
-    foreach($this->manifest[$arrayName] as $pageName => &$contentList) {
246
+    foreach ($this->manifest[$arrayName] as $pageName => &$contentList) {
247 247
       !isset(classSupernova::$sn_mvc[$arrayName][$pageName]) ? classSupernova::$sn_mvc[$arrayName][$pageName] = array() : false;
248
-      foreach($contentList as $contentName => &$content) {
248
+      foreach ($contentList as $contentName => &$content) {
249 249
         classSupernova::$sn_mvc[$arrayName][$pageName][$contentName] = $content;
250 250
       }
251 251
     }
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
           $load_order[$loaded_module_name] = $level;
300 300
         }
301 301
       }
302
-    } while($prev_order != $load_order);
302
+    } while ($prev_order != $load_order);
303 303
 
304 304
     asort($load_order);
305 305
 
Please login to merge, or discard this patch.
classes/PlayerToAccountTranslate.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
   protected static $is_init = false;
20 20
 
21 21
   protected static function init() {
22
-    if(!empty(static::$db)) {
22
+    if (!empty(static::$db)) {
23 23
       return;
24 24
     }
25 25
     static::$db = classSupernova::$db;
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
     $provider_id_safe = intval($provider_id_unsafe);
67 67
     !is_array($account_list) ? $account_list = array($account_list) : false;
68 68
 
69
-    foreach($account_list as $provider_account_id_unsafe) {
69
+    foreach ($account_list as $provider_account_id_unsafe) {
70 70
       $provider_account_id_safe = intval($provider_account_id_unsafe);
71 71
 
72 72
       // TODO - Здесь могут отсутствовать аккаунты - проверять провайдером
73 73
       $query = static::$db->doquery("SELECT `user_id` FROM {{account_translate}} WHERE `provider_id` = {$provider_id_safe} AND `provider_account_id` = {$provider_account_id_safe} FOR UPDATE");
74
-      while($row = static::$db->db_fetch($query)) {
74
+      while ($row = static::$db->db_fetch($query)) {
75 75
         $account_translation[$row['user_id']][$provider_id_unsafe][$provider_account_id_unsafe] = true;
76 76
       }
77 77
     }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
       "SELECT * FROM {{account_translate}} WHERE `user_id` = {$user_id_safe} " .
92 92
       ($provider_id_unsafe ? "AND `provider_id` = {$provider_id_safe} " : '') .
93 93
       "ORDER BY `timestamp` FOR UPDATE");
94
-    while($row = static::$db->db_fetch($query)) {
94
+    while ($row = static::$db->db_fetch($query)) {
95 95
       $account_translation[$row['user_id']][$row['provider_id']][$row['provider_account_id']] = $row;
96 96
     }
97 97
 
Please login to merge, or discard this patch.
classes/classCache.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 
148 148
   public function unset_by_prefix($prefix_unset = '') {
149 149
     static $array_clear;
150
-    !$array_clear ? $array_clear = function (&$v, $k, $p) {
150
+    !$array_clear ? $array_clear = function(&$v, $k, $p) {
151 151
       strpos($k, $p) === 0 ? $v = null : false;
152 152
     } : false;
153 153
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     if ($this->$name[0] === null) {
203 203
       for ($i = count($name) - 1; $i > 0; $i--) {
204 204
         $cName = "{$name[$i]}_COUNT";
205
-        $cName1 = "{$name[$i-1]}_COUNT";
205
+        $cName1 = "{$name[$i - 1]}_COUNT";
206 206
         if ($this->$cName1 == null || $i == 1) {
207 207
           $this->$cName++;
208 208
         }
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 
248 248
     for ($i = 1; $i < count($name); $i++) {
249 249
       $cName = "{$name[$i]}_COUNT";
250
-      $cName1 = "{$name[$i-1]}_COUNT";
250
+      $cName1 = "{$name[$i - 1]}_COUNT";
251 251
 
252 252
       if ($i == 1 || $this->$cName1 === null) {
253 253
         $this->$cName--;
Please login to merge, or discard this patch.
classes/Buddy/BuddyParams.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  * @property string           $playerName
22 22
  * @property string           $playerNameAndCoordinates
23 23
  */
24
-class BuddyParams extends ContainerPlus  {
24
+class BuddyParams extends ContainerPlus {
25 25
 
26 26
   /**
27 27
    * BuddyParams constructor.
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
     $this->new_friend_name_unsafe = sys_get_param_str_unsafe('request_user_name');
38 38
     $this->request_text_unsafe = sys_get_param_str_unsafe('request_text');
39 39
 
40
-    $this->playerId = function (BuddyParams $cBuddy) {
40
+    $this->playerId = function(BuddyParams $cBuddy) {
41 41
       return $cBuddy->playerArray['id'];
42 42
     };
43
-    $this->playerName = function (BuddyParams $cBuddy) {
43
+    $this->playerName = function(BuddyParams $cBuddy) {
44 44
       return $cBuddy->playerArray['username'];
45 45
     };
46
-    $this->playerNameAndCoordinates = function (BuddyParams $cBuddy) {
46
+    $this->playerNameAndCoordinates = function(BuddyParams $cBuddy) {
47 47
       return "{$cBuddy->playerArray['username']} " . uni_render_coordinates($cBuddy->playerArray);
48 48
     };
49 49
   }
Please login to merge, or discard this patch.
classes/template.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
       // Re-position template blocks
629 629
       for ($i = sizeof($this->_tpldata[$blockname]); $i > $key; $i--)
630 630
       {
631
-        $this->_tpldata[$blockname][$i] = $this->_tpldata[$blockname][$i-1];
631
+        $this->_tpldata[$blockname][$i] = $this->_tpldata[$blockname][$i - 1];
632 632
         $this->_tpldata[$blockname][$i]['S_ROW_COUNT'] = $i;
633 633
       }
634 634
 
@@ -710,13 +710,13 @@  discard block
 block discarded – undo
710 710
   */
711 711
   function assign_recursive($values, $name = '')
712 712
   {
713
-    if(isset($values['.']))
713
+    if (isset($values['.']))
714 714
     {
715 715
       $values_extra = $values['.'];
716 716
       unset($values['.']);
717 717
     }
718 718
 
719
-    if(!$name)
719
+    if (!$name)
720 720
     {
721 721
       $this->assign_vars($values);
722 722
     }
@@ -725,12 +725,12 @@  discard block
 block discarded – undo
725 725
       $this->assign_block_vars($name, $values);
726 726
     }
727 727
 
728
-    if(isset($values_extra))
728
+    if (isset($values_extra))
729 729
     {
730
-      foreach($values_extra as $sub_array_name => $sub_array)
730
+      foreach ($values_extra as $sub_array_name => $sub_array)
731 731
       {
732 732
         $new_name = $name . ($name ? '.' : '') . $sub_array_name;
733
-        foreach($sub_array as $sub_element)
733
+        foreach ($sub_array as $sub_element)
734 734
         {
735 735
           $this->assign_recursive($sub_element, $new_name);
736 736
         }
Please login to merge, or discard this patch.
classes/DBAL/DbQuery.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
    * @return string
141 141
    */
142 142
   protected function setInsertCommand($replace) {
143
-    switch($replace) {
143
+    switch ($replace) {
144 144
       case DB_INSERT_IGNORE:
145 145
         $result = static::INSERT_IGNORE;
146 146
       break;
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     $this->build = array();
161 161
     $this->buildCommand($this->setInsertCommand($replace));
162 162
 
163
-    if(!$forceSingleInsert && is_array($this->fields) && !empty($this->fields)) {
163
+    if (!$forceSingleInsert && is_array($this->fields) && !empty($this->fields)) {
164 164
       // If there are fields - it's batch insert... unless it forced single insert
165 165
       $this->build[] = " (";
166 166
       $this->buildFieldNames(); // used $this->fields
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
    * @return string
311 311
    */
312 312
   protected function stringValue($value) {
313
-    return "'" . $this->escape((string)$value) . "'";
313
+    return "'" . $this->escape((string) $value) . "'";
314 314
   }
315 315
 
316 316
   /**
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
    * @return string
322 322
    */
323 323
   public function quote($fieldName) {
324
-    return "`" . $this->escape((string)$fieldName) . "`";
324
+    return "`" . $this->escape((string) $fieldName) . "`";
325 325
   }
326 326
 
327 327
   public function makeAdjustString($fieldValue, $fieldName) {
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
    * @return string
346 346
    */
347 347
   protected function quoteTable($tableName) {
348
-    return "`{{" . $this->escape((string)$tableName) . "}}`";
348
+    return "`{{" . $this->escape((string) $tableName) . "}}`";
349 349
   }
350 350
 
351 351
   public function castAsDbValue($value) {
352
-    switch(gettype($value)) {
352
+    switch (gettype($value)) {
353 353
       case TYPE_INTEGER:
354 354
       case TYPE_DOUBLE:
355 355
         // do nothing
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 
381 381
 
382 382
   protected function buildCommand($command) {
383
-    switch($this->command = $command) {
383
+    switch ($this->command = $command) {
384 384
       case static::UPDATE:
385 385
         $this->build[] = $this->command . " " . $this->quoteTable($this->table);
386 386
       break;
Please login to merge, or discard this patch.
classes/DbSqlHelper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@
 block discarded – undo
15 15
    * @return string
16 16
    */
17 17
   public static function quoteComment($comment) {
18
-    if($comment == '') {
18
+    if ($comment == '') {
19 19
       return '';
20 20
     }
21 21
 
22
-    $comment = str_replace(array('/*', '*/'), '__',$comment);
22
+    $comment = str_replace(array('/*', '*/'), '__', $comment);
23 23
 
24 24
     return "\r\n/*" . $comment . "*/";
25 25
   }
Please login to merge, or discard this patch.
classes/auth_local.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
     $this->prepare();
96 96
 
97 97
     $this->manifest['active'] = false;
98
-    if(!empty($this->config) && is_array($this->config['db'])) {
98
+    if (!empty($this->config) && is_array($this->config['db'])) {
99 99
       // БД, отличная от стандартной
100 100
       $this->db = classSupernova::$gc->db;
101 101
 
102 102
       $this->db->sn_db_connect($this->config['db']);
103
-      if($this->manifest['active'] = $this->db->connected) {
103
+      if ($this->manifest['active'] = $this->db->connected) {
104 104
         $this->provider_id = ACCOUNT_PROVIDER_CENTRAL;
105 105
 
106 106
         $this->domain = $this->config['domain'];
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
     }
115 115
 
116 116
     // Fallback to local DB
117
-    if(!$this->manifest['active']) {
117
+    if (!$this->manifest['active']) {
118 118
       $this->db = classSupernova::$db;
119 119
 
120 120
       $this->provider_id = ACCOUNT_PROVIDER_LOCAL;
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
   // OK v4.5
167 167
   public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) {
168 168
     $result = parent::password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe);
169
-    if($result) {
169
+    if ($result) {
170 170
       $this->cookie_set();
171 171
     }
172 172
 
@@ -194,12 +194,12 @@  discard block
 block discarded – undo
194 194
    */
195 195
   // OK v4.6
196 196
   protected function password_reset_send_code() {
197
-    if(!$this->is_password_reset) {
197
+    if (!$this->is_password_reset) {
198 198
       return $this->account_login_status;
199 199
     }
200 200
 
201 201
     // Проверяем поддержку сброса пароля
202
-    if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) {
202
+    if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) {
203 203
       return $this->account_login_status;
204 204
     }
205 205
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
       unset($this->account);
210 210
       $this->account = new Account($this->db);
211 211
 
212
-      if(!$this->account->db_get_by_email($email_unsafe)) {
212
+      if (!$this->account->db_get_by_email($email_unsafe)) {
213 213
         throw new Exception(PASSWORD_RESTORE_ERROR_EMAIL_NOT_EXISTS, ERR_ERROR);
214 214
         // return $this->account_login_status;
215 215
       }
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
 
220 220
       // TODO - Проверять уровень доступа аккаунта!
221 221
       // Аккаунты с АУТЛЕВЕЛ больше 0 - НЕ СБРАСЫВАЮТ ПАРОЛИ!
222
-      foreach($user_list as $user_id => $user_data) {
223
-        if($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) {
222
+      foreach ($user_list as $user_id => $user_data) {
223
+        if ($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) {
224 224
           throw new Exception(PASSWORD_RESTORE_ERROR_ADMIN_ACCOUNT, ERR_ERROR);
225 225
         }
226 226
       }
227 227
 
228 228
       $confirmation = $this->confirmation->db_confirmation_get_latest_by_type_and_email(CONFIRM_PASSWORD_RESET, $email_unsafe); // OK 4.5
229
-      if(isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) {
229
+      if (isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) {
230 230
         throw new Exception(PASSWORD_RESTORE_ERROR_TOO_OFTEN, ERR_ERROR);
231 231
       }
232 232
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
       );
244 244
 
245 245
       $result = $result ? PASSWORD_RESTORE_SUCCESS_CODE_SENT : PASSWORD_RESTORE_ERROR_SENDING;
246
-    } catch(Exception $e) {
246
+    } catch (Exception $e) {
247 247
       sn_db_transaction_rollback();
248 248
       $result = $e->getMessage();
249 249
     }
@@ -256,46 +256,46 @@  discard block
 block discarded – undo
256 256
    * @return int|string
257 257
    */
258 258
   protected function password_reset_confirm() {
259
-    if(!$this->is_password_reset_confirm) {
259
+    if (!$this->is_password_reset_confirm) {
260 260
       return $this->account_login_status;
261 261
     }
262 262
 
263
-    if($this->account_login_status != LOGIN_UNDEFINED) {
263
+    if ($this->account_login_status != LOGIN_UNDEFINED) {
264 264
       return $this->account_login_status;
265 265
     }
266 266
 
267 267
     // Проверяем поддержку сброса пароля
268
-    if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) {
268
+    if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) {
269 269
       return $this->account_login_status;
270 270
     }
271 271
 
272 272
     try {
273 273
       $code_unsafe = sys_get_param_str_unsafe('password_reset_code');
274
-      if(empty($code_unsafe)) {
274
+      if (empty($code_unsafe)) {
275 275
         throw new Exception(PASSWORD_RESTORE_ERROR_CODE_EMPTY, ERR_ERROR);
276 276
       }
277 277
 
278 278
       sn_db_transaction_start();
279 279
       $confirmation = $this->confirmation->db_confirmation_get_by_type_and_code(CONFIRM_PASSWORD_RESET, $code_unsafe); // OK 4.5
280 280
 
281
-      if(empty($confirmation)) {
281
+      if (empty($confirmation)) {
282 282
         throw new Exception(PASSWORD_RESTORE_ERROR_CODE_WRONG, ERR_ERROR);
283 283
       }
284 284
 
285
-      if(SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) {
285
+      if (SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) {
286 286
         throw new Exception(PASSWORD_RESTORE_ERROR_CODE_TOO_OLD, ERR_ERROR);
287 287
       }
288 288
 
289 289
       unset($this->account);
290 290
       $this->account = new Account($this->db);
291 291
 
292
-      if(!$this->account->db_get_by_email($confirmation['email'])) {
292
+      if (!$this->account->db_get_by_email($confirmation['email'])) {
293 293
         throw new Exception(PASSWORD_RESTORE_ERROR_CODE_OK_BUT_NO_ACCOUNT_FOR_EMAIL, ERR_ERROR);
294 294
       }
295 295
 
296 296
       $new_password_unsafe = $this->make_random_password();
297 297
       $salt_unsafe = $this->password_salt_generate();
298
-      if(!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) {
298
+      if (!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) {
299 299
         // Ошибка смены пароля
300 300
         throw new Exception(AUTH_ERROR_INTERNAL_PASSWORD_CHANGE_ON_RESTORE, ERR_ERROR);
301 301
       }
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
       $this->cookie_set();
306 306
       $this->login_cookie();
307 307
 
308
-      if($this->account_login_status == LOGIN_SUCCESS) {
308
+      if ($this->account_login_status == LOGIN_SUCCESS) {
309 309
         // TODO - НЕ ОБЯЗАТЕЛЬНО ОТПРАВЛЯТЬ ЧЕРЕЗ ЕМЕЙЛ! ЕСЛИ ЭТО ФЕЙСБУЧЕК ИЛИ ВКШЕЧКА - МОЖНО ЧЕРЕЗ ЛС ПИСАТЬ!!
310 310
         $message_header = sprintf(classLocale::$lang['log_lost_email_title'], classSupernova::$config->game_name);
311 311
         $message = sprintf(classLocale::$lang['log_lost_email_pass'], classSupernova::$config->game_name, $this->account->account_name, $new_password_unsafe);
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         mymail($confirmation['email'], $message_header, htmlspecialchars($message));
314 314
 
315 315
         $users_translated = PlayerToAccountTranslate::db_translate_get_users_from_account_list($this->provider_id, $this->account->account_id); // OK 4.5
316
-        if(!empty($users_translated)) {
316
+        if (!empty($users_translated)) {
317 317
           // Отправляем в лички письмо о сбросе пароля
318 318
 
319 319
           // ПО ОПРЕДЕЛЕНИЮ в $users_translated только
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
           $message = sprintf(classLocale::$lang['sys_password_reset_message_body'], $new_password_unsafe);
325 325
           $message = sys_bbcodeParse($message) . '<br><br>';
326 326
 
327
-          foreach($users_translated as $user_id => $providers_list) {
327
+          foreach ($users_translated as $user_id => $providers_list) {
328 328
             DBStaticMessages::msgSendFromAdmin($user_id, classLocale::$lang['sys_login_register_message_title'], $message);
329 329
           }
330 330
         } else {
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
     $this->flog('Регистрация: начинаем. Провайдер ' . $this->provider_id);
378 378
 
379 379
     try {
380
-      if(!$this->is_register) {
380
+      if (!$this->is_register) {
381 381
         $this->flog('Регистрация: не выставлен флаг регистрации - пропускаем');
382 382
         throw new Exception(LOGIN_UNDEFINED, ERR_ERROR);
383 383
       }
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
       sn_db_transaction_start();
388 388
 
389 389
       $this->account->db_get_by_name_or_email($this->input_login_unsafe, $this->input_email_unsafe);
390
-      if($this->account->is_exists) {
391
-        if($this->account->account_email == $this->input_email_unsafe) {
390
+      if ($this->account->is_exists) {
391
+        if ($this->account->account_email == $this->input_email_unsafe) {
392 392
           throw new Exception(REGISTER_ERROR_EMAIL_EXISTS, ERR_ERROR);
393 393
         } else {
394 394
           throw new Exception(REGISTER_ERROR_ACCOUNT_NAME_EXISTS, ERR_ERROR);
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
       // А вот это пока не нужно. Трансляцией аккаунтов в юзеров и созданием новых юзеров для новозашедших аккаунтов занимается Auth
411 411
       // $this->register_account();
412 412
       sn_db_transaction_commit();
413
-    } catch(Exception $e) {
413
+    } catch (Exception $e) {
414 414
       sn_db_transaction_rollback();
415 415
       $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false;
416 416
     }
@@ -424,19 +424,19 @@  discard block
 block discarded – undo
424 424
    * @return int Результат попытки
425 425
    */
426 426
   protected function login_cookie() {
427
-    if($this->account_login_status != LOGIN_UNDEFINED) {
427
+    if ($this->account_login_status != LOGIN_UNDEFINED) {
428 428
       return $this->account_login_status;
429 429
     }
430 430
 
431 431
     // Пытаемся войти по куке
432
-    if(!empty($_COOKIE[$this->cookie_name])) {
433
-      if(count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) {
432
+    if (!empty($_COOKIE[$this->cookie_name])) {
433
+      if (count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) {
434 434
         list($account_id_unsafe, $cookie_password_hash_salted, $user_remember_me) = explode(AUTH_COOKIE_DELIMETER, $_COOKIE[$this->cookie_name]);
435 435
       } else {
436 436
         list($account_id_unsafe, $user_name, $cookie_password_hash_salted, $user_remember_me) = explode("/%/", $_COOKIE[$this->cookie_name]);
437 437
       }
438 438
 
439
-      if(
439
+      if (
440 440
         $this->account->db_get_by_id($account_id_unsafe)
441 441
         && ($this->password_encode_for_cookie($this->account->account_password) == $cookie_password_hash_salted)
442 442
       ) {
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
       }
446 446
     }
447 447
 
448
-    if($this->account_login_status != LOGIN_SUCCESS) {
448
+    if ($this->account_login_status != LOGIN_SUCCESS) {
449 449
       // Невалидная кука - чистим
450 450
       $this->cookie_clear();
451 451
     }
@@ -462,29 +462,29 @@  discard block
 block discarded – undo
462 462
   protected function login_username() {
463 463
     // TODO - Логин по старым именам
464 464
     try {
465
-      if(!$this->is_login) {
465
+      if (!$this->is_login) {
466 466
         $this->flog('Логин: не выставлен флаг входа в игру - это не логин');
467 467
         throw new Exception(LOGIN_UNDEFINED, ERR_ERROR);
468 468
       }
469 469
 
470 470
       // TODO Пустое имя аккаунта
471
-      if(!$this->input_login_unsafe) {
471
+      if (!$this->input_login_unsafe) {
472 472
         throw new Exception(LOGIN_UNDEFINED, ERR_ERROR);
473 473
       }
474 474
 
475 475
       $this->login_validate_input();
476 476
 
477
-      if(!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) {
477
+      if (!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) {
478 478
         throw new Exception(LOGIN_ERROR_USERNAME, ERR_ERROR);
479 479
       }
480 480
 
481
-      if(!$this->account->password_check($this->input_login_password_raw)) {
481
+      if (!$this->account->password_check($this->input_login_password_raw)) {
482 482
         throw new Exception(LOGIN_ERROR_PASSWORD, ERR_ERROR);
483 483
       }
484 484
 
485 485
       $this->cookie_set();
486 486
       $this->account_login_status = LOGIN_SUCCESS;
487
-    } catch(Exception $e) {
487
+    } catch (Exception $e) {
488 488
       $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false;
489 489
     }
490 490
 
@@ -506,11 +506,11 @@  discard block
 block discarded – undo
506 506
   protected function cookie_set($account_to_impersonate = null) {
507 507
     $this_account = is_object($account_to_impersonate) ? $account_to_impersonate : $this->account;
508 508
 
509
-    if(!is_object($this_account) || !$this_account->is_exists) {
509
+    if (!is_object($this_account) || !$this_account->is_exists) {
510 510
       throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR);
511 511
     }
512 512
 
513
-    if(is_object($account_to_impersonate) && $account_to_impersonate->is_exists) {
513
+    if (is_object($account_to_impersonate) && $account_to_impersonate->is_exists) {
514 514
       sn_setcookie($this->cookie_name_impersonate, $_COOKIE[$this->cookie_name], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $this->domain);
515 515
     }
516 516
 
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
   // OK v4.1
529 529
   protected function cookie_clear() {
530 530
     // Автоматически вообще-то - если установлена кука имперсонатора - то чистим обычную, а куку имперсонатора - копируем в неё
531
-    if(!empty($_COOKIE[$this->cookie_name_impersonate])) {
531
+    if (!empty($_COOKIE[$this->cookie_name_impersonate])) {
532 532
       sn_setcookie($this->cookie_name, $_COOKIE[$this->cookie_name_impersonate], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $this->domain);
533 533
       sn_setcookie($this->cookie_name_impersonate, '', SN_TIME_NOW - PERIOD_WEEK, $this->sn_root_path, $this->domain);
534 534
     } else {
@@ -547,10 +547,10 @@  discard block
 block discarded – undo
547 547
   protected function login_validate_input() {
548 548
     // Проверяем, что бы в начале и конце не было пустых символов
549 549
     // TODO - при копировании Эксель -> Опера - в конце образуются пустые места. Это не должно быть проблемой! Вынести проверку пароля в регистрацию!
550
-    if($this->input_login_password_raw != trim($this->input_login_password_raw)) {
550
+    if ($this->input_login_password_raw != trim($this->input_login_password_raw)) {
551 551
       throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR);
552 552
     }
553
-    if(!$this->input_login_password_raw) {
553
+    if (!$this->input_login_password_raw) {
554 554
       throw new Exception(LOGIN_ERROR_PASSWORD_EMPTY, ERR_ERROR);
555 555
     }
556 556
   }
@@ -566,37 +566,37 @@  discard block
 block discarded – undo
566 566
     $this->login_validate_input();
567 567
 
568 568
     // Если нет имени пользователя - NO GO!
569
-    if(!$this->input_login_unsafe) {
569
+    if (!$this->input_login_unsafe) {
570 570
       throw new Exception(LOGIN_ERROR_USERNAME_EMPTY, ERR_ERROR);
571 571
     }
572 572
     // Если логин имеет запрещенные символы - NO GO!
573
-    if(strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
573
+    if (strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
574 574
       throw new Exception(LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS, ERR_ERROR);
575 575
     }
576 576
     // Если логин меньше минимальной длины - NO GO!
577
-    if(strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) {
577
+    if (strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) {
578 578
       throw new Exception(REGISTER_ERROR_USERNAME_SHORT, ERR_ERROR);
579 579
     }
580 580
     // Если пароль меньше минимальной длины - NO GO!
581
-    if(strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) {
581
+    if (strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) {
582 582
       throw new Exception(REGISTER_ERROR_PASSWORD_INSECURE, ERR_ERROR);
583 583
     }
584 584
     // Если пароль имеет пробельные символы в начале или конце - NO GO!
585
-    if($this->input_login_password_raw != trim($this->input_login_password_raw)) {
585
+    if ($this->input_login_password_raw != trim($this->input_login_password_raw)) {
586 586
       throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR);
587 587
     }
588 588
     // Если пароль не совпадает с подтверждением - NO GO! То, что у пароля нет пробельных символов в начале/конце - мы уже проверили выше
589 589
     //Если они есть у повтора - значит пароль и повтор не совпадут
590
-    if($this->input_login_password_raw <> $this->input_login_password_raw_repeat) {
590
+    if ($this->input_login_password_raw <> $this->input_login_password_raw_repeat) {
591 591
       throw new Exception(REGISTER_ERROR_PASSWORD_DIFFERENT, ERR_ERROR);
592 592
     }
593 593
     // Если нет емейла - NO GO!
594 594
     // TODO - регистрация без емейла
595
-    if(!$this->input_email_unsafe) {
595
+    if (!$this->input_email_unsafe) {
596 596
       throw new Exception(REGISTER_ERROR_EMAIL_EMPTY, ERR_ERROR);
597 597
     }
598 598
     // Если емейл не является емейлом - NO GO!
599
-    if(!is_email($this->input_email_unsafe)) {
599
+    if (!is_email($this->input_email_unsafe)) {
600 600
       throw new Exception(REGISTER_ERROR_EMAIL_WRONG, ERR_ERROR);
601 601
     }
602 602
   }
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
     return core_auth::make_random_password();
626 626
   }
627 627
   protected function flog($message, $die = false) {
628
-    if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
628
+    if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
629 629
       return;
630 630
     }
631 631
     list($called, $caller) = debug_backtrace(false);
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
     $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false;
640 640
 
641 641
     classSupernova::log_file("$message - $caller_name");
642
-    if($die) {
642
+    if ($die) {
643 643
       $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>");
644 644
     }
645 645
   }
Please login to merge, or discard this patch.
classes/UBE/UBEFleet.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -159,20 +159,20 @@  discard block
 block discarded – undo
159 159
       $this->owner_id,
160 160
       $this->db_id,
161 161
 
162
-      (float)$this->UBE_PLANET[PLANET_ID],
162
+      (float) $this->UBE_PLANET[PLANET_ID],
163 163
       "'" . db_escape($this->UBE_PLANET[PLANET_NAME]) . "'",
164
-      (int)$this->UBE_PLANET[PLANET_GALAXY],
165
-      (int)$this->UBE_PLANET[PLANET_SYSTEM],
166
-      (int)$this->UBE_PLANET[PLANET_PLANET],
167
-      (int)$this->UBE_PLANET[PLANET_TYPE],
168
-
169
-      (float)$this->resource_list[RES_METAL],
170
-      (float)$this->resource_list[RES_CRYSTAL],
171
-      (float)$this->resource_list[RES_DEUTERIUM],
172
-
173
-      (float)$this->fleet_bonus->calcBonus(P_ATTACK),
174
-      (float)$this->fleet_bonus->calcBonus(P_SHIELD),
175
-      (float)$this->fleet_bonus->calcBonus(P_ARMOR),
164
+      (int) $this->UBE_PLANET[PLANET_GALAXY],
165
+      (int) $this->UBE_PLANET[PLANET_SYSTEM],
166
+      (int) $this->UBE_PLANET[PLANET_PLANET],
167
+      (int) $this->UBE_PLANET[PLANET_TYPE],
168
+
169
+      (float) $this->resource_list[RES_METAL],
170
+      (float) $this->resource_list[RES_CRYSTAL],
171
+      (float) $this->resource_list[RES_DEUTERIUM],
172
+
173
+      (float) $this->fleet_bonus->calcBonus(P_ATTACK),
174
+      (float) $this->fleet_bonus->calcBonus(P_SHIELD),
175
+      (float) $this->fleet_bonus->calcBonus(P_ARMOR),
176 176
     );
177 177
   }
178 178
 
@@ -185,13 +185,13 @@  discard block
 block discarded – undo
185 185
     $this->owner_id = $objFleet->playerOwnerId;
186 186
     $this->group_id = $objFleet->group_id;
187 187
 
188
-    foreach($objFleet->shipsIterator() as $unit_id => $unit) {
189
-      if(!$unit->count) {
188
+    foreach ($objFleet->shipsIterator() as $unit_id => $unit) {
189
+      if (!$unit->count) {
190 190
         continue;
191 191
       }
192 192
 
193 193
       $unit_type = get_unit_param($unit_id, P_UNIT_TYPE);
194
-      if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
194
+      if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
195 195
         $this->unit_list->unitAdjustCount($unit_id, $unit->count);
196 196
       }
197 197
     }
@@ -227,13 +227,13 @@  discard block
 block discarded – undo
227 227
 //      }
228 228
 //    }
229 229
 
230
-    foreach($sn_group_combat as $unit_id) {
231
-      if($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) {
230
+    foreach ($sn_group_combat as $unit_id) {
231
+      if ($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) {
232 232
         $this->unit_list->unitAdjustCount($unit_id, $unit_count);
233 233
       }
234 234
     }
235 235
 
236
-    foreach(sn_get_groups('resources_loot') as $resource_id) {
236
+    foreach (sn_get_groups('resources_loot') as $resource_id) {
237 237
       $this->resource_list[$resource_id] = floor(mrc_get_level($player_db_row, $planet_row, $resource_id));
238 238
     }
239 239
 
@@ -292,27 +292,27 @@  discard block
 block discarded – undo
292 292
       $ube_report_id,
293 293
       $this->db_id,
294 294
 
295
-      (float)$this->resources_lost_on_units[RES_METAL],
296
-      (float)$this->resources_lost_on_units[RES_CRYSTAL],
297
-      (float)$this->resources_lost_on_units[RES_DEUTERIUM],
298
-      (float)$this->cargo_dropped[RES_METAL],
299
-      (float)$this->cargo_dropped[RES_CRYSTAL],
300
-      (float)$this->cargo_dropped[RES_DEUTERIUM],
301
-      (float)$this->resources_looted[RES_METAL],
302
-      (float)$this->resources_looted[RES_CRYSTAL],
303
-      (float)$this->resources_looted[RES_DEUTERIUM],
304
-      (float)$this->resources_lost_in_metal[RES_METAL],
295
+      (float) $this->resources_lost_on_units[RES_METAL],
296
+      (float) $this->resources_lost_on_units[RES_CRYSTAL],
297
+      (float) $this->resources_lost_on_units[RES_DEUTERIUM],
298
+      (float) $this->cargo_dropped[RES_METAL],
299
+      (float) $this->cargo_dropped[RES_CRYSTAL],
300
+      (float) $this->cargo_dropped[RES_DEUTERIUM],
301
+      (float) $this->resources_looted[RES_METAL],
302
+      (float) $this->resources_looted[RES_CRYSTAL],
303
+      (float) $this->resources_looted[RES_DEUTERIUM],
304
+      (float) $this->resources_lost_in_metal[RES_METAL],
305 305
     );
306 306
   }
307 307
 
308 308
   public function report_render_outcome_side_fleet() {
309 309
     $UBE_DEFENCE_RESTORE = array();
310 310
     $UBE_UNITS_LOST = array();
311
-    foreach($this->unit_list->_container as $UBEUnit) {
312
-      if($UBEUnit->units_restored) {
311
+    foreach ($this->unit_list->_container as $UBEUnit) {
312
+      if ($UBEUnit->units_restored) {
313 313
         $UBE_DEFENCE_RESTORE[$UBEUnit->unitId] = $UBEUnit->units_restored;
314 314
       }
315
-      if($UBEUnit->units_lost) {
315
+      if ($UBEUnit->units_lost) {
316 316
         $UBE_UNITS_LOST[$UBEUnit->unitId] = $UBEUnit->units_lost;
317 317
       }
318 318
     }
@@ -337,16 +337,16 @@  discard block
 block discarded – undo
337 337
    */
338 338
   protected function report_render_outcome_side_fleet_line(&$array, $lang_header_index) {
339 339
     $result = array();
340
-    if(!empty($array)) {
341
-      foreach($array as $unit_id => $unit_count) {
342
-        if($unit_count) {
340
+    if (!empty($array)) {
341
+      foreach ($array as $unit_id => $unit_count) {
342
+        if ($unit_count) {
343 343
           $result[] = array(
344 344
             'NAME' => classLocale::$lang['tech'][$unit_id],
345 345
             'LOSS' => pretty_number($unit_count),
346 346
           );
347 347
         }
348 348
       }
349
-      if($lang_header_index && count($result)) {
349
+      if ($lang_header_index && count($result)) {
350 350
         array_unshift($result, array('NAME' => classLocale::$lang[$lang_header_index]));
351 351
       }
352 352
     }
@@ -359,16 +359,16 @@  discard block
 block discarded – undo
359 359
     $fleet_id = $this->db_id;
360 360
 
361 361
     $unit_sort_order = 0;
362
-    foreach($this->unit_list->_container as $UBEUnit) {
363
-      if($UBEUnit->units_lost || $UBEUnit->units_restored) {
362
+    foreach ($this->unit_list->_container as $UBEUnit) {
363
+      if ($UBEUnit->units_lost || $UBEUnit->units_restored) {
364 364
         $unit_sort_order++;
365 365
         $sql_perform_report_unit[] = array(
366 366
           $ube_report_id,
367 367
           $fleet_id,
368 368
 
369 369
           $UBEUnit->unitId,
370
-          (float)$UBEUnit->units_restored,
371
-          (float)$UBEUnit->units_lost,
370
+          (float) $UBEUnit->units_restored,
371
+          (float) $UBEUnit->units_lost,
372 372
 
373 373
           $unit_sort_order,
374 374
         );
@@ -384,9 +384,9 @@  discard block
 block discarded – undo
384 384
   public function ube_combat_result_calculate_resources() {
385 385
     $resource_delta_fleet = array();
386 386
     // Если во флоте остались юниты или это планета - генерируем изменение ресурсов
387
-    foreach(sn_get_groups('resources_loot') as $resource_id) {
388
-      $resource_change = (float)$this->resources_looted[$resource_id] + (float)$this->cargo_dropped[$resource_id];
389
-      if($resource_change) {
387
+    foreach (sn_get_groups('resources_loot') as $resource_id) {
388
+      $resource_change = (float) $this->resources_looted[$resource_id] + (float) $this->cargo_dropped[$resource_id];
389
+      if ($resource_change) {
390 390
         $resource_delta_fleet[$resource_id] = -($resource_change);
391 391
       }
392 392
     }
@@ -419,12 +419,12 @@  discard block
 block discarded – undo
419 419
     );
420 420
 
421 421
     $this->fleet_capacity = 0;
422
-    foreach($this->unit_list->_container as $UBEUnit) {
422
+    foreach ($this->unit_list->_container as $UBEUnit) {
423 423
       $this->fleet_capacity += $UBEUnit->capacity * $UBEUnit->count;
424 424
 
425
-      if($UBEUnit->units_lost) {
426
-        foreach($UBEUnit->price as $resource_id => $unit_resource_price) {
427
-          if(!$unit_resource_price) {
425
+      if ($UBEUnit->units_lost) {
426
+        foreach ($UBEUnit->price as $resource_id => $unit_resource_price) {
427
+          if (!$unit_resource_price) {
428 428
             continue;
429 429
           }
430 430
 
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
           $this->resources_lost_on_units[$resource_id] += $resources_lost;
433 433
           // Если это корабль - прибавляем потери к обломкам на орбите
434 434
           // TODO - опция выбрасывания обороны в обломки
435
-          if($UBEUnit->getType() == UNIT_SHIPS) {
435
+          if ($UBEUnit->getType() == UNIT_SHIPS) {
436 436
             $this->resources_lost_on_ships[$resource_id] += $resources_lost;
437 437
           }
438 438
         }
@@ -444,11 +444,11 @@  discard block
 block discarded – undo
444 444
 
445 445
     // Если емкость трюмов меньше количество ресурсов - часть ресов выбрасываем нахуй
446 446
     // На планете ($fleet_id = 0) ресурсы в космос не выбрасываются
447
-    if($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) {
447
+    if ($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) {
448 448
       $drop_share = 1 - $this->fleet_capacity / $fleet_total_resources; // Какая часть ресурсов выброшена
449
-      foreach($this->resource_list as $resource_id => &$resource_amount) {
449
+      foreach ($this->resource_list as $resource_id => &$resource_amount) {
450 450
         // Не просчитываем ресурсы, которых нет на борту кораблей флота
451
-        if(!$resource_amount) {
451
+        if (!$resource_amount) {
452 452
           continue;
453 453
         }
454 454
 
@@ -469,19 +469,19 @@  discard block
 block discarded – undo
469 469
     $objFleet2->dbId = $this->db_id;
470 470
 
471 471
     // Если это была миссия Уничтожения И звезда смерти взорвалась И мы работаем с аттакерами - значит все аттакеры умерли
472
-    if($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) {
472
+    if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) {
473 473
       $objFleet2->dbDelete();
474
-    } elseif($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial ||
474
+    } elseif ($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial ||
475 475
       $objFleet2->dbDelete();
476 476
     } else {
477
-      if($ship_count_lost) {
477
+      if ($ship_count_lost) {
478 478
         // Просматриваем результаты изменения флотов
479
-        foreach($this->unit_list->_container as $UBEUnit) {
479
+        foreach ($this->unit_list->_container as $UBEUnit) {
480 480
           // Перебираем аутком на случай восстановления юнитов
481 481
 //          if(($units_left = $UBEUnit->getCount() - (float)$UBEUnit->units_lost) > 0) {
482 482
 //            $fleet_real_array[$UBEUnit->unitId] = $units_left;
483 483
 //          };
484
-          if(floatval($UBEUnit->units_lost) != 0) {
484
+          if (floatval($UBEUnit->units_lost) != 0) {
485 485
             $objFleet2->shipAdjustCount($UBEUnit->unitId, floatval($UBEUnit->units_lost));
486 486
           };
487 487
         }
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
       $objFleet2->resourcesAdjust($resource_delta_fleet);
492 492
 
493 493
       // Если защитник и не РМФ - отправляем флот назад
494
-      if($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) {
494
+      if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) {
495 495
         $objFleet2->is_returning = 1;
496 496
       }
497 497
       $objFleet2->dbSave();
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
   public function calculate_unit_partial_data(UBEASA $side_ASA) {
522 522
     $this->fleet_share_of_side_armor = $this->total_stats[P_ARMOR] / $side_ASA->getArmor();
523 523
 
524
-    foreach($this->unit_list->_container as $UBEUnit) {
524
+    foreach ($this->unit_list->_container as $UBEUnit) {
525 525
       $UBEUnit->share_of_side_armor = $UBEUnit->pool_armor / $side_ASA->getArmor();
526 526
     }
527 527
   }
@@ -533,9 +533,9 @@  discard block
 block discarded – undo
533 533
    * @version 2016-02-25 23:42:45 41a4.68
534 534
    */
535 535
   public function attack_fleets(UBEFleetList $fleet_list, $is_simulator) {
536
-    foreach($fleet_list->_container as $defending_fleet) {
536
+    foreach ($fleet_list->_container as $defending_fleet) {
537 537
       // Не атакуются флоты на своей стороне
538
-      if($this->is_attacker == $defending_fleet->is_attacker) {
538
+      if ($this->is_attacker == $defending_fleet->is_attacker) {
539 539
         continue;
540 540
       }
541 541
       $this->attack_fleet($defending_fleet, $is_simulator);
@@ -550,12 +550,12 @@  discard block
 block discarded – undo
550 550
   public function attack_fleet(UBEFleet $defending_fleet, $is_simulator) {
551 551
     UBEDebug::unit_dump_header();
552 552
 
553
-    foreach($this->unit_list->_container as $attacking_unit_pool) {
553
+    foreach ($this->unit_list->_container as $attacking_unit_pool) {
554 554
       UBEDebug::unit_dump($attacking_unit_pool, 'attacker');
555 555
 
556 556
       // if($attack_unit_count <= 0) continue; // TODO: Это пока нельзя включать - вот если будут "боевые порядки юнитов..."
557
-      foreach($defending_fleet->unit_list->_container as $defending_unit_pool) {
558
-        if($defending_unit_pool->isEmpty()) {
557
+      foreach ($defending_fleet->unit_list->_container as $defending_unit_pool) {
558
+        if ($defending_unit_pool->isEmpty()) {
559 559
           continue;
560 560
         }
561 561
 
Please login to merge, or discard this patch.