Completed
Push — trunk ( 5a98ee...c2d255 )
by SuperNova.WS
04:09
created
includes/vars_structures.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
       'factor'      => 1.5,
17 17
     ),
18 18
     P_UNIT_PRODUCTION   => array(
19
-      RES_METAL  => function ($level, $production_factor, $user, $planet_row) { return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
20
-      RES_ENERGY => function ($level, $production_factor, $user, $planet_row) { return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
19
+      RES_METAL  => function($level, $production_factor, $user, $planet_row) { return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
20
+      RES_ENERGY => function($level, $production_factor, $user, $planet_row) { return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
21 21
     ),
22 22
     P_MINING_IS_MANAGED => true,
23 23
   ),
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
       'factor'      => 1.6,
35 35
     ),
36 36
     P_UNIT_PRODUCTION   => array(
37
-      RES_CRYSTAL => function ($level, $production_factor, $user, $planet_row) { return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
38
-      RES_ENERGY  => function ($level, $production_factor, $user, $planet_row) { return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
37
+      RES_CRYSTAL => function($level, $production_factor, $user, $planet_row) { return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
38
+      RES_ENERGY  => function($level, $production_factor, $user, $planet_row) { return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
39 39
     ),
40 40
     P_MINING_IS_MANAGED => true,
41 41
   ),
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
       'factor'      => 1.5,
53 53
     ),
54 54
     P_UNIT_PRODUCTION   => array(
55
-      RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) { return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28); },
56
-      RES_ENERGY    => function ($level, $production_factor, $user, $planet_row) { return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
55
+      RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) { return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28); },
56
+      RES_ENERGY    => function($level, $production_factor, $user, $planet_row) { return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
57 57
     ),
58 58
     P_MINING_IS_MANAGED => true,
59 59
   ),
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
       'factor'      => 1.5,
71 71
     ),
72 72
     P_UNIT_PRODUCTION   => array(
73
-      RES_ENERGY => function ($level, $production_factor, $user, $planet_row) { return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor); },
73
+      RES_ENERGY => function($level, $production_factor, $user, $planet_row) { return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor); },
74 74
     ),
75 75
     P_MINING_IS_MANAGED => true,
76 76
   ),
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
       'factor'      => 1.8,
89 89
     ),
90 90
     P_UNIT_PRODUCTION   => array(
91
-      RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) { return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
92
-      RES_ENERGY    => function ($level, $production_factor, $user, $planet_row) { return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, "", TECH_ENERGY), $level) * (0.1 * $production_factor); },
91
+      RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) { return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
92
+      RES_ENERGY    => function($level, $production_factor, $user, $planet_row) { return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, "", TECH_ENERGY), $level) * (0.1 * $production_factor); },
93 93
     ),
94 94
     P_MINING_IS_MANAGED => true,
95 95
   ),
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
       'factor'      => 2,
107 107
     ),
108 108
     'storage'  => array(
109
-      RES_METAL => function ($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); },
109
+      RES_METAL => function($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); },
110 110
     ),
111 111
   ),
112 112
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
       'factor'      => 2,
123 123
     ),
124 124
     'storage'  => array(
125
-      RES_CRYSTAL => function ($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); },
125
+      RES_CRYSTAL => function($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); },
126 126
     ),
127 127
   ),
128 128
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
       'factor'      => 2,
139 139
     ),
140 140
     'storage'  => array(
141
-      RES_DEUTERIUM => function ($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); },
141
+      RES_DEUTERIUM => function($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); },
142 142
     ),
143 143
   ),
144 144
 
Please login to merge, or discard this patch.
classes/_SnCacheInternal.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
     //print("<br />CACHE CLEAR {$cache_id} " . ($hard ? 'HARD' : 'SOFT') . "<br />");
53 53
     if ($hard && !empty(_SnCacheInternal::$data[$location_type])) {
54 54
       // Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях
55
-      array_walk(_SnCacheInternal::$data[$location_type], function (&$item) { $item = null; });
55
+      array_walk(_SnCacheInternal::$data[$location_type], function(&$item) { $item = null; });
56 56
     }
57 57
     _SnCacheInternal::$locator[$location_type] = [];
58 58
     _SnCacheInternal::$queries[$location_type] = [];
Please login to merge, or discard this patch.
classes/debug.php 1 patch
Spacing   +42 added lines, -43 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  * que esperabas!!! soy newbie!!! D':<
25 25
 */
26 26
 
27
-if(!defined('INSIDE')) {
27
+if (!defined('INSIDE')) {
28 28
   die("attemp hacking");
29 29
 }
30 30
 
@@ -37,16 +37,16 @@  discard block
 block discarded – undo
37 37
   function log_file($message, $ident_change = 0) {
38 38
     static $ident = 0;
39 39
 
40
-    if(!defined('SN_DEBUG_LOG')) {
40
+    if (!defined('SN_DEBUG_LOG')) {
41 41
       return;
42 42
     }
43 43
 
44
-    if($this->log_file_handler === null) {
44
+    if ($this->log_file_handler === null) {
45 45
       $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+');
46 46
       @fwrite($this->log_file_handler, "\r\n\r\n");
47 47
     }
48 48
     $ident_change < 0 ? $ident += $ident_change * 2 : false;
49
-    if($this->log_file_handler) {
49
+    if ($this->log_file_handler) {
50 50
       @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n");
51 51
     }
52 52
     $ident_change > 0 ? $ident += $ident_change * 2 : false;
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
     $result = array();
82 82
     $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++;
83 83
     $result[] = "tID {$transaction_id}";
84
-    foreach($backtrace as $a_trace) {
85
-      if(in_array($a_trace['function'], $exclude_functions)) {
84
+    foreach ($backtrace as $a_trace) {
85
+      if (in_array($a_trace['function'], $exclude_functions)) {
86 86
         continue;
87 87
       }
88 88
       $function =
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
       $result[] = "{$function} - '{$file}' Line {$a_trace['line']}";
100 100
 
101
-      if(!$long_comment) {
101
+      if (!$long_comment) {
102 102
         break;
103 103
       }
104 104
     }
@@ -107,26 +107,26 @@  discard block
 block discarded – undo
107 107
   }
108 108
 
109 109
   function dump($dump = false, $force_base = false, $deadlock = false) {
110
-    if($dump === false) {
110
+    if ($dump === false) {
111 111
       return;
112 112
     }
113 113
 
114 114
     $error_backtrace = array();
115 115
     $base_dump = false;
116 116
 
117
-    if($force_base === true) {
117
+    if ($force_base === true) {
118 118
       $base_dump = true;
119 119
     }
120 120
 
121
-    if($dump === true) {
121
+    if ($dump === true) {
122 122
       $base_dump = true;
123 123
     } else {
124
-      if(!is_array($dump)) {
124
+      if (!is_array($dump)) {
125 125
         $dump = array('var' => $dump);
126 126
       }
127 127
 
128
-      foreach($dump as $dump_var_name => $dump_var) {
129
-        if($dump_var_name == 'base_dump') {
128
+      foreach ($dump as $dump_var_name => $dump_var) {
129
+        if ($dump_var_name == 'base_dump') {
130 130
           $base_dump = $dump_var;
131 131
         } else {
132 132
           $error_backtrace[$dump_var_name] = $dump_var;
@@ -134,24 +134,23 @@  discard block
 block discarded – undo
134 134
       }
135 135
     }
136 136
 
137
-    if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
137
+    if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
138 138
       $error_backtrace['deadlock'] = explode("\n", $q['Status']);
139 139
       $error_backtrace['locks'] = _SnCacheInternal::$locks;
140 140
       $error_backtrace['cSN_data'] = _SnCacheInternal::$data;
141
-      foreach($error_backtrace['cSN_data'] as &$location) {
142
-        foreach($location as $location_id => &$location_data) //          $location_data = $location_id;
141
+      foreach ($error_backtrace['cSN_data'] as &$location) {
142
+        foreach ($location as $location_id => &$location_data) //          $location_data = $location_id;
143 143
         {
144
-          $location_data = isset($location_data['username']) ? $location_data['username'] :
145
-            (isset($location_data['name']) ? $location_data['name'] : $location_id);
144
+          $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id);
146 145
         }
147 146
       }
148 147
     }
149 148
 
150
-    if($base_dump) {
151
-      if(!is_array($this->log_array) || empty($this->log_array)) {
149
+    if ($base_dump) {
150
+      if (!is_array($this->log_array) || empty($this->log_array)) {
152 151
         $this->log_array = [];
153 152
       } else {
154
-        foreach($this->log_array as $log) {
153
+        foreach ($this->log_array as $log) {
155 154
           $error_backtrace['queries'][] = $log;
156 155
         }
157 156
       }
@@ -163,17 +162,17 @@  discard block
 block discarded – undo
163 162
       // Converting object instances to object names
164 163
 
165 164
       foreach ($error_backtrace['backtrace'] as &$backtrace) {
166
-        if(is_object($backtrace['object'])) {
165
+        if (is_object($backtrace['object'])) {
167 166
           $backtrace['object'] = get_class($backtrace['object']);
168 167
         }
169 168
 
170
-        if(empty($backtrace['args'])) {
169
+        if (empty($backtrace['args'])) {
171 170
           continue;
172 171
         }
173 172
 
174 173
         // Doing same conversion for backtrace params
175
-        foreach($backtrace['args'] as &$arg) {
176
-          if(is_object($arg)) {
174
+        foreach ($backtrace['args'] as &$arg) {
175
+          if (is_object($arg)) {
177 176
             $arg = 'object::' . get_class($arg);
178 177
           }
179 178
         }
@@ -202,14 +201,14 @@  discard block
 block discarded – undo
202 201
   function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) {
203 202
     global $config, $sys_stop_log_hit, $lang, $sys_log_disabled, $user;
204 203
 
205
-    if(empty(classSupernova::$db->connected)) {
204
+    if (empty(classSupernova::$db->connected)) {
206 205
       // TODO - писать ошибку в файл
207 206
       die('SQL server currently unavailable. Please contact Administration...');
208 207
     }
209 208
 
210 209
     sn_db_transaction_rollback();
211 210
 
212
-    if(classSupernova::$config->debug == 1) {
211
+    if (classSupernova::$config->debug == 1) {
213 212
       echo "<h2>{$title}</h2><br><font color=red>" . htmlspecialchars($message) . "</font><br><hr>";
214 213
       echo "<table>{$this->log}</table>";
215 214
     }
@@ -219,7 +218,7 @@  discard block
 block discarded – undo
219 218
     $error_text = db_escape($message);
220 219
     $error_backtrace = $this->dump($dump, true, strpos($message, 'Deadlock') !== false);
221 220
 
222
-    if(!$sys_log_disabled) {
221
+    if (!$sys_log_disabled) {
223 222
       $query = "INSERT INTO `{{logs}}` SET
224 223
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "',
225 224
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -237,7 +236,7 @@  discard block
 block discarded – undo
237 236
       ob_start();
238 237
       print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}");
239 238
 
240
-      foreach($error_backtrace as $name => $value) {
239
+      foreach ($error_backtrace as $name => $value) {
241 240
         print('<hr>');
242 241
         pdump($value, $name);
243 242
       }
@@ -249,14 +248,14 @@  discard block
 block discarded – undo
249 248
   function warning($message, $title = 'System Message', $log_code = 300, $dump = false) {
250 249
     global $user, $lang, $sys_log_disabled;
251 250
 
252
-    if(empty(classSupernova::$db->connected)) {
251
+    if (empty(classSupernova::$db->connected)) {
253 252
       // TODO - писать ошибку в файл
254 253
       die('SQL server currently unavailable. Please contact Administration...');
255 254
     }
256 255
 
257 256
     $error_backtrace = $this->dump($dump, false);
258 257
 
259
-    if(!$sys_log_disabled) {
258
+    if (!$sys_log_disabled) {
260 259
       $query = "INSERT INTO `{{logs}}` SET
261 260
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "',
262 261
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -274,11 +273,11 @@  discard block
 block discarded – undo
274 273
 // Dump variables nicer then var_dump()
275 274
 
276 275
 function dump($value, $varname = null, $level = 0, $dumper = '') {
277
-  if(isset($varname)) {
276
+  if (isset($varname)) {
278 277
     $varname .= " = ";
279 278
   }
280 279
 
281
-  if($level == -1) {
280
+  if ($level == -1) {
282 281
     $trans[' '] = '&there4;';
283 282
     $trans["\t"] = '&rArr;';
284 283
     $trans["\n"] = '&para;;';
@@ -287,7 +286,7 @@  discard block
 block discarded – undo
287 286
 
288 287
     return strtr(htmlspecialchars($value), $trans);
289 288
   }
290
-  if($level == 0) {
289
+  if ($level == 0) {
291 290
 //    $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname;
292 291
     $dumper = mt_rand(10, 99) . '|' . $varname;
293 292
   }
@@ -295,22 +294,22 @@  discard block
 block discarded – undo
295 294
   $type = gettype($value);
296 295
   $dumper .= $type;
297 296
 
298
-  if($type == 'string') {
297
+  if ($type == 'string') {
299 298
     $dumper .= '(' . strlen($value) . ')';
300 299
     $value = dump($value, '', -1);
301
-  } elseif($type == 'boolean') {
300
+  } elseif ($type == 'boolean') {
302 301
     $value = ($value ? 'true' : 'false');
303
-  } elseif($type == 'object') {
302
+  } elseif ($type == 'object') {
304 303
     $props = get_class_vars(get_class($value));
305 304
     $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>';
306
-    foreach($props as $key => $val) {
305
+    foreach ($props as $key => $val) {
307 306
       $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => ';
308 307
       $dumper .= dump($value->$key, '', $level + 1);
309 308
     }
310 309
     $value = '';
311
-  } elseif($type == 'array') {
310
+  } elseif ($type == 'array') {
312 311
     $dumper .= '(' . count($value) . ')';
313
-    foreach($value as $key => $val) {
312
+    foreach ($value as $key => $val) {
314 313
       $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => ';
315 314
       $dumper .= dump($val, '', $level + 1);
316 315
     }
@@ -330,7 +329,7 @@  discard block
 block discarded – undo
330 329
 //  $backtrace = $backtrace[1];
331 330
 
332 331
   $caller = '';
333
-  if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
332
+  if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
334 333
     $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') .
335 334
       (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') .
336 335
       $backtrace[1]['function'] .
@@ -357,7 +356,7 @@  discard block
 block discarded – undo
357 356
 }
358 357
 
359 358
 function pr($prePrint = false) {
360
-  if($prePrint) {
359
+  if ($prePrint) {
361 360
     print("<br>");
362 361
   }
363 362
   print(mt_rand() . "<br>");
@@ -367,7 +366,7 @@  discard block
 block discarded – undo
367 366
   global $_PRINT_COUNT_VALUE;
368 367
   $_PRINT_COUNT_VALUE++;
369 368
 
370
-  if($prePrint) {
369
+  if ($prePrint) {
371 370
     print("<br>");
372 371
   }
373 372
   print($_PRINT_COUNT_VALUE . "<br>");
Please login to merge, or discard this patch.
includes/db/db_queries_users.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
     "SELECT `id` AS `ID`, `username` AS `NAME`, `ally_name` AS `ALLY`, `total_points` AS `STAT_POINTS`,
181 181
       `onlinetime` AS `ACTIVITY`
182 182
     FROM `{{users}}`
183
-    WHERE `onlinetime` >= ". (SN_TIME_NOW - $config->game_users_online_timeout) ." ORDER BY user_as_ally, `". $TypeSort ."` ASC;");
183
+    WHERE `onlinetime` >= ". (SN_TIME_NOW - $config->game_users_online_timeout) . " ORDER BY user_as_ally, `" . $TypeSort . "` ASC;");
184 184
 }
185 185
 
186 186
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
   return doquery("SELECT u.*, COUNT(r.id) AS referral_count, SUM(r.dark_matter) AS referral_dm FROM {{users}} as u
196 196
     LEFT JOIN {{referrals}} as r on r.id_partner = u.id
197 197
     WHERE" .
198
-    ($online ? " `onlinetime` >= ". (SN_TIME_NOW - $config->game_users_online_timeout) : ' user_as_ally IS NULL') .
198
+    ($online ? " `onlinetime` >= " . (SN_TIME_NOW - $config->game_users_online_timeout) : ' user_as_ally IS NULL') .
199 199
     " GROUP BY u.id
200 200
     ORDER BY user_as_ally, {$sort} ASC");
201 201
 }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
   !is_array($user_id_list) ? $user_id_list = array($user_id_list) : false;
212 212
 
213 213
   $user_list = array();
214
-  foreach($user_id_list as $user_id_unsafe) {
214
+  foreach ($user_id_list as $user_id_unsafe) {
215 215
     $user = db_user_by_id($user_id_unsafe);
216 216
     !empty($user) ? $user_list[$user_id_unsafe] = $user : false;
217 217
   }
Please login to merge, or discard this patch.
includes/includes/flt_page4.inc 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(SN_IN_FLEET !== true) {
3
+if (SN_IN_FLEET !== true) {
4 4
   $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
5 5
 }
6 6
 
7 7
 $fleetid = sys_get_param_id('fleetid');
8 8
 
9
-if(!is_numeric($fleetid) || empty($fleetid)) {
9
+if (!is_numeric($fleetid) || empty($fleetid)) {
10 10
   sys_redirect("fleet.php");
11 11
 }
12 12
 
13 13
 $fleet = db_fleet_get($fleetid);
14
-if(!$fleet) {
14
+if (!$fleet) {
15 15
   messageBox($lang['fl_fleet_not_exists'], $lang['fl_error']);
16 16
 }
17 17
 //$query = doquery("SELECT * FROM `{{fleets}}` WHERE fleet_id = '{$fleetid}'");
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
   messageBox($lang['fl_isback'], $lang['fl_error']);
26 26
 }
27 27
 
28
-if($fleet['fleet_owner'] != $user['id']) {
29
-  $debug->warning($lang['fl_aks_hack_wrong_fleet'],'Wrong Fleet Owner',301);
28
+if ($fleet['fleet_owner'] != $user['id']) {
29
+  $debug->warning($lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301);
30 30
   messageBox($lang['fl_aks_hack_wrong_fleet'], $lang['fl_error']);
31 31
 }
32 32
 
@@ -36,19 +36,19 @@  discard block
 block discarded – undo
36 36
 
37 37
 !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false;
38 38
 
39
-if($userToAdd_unsafe) {
39
+if ($userToAdd_unsafe) {
40 40
   $userToAdd = db_escape($userToAdd_unsafe);
41 41
   $userToAddID = db_user_by_username($userToAdd_unsafe, true);
42 42
   $userToAddID = $userToAddID['id'];
43 43
 
44
-  if($fleet['fleet_target_owner'] == $userToAddID) {
44
+  if ($fleet['fleet_target_owner'] == $userToAddID) {
45 45
     messageBox($lang['flt_aks_player_same'], $lang['fl_error']);
46 46
   }
47 47
 
48
-  if($userToAddID) {
49
-    if(!$aks) {
48
+  if ($userToAddID) {
49
+    if (!$aks) {
50 50
       // No AСS exists - making one
51
-      if(!$fleet['fleet_group']) {
51
+      if (!$fleet['fleet_group']) {
52 52
         doquery("INSERT INTO {{aks}} SET
53 53
           `name` = '" . db_escape($lang['flt_acs_prefix'] . $fleetid) . "',
54 54
           `teilnehmer` = '" . $user['id'] . "',
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
           `planet` = '" . $fleet['fleet_end_planet'] . "',
60 60
           `planet_type` = '" . $fleet['fleet_end_type'] . "',
61 61
           `eingeladen` = '" . $user['id'] . "',
62
-          `fleet_end_time` = '" . $fleet['fleet_end_time']. "'");
62
+          `fleet_end_time` = '" . $fleet['fleet_end_time'] . "'");
63 63
 
64 64
         $aks = doquery("SELECT * FROM {{aks}} WHERE `flotten` = {$fleetid} LIMIT 1;", true);
65 65
 
@@ -77,26 +77,26 @@  discard block
 block discarded – undo
77 77
 
78 78
     $isUserExists = false;
79 79
     $invited_ar = explode(",", $aks['eingeladen']);
80
-    foreach($invited_ar as $inv) {
80
+    foreach ($invited_ar as $inv) {
81 81
       if ($userToAddID == $inv) {
82 82
         $isUserExists = true;
83 83
       }
84 84
     }
85 85
 
86
-    if(count($invited_ar) >= 5) {
86
+    if (count($invited_ar) >= 5) {
87 87
       messageBox($lang['flt_aks_error_too_much_players'], $lang['fl_error']);
88 88
     }
89 89
 
90
-    if($isUserExists) {
90
+    if ($isUserExists) {
91 91
       $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf($lang['fl_aks_player_invited_already'], $userToAdd) : false;
92 92
     } else {
93 93
       $add_user_message_mr = sprintf($lang['fl_aks_player_invited'], $userToAdd);
94 94
       doquery("UPDATE `{{aks}}` SET `eingeladen` = concat(`eingeladen`, ',{$userToAddID}') WHERE `flotten` = {$fleetid};")
95
-        or die(sprintf($lang['fl_aks_adding_error'],db_error()));
95
+        or die(sprintf($lang['fl_aks_adding_error'], db_error()));
96 96
       $aks['eingeladen'] .= ',' . $userToAddID;
97 97
     }
98
-    msg_send_simple_message ( $userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'],
99
-      $lang['fl_aks_invite_message_header'], sprintf( $lang['fl_aks_invite_message'], $user['username']));
98
+    msg_send_simple_message($userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'],
99
+      $lang['fl_aks_invite_message_header'], sprintf($lang['fl_aks_invite_message'], $user['username']));
100 100
   } else {
101 101
     $add_user_message_mr = sprintf($lang['fl_aks_player_error'], $userToAdd);
102 102
   }
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
   'MISSION_NAME' => $lang['type_mission'][MT_AKS],
111 111
 ));
112 112
 
113
-if($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
114
-  foreach($members as $row) {
113
+if ($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
114
+  foreach ($members as $row) {
115 115
     $template->assign_block_vars('invited', array(
116 116
       'NAME' => $row['username'],
117 117
     ));
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 $i++;
122 122
 $fleet_row = db_fleet_get($fleetid);
123 123
 
124
-if(is_array($fleet_row) && !empty($fleet_row)) {
124
+if (is_array($fleet_row) && !empty($fleet_row)) {
125 125
 $planet_start = DBStaticPlanet::db_planet_by_id($fleet_row['fleet_start_planet_id']);
126 126
 $fleet_row['fleet_start_name'] = !empty($planet_start['name']) ? $planet_start['name'] : '';
127 127
 $planet_end = DBStaticPlanet::db_planet_by_id($fleet_row['fleet_end_planet_id']);
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 
130 130
 $fleet_data = tpl_parse_fleet_db($fleet_row, $i, $user);
131 131
 $template->assign_block_vars('fleets', $fleet_data['fleet']);
132
-foreach($fleet_data['ships'] as $ship_data) {
132
+foreach ($fleet_data['ships'] as $ship_data) {
133 133
   $template->assign_block_vars('fleets.ships', $ship_data);
134 134
 }
135 135
 }
Please login to merge, or discard this patch.
includes/includes/market_info.inc 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true)
3
+if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true)
4 4
 {
5 5
   $debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403);
6 6
 }
@@ -15,50 +15,50 @@  discard block
 block discarded – undo
15 15
 ));
16 16
 
17 17
 $info_action = sys_get_param_int('action');
18
-if($info_action)
18
+if ($info_action)
19 19
 {
20 20
   try
21 21
   {
22 22
     sn_db_transaction_start();
23 23
 
24 24
     $user = db_user_by_id($user['id'], true);
25
-    if(mrc_get_level($user, null, RES_DARK_MATTER) < $config->rpg_cost_info)
25
+    if (mrc_get_level($user, null, RES_DARK_MATTER) < $config->rpg_cost_info)
26 26
     {
27 27
       throw new Exception(MARKET_NO_DM, ERR_ERROR);
28 28
     }
29 29
 
30
-    switch($info_action)
30
+    switch ($info_action)
31 31
     {
32 32
       case MARKET_INFO_PLAYER:
33 33
         $user_info_name_unsafe = sys_get_param_str_unsafe('user_info_name');
34
-        if(!$user_info_name_unsafe)
34
+        if (!$user_info_name_unsafe)
35 35
         {
36 36
           throw new Exception(MARKET_INFO_PLAYER_WRONG, ERR_ERROR);
37 37
         }
38 38
 
39
-        if(is_id($user_info_name_unsafe))
39
+        if (is_id($user_info_name_unsafe))
40 40
         {
41 41
           $user_info = db_user_by_id($user_info_name_unsafe, true, '`id`, `username`', true);
42 42
         }
43
-        if(!is_array($user_info))
43
+        if (!is_array($user_info))
44 44
         {
45 45
           $user_info = db_user_by_username($user_info_name_unsafe, true);
46 46
         }
47
-        if(!is_array($user_info))
47
+        if (!is_array($user_info))
48 48
         {
49 49
           throw new Exception(MARKET_INFO_PLAYER_NOT_FOUND, ERR_ERROR);
50 50
         }
51
-        if($user_info['id'] == $user['id'])
51
+        if ($user_info['id'] == $user['id'])
52 52
         {
53 53
           throw new Exception(MARKET_INFO_PLAYER_SAME, ERR_ERROR);
54 54
         }
55 55
 
56 56
         $msg_text = array();
57
-        foreach(sn_get_groups('mercenaries') as $mercenary_id)
57
+        foreach (sn_get_groups('mercenaries') as $mercenary_id)
58 58
         {
59 59
           $msg_text[] = "{$lang['tech'][$mercenary_id]} - " . (($mercenary_level = mrc_get_level($user_info, false, $mercenary_id)) ? "{$lang['sys_level']} {$mercenary_level}" : $lang['eco_mrk_info_not_hired']);
60 60
         }
61
-        if($mercenary_level = mrc_get_level($user_info, false, UNIT_PREMIUM))
61
+        if ($mercenary_level = mrc_get_level($user_info, false, UNIT_PREMIUM))
62 62
         {
63 63
           $msg_text[] = "{$lang['tech'][UNIT_PREMIUM]} - {$mercenary_level} {$lang['sys_level']}";
64 64
         }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
       break;
73 73
     }
74 74
 
75
-    if(!rpg_points_change($user['id'], RPG_MARKET_INFO_MERCENARY, -$config->rpg_cost_info, "Using Black Market page {$lang['eco_mrk_info']} - getting info about user ID {$user_info['id']}"))
75
+    if (!rpg_points_change($user['id'], RPG_MARKET_INFO_MERCENARY, -$config->rpg_cost_info, "Using Black Market page {$lang['eco_mrk_info']} - getting info about user ID {$user_info['id']}"))
76 76
     {
77 77
       // TODO: throw new Exception(MARKET_INFO_PLAYER_SAME, ERR_ERROR);
78 78
     }
Please login to merge, or discard this patch.
buddy.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -18,39 +18,39 @@  discard block
 block discarded – undo
18 18
 {
19 19
   sn_db_transaction_start();
20 20
 
21
-  if($buddy_id = sys_get_param_id('buddy_id'))
21
+  if ($buddy_id = sys_get_param_id('buddy_id'))
22 22
   {
23 23
     $buddy_row = doquery("SELECT BUDDY_SENDER_ID, BUDDY_OWNER_ID, BUDDY_STATUS FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1 FOR UPDATE;", true);
24
-    if(!is_array($buddy_row))
24
+    if (!is_array($buddy_row))
25 25
     {
26 26
       throw new exception('buddy_err_not_exist', ERR_ERROR);
27 27
     }
28 28
 
29
-    switch($mode = sys_get_param_str('mode'))
29
+    switch ($mode = sys_get_param_str('mode'))
30 30
     {
31 31
       case 'accept':
32
-        if($buddy_row['BUDDY_SENDER_ID'] == $user['id'])
32
+        if ($buddy_row['BUDDY_SENDER_ID'] == $user['id'])
33 33
         {
34 34
           throw new exception('buddy_err_accept_own', ERR_ERROR);
35 35
         }
36 36
 
37
-        if($buddy_row['BUDDY_OWNER_ID'] != $user['id'])
37
+        if ($buddy_row['BUDDY_OWNER_ID'] != $user['id'])
38 38
         {
39 39
           throw new exception('buddy_err_accept_alien', ERR_ERROR);
40 40
         }
41 41
 
42
-        if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE)
42
+        if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE)
43 43
         {
44 44
           throw new exception('buddy_err_accept_already', ERR_WARNING);
45 45
         }
46 46
 
47
-        if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_DENIED)
47
+        if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_DENIED)
48 48
         {
49 49
           throw new exception('buddy_err_accept_denied', ERR_ERROR);
50 50
         }
51 51
 
52 52
         doquery("UPDATE {{buddy}} SET `BUDDY_STATUS` = " . BUDDY_REQUEST_ACTIVE . " WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;");
53
-        if(classSupernova::$db->db_affected_rows())
53
+        if (classSupernova::$db->db_affected_rows())
54 54
         {
55 55
           msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_accept_title'],
56 56
             sprintf($lang['buddy_msg_accept_text'], $user['username']));
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
       break;
65 65
 
66 66
       case 'delete':
67
-        if($buddy_row['BUDDY_SENDER_ID'] != $user['id'] && $buddy_row['BUDDY_OWNER_ID'] != $user['id'])
67
+        if ($buddy_row['BUDDY_SENDER_ID'] != $user['id'] && $buddy_row['BUDDY_OWNER_ID'] != $user['id'])
68 68
         {
69 69
           throw new exception('buddy_err_delete_alien', ERR_ERROR);
70 70
         }
71 71
 
72
-        if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship
72
+        if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship
73 73
         {
74 74
           $ex_friend_id = $buddy_row['BUDDY_SENDER_ID'] == $user['id'] ? $buddy_row['BUDDY_OWNER_ID'] : $buddy_row['BUDDY_SENDER_ID'];
75 75
 
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
           sn_db_transaction_commit();
81 81
           throw new exception('buddy_err_unfriend_none', ERR_NONE);
82 82
         }
83
-        elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting
83
+        elseif ($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting
84 84
         {
85 85
           doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;");
86 86
           sn_db_transaction_commit();
87 87
           throw new exception('buddy_err_delete_own', ERR_NONE);
88 88
         }
89
-        elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request
89
+        elseif ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request
90 90
         {
91 91
           msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_deny_title'],
92 92
             sprintf($lang['buddy_msg_deny_text'], $user['username']));
@@ -101,24 +101,24 @@  discard block
 block discarded – undo
101 101
 
102 102
   // New request?
103 103
   // Checking for user ID - in case if it was request from outside buddy system
104
-  if($new_friend_id = sys_get_param_id('request_user_id'))
104
+  if ($new_friend_id = sys_get_param_id('request_user_id'))
105 105
   {
106 106
     $new_friend_row = db_user_by_id($new_friend_id, true, '`id`, `username`');
107 107
   }
108
-  elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name'))
108
+  elseif ($new_friend_name = sys_get_param_str_unsafe('request_user_name'))
109 109
   {
110 110
     $new_friend_row = db_user_by_username($new_friend_name);
111 111
     $new_friend_name = db_escape($new_friend_name);
112 112
   }
113 113
 
114
-  if($new_friend_row['id'] == $user['id'])
114
+  if ($new_friend_row['id'] == $user['id'])
115 115
   {
116 116
     unset($new_friend_row);
117 117
     throw new exception('buddy_err_adding_self', ERR_ERROR);
118 118
   }
119 119
 
120 120
   // Checking for user name & request text - in case if it was request to adding new request
121
-  if(isset($new_friend_row['id']) && ($new_request_text = sys_get_param_str('request_text')))
121
+  if (isset($new_friend_row['id']) && ($new_request_text = sys_get_param_str('request_text')))
122 122
   {
123 123
     $check_relation = doquery("SELECT `BUDDY_ID` FROM {{buddy}} WHERE
124 124
       (`BUDDY_SENDER_ID` = {$user['id']} AND `BUDDY_OWNER_ID` = {$new_friend_row['id']})
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
       (`BUDDY_SENDER_ID` = {$new_friend_row['id']} AND `BUDDY_OWNER_ID` = {$user['id']})
127 127
       LIMIT 1 FOR UPDATE;"
128 128
     , true);
129
-    if(isset($check_relation['BUDDY_ID']))
129
+    if (isset($check_relation['BUDDY_ID']))
130 130
     {
131 131
       throw new exception('buddy_err_adding_exists', ERR_WARNING);
132 132
     }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     throw new exception('buddy_err_adding_none', ERR_NONE);
140 140
   }
141 141
 }
142
-catch(exception $e)
142
+catch (exception $e)
143 143
 {
144 144
   $result[] = array(
145 145
     'STATUS'  => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR,
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 sn_db_transaction_rollback();
151 151
 
152 152
 $query = db_buddy_list_by_user($user['id']);
153
-while($row = db_fetch($query))
153
+while ($row = db_fetch($query))
154 154
 {
155 155
   $row['BUDDY_REQUEST'] = HelperString::nl2br($row['BUDDY_REQUEST']);
156 156
 
Please login to merge, or discard this patch.
includes/functions/sys_maintenance.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
     array('query' => "DELETE FROM `{{planets}}` WHERE `id_owner` = 0 AND `destruyed` < UNIX_TIMESTAMP();", 'result' => false, 'error' => '', 'affected_rows' => 0),
18 18
   );
19 19
 
20
-  foreach($queries as &$query)
20
+  foreach ($queries as &$query)
21 21
   {
22 22
     $query['result'] = doquery($query['query']);
23 23
     $query['error']  = classSupernova::$db->db_error();
24
-    $query['affected_rows']  = classSupernova::$db->db_affected_rows();
24
+    $query['affected_rows'] = classSupernova::$db->db_affected_rows();
25 25
   }
26 26
 
27 27
   return $queries;
@@ -53,30 +53,30 @@  discard block
 block discarded – undo
53 53
   $recorded_run = strtotime($recorded_run);
54 54
 
55 55
   $prev_run_array = getdate($recorded_run);
56
-  $prev_run_array = array($prev_run_array['seconds'],$prev_run_array['minutes'],$prev_run_array['hours'],$prev_run_array['mday'],$prev_run_array['mon'],$prev_run_array['year']);
56
+  $prev_run_array = array($prev_run_array['seconds'], $prev_run_array['minutes'], $prev_run_array['hours'], $prev_run_array['mday'], $prev_run_array['mon'], $prev_run_array['year']);
57 57
   $today_array = getdate(SN_TIME_NOW);
58
-  $today_array = array($today_array['seconds'],$today_array['minutes'],$today_array['hours'],$today_array['mday'],$today_array['mon'],$today_array['year']);
58
+  $today_array = array($today_array['seconds'], $today_array['minutes'], $today_array['hours'], $today_array['mday'], $today_array['mon'], $today_array['year']);
59 59
   $scheduleList = explode(',', $scheduleList);
60 60
   array_walk($scheduleList, function(&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) {
61 61
     $schedule = array('schedule_array' => array_reverse(explode(':', trim($schedule))));
62 62
 
63 63
     $interval = $date_part_names_reverse[count($schedule['schedule_array'])];
64 64
 
65
-    foreach($prev_run_array as $index => $date_part) {
65
+    foreach ($prev_run_array as $index => $date_part) {
66 66
       $schedule['array']['recorded'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $date_part;
67 67
       $schedule['array']['now'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $today_array[$index];
68 68
     }
69
-    if($schedule['array']['recorded'] == $schedule['array']['now']) {
69
+    if ($schedule['array']['recorded'] == $schedule['array']['now']) {
70 70
       unset($schedule['array']['now']);
71 71
     }
72 72
 
73
-    foreach($schedule['array'] as $name => $array) {
73
+    foreach ($schedule['array'] as $name => $array) {
74 74
       $schedule['string'][$name] = "{$array[5]}-{$array[4]}-{$array[3]} {$array[2]}:{$array[1]}:{$array[0]}";
75 75
       $schedule['string'][$name . '_next'] = $schedule['string'][$name] . ' +1 ' . $interval;
76 76
       $schedule['string'][$name . '_prev'] = $schedule['string'][$name] . ' -1 ' . $interval;
77 77
     }
78 78
 
79
-    foreach($schedule['string'] as $string) {
79
+    foreach ($schedule['string'] as $string) {
80 80
       $timestamp = strtotime($string);
81 81
       $schedule['timestamp'][$timestamp] = $possible_schedules[$timestamp] = date(FMT_DATE_TIME_SQL, strtotime($string));
82 82
     }
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
   $prev_run = 0;
88 88
   $next_run = 0;
89
-  foreach($possible_schedules as $timestamp => $string_date) {
89
+  foreach ($possible_schedules as $timestamp => $string_date) {
90 90
     $prev_run = SN_TIME_NOW >= $timestamp ? $timestamp : $prev_run;
91 91
     $next_run = SN_TIME_NOW < $timestamp && !$next_run ? $timestamp : $next_run;
92 92
   }
Please login to merge, or discard this patch.
classes/OldDbChangeSet.php 1 patch
Spacing   +24 added lines, -26 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
    */
26 26
   public static function db_changeset_prepare_unit($unit_id, $unit_value, $user, $planet_id = null)
27 27
   {
28
-    if(!is_array($user))
28
+    if (!is_array($user))
29 29
     {
30 30
       // TODO - remove later
31 31
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: OldDbChangeSet::db_changeset_prepare_unit() - USER is not ARRAY</h1>');
32 32
       pdump(debug_backtrace());
33 33
       die('USER is not ARRAY');
34 34
     }
35
-    if(!isset($user['id']) || !$user['id'])
35
+    if (!isset($user['id']) || !$user['id'])
36 36
     {
37 37
       // TODO - remove later
38 38
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: OldDbChangeSet::db_changeset_prepare_unit() - USER[id] пустой</h1>');
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     $location_id = $location_id ? $location_id : 'NULL';
48 48
 
49 49
     $temp = DBStaticUnit::db_unit_by_location($user['id'], $unit_location, $location_id, $unit_id);
50
-    if(!empty($temp['unit_id']))
50
+    if (!empty($temp['unit_id']))
51 51
     {
52 52
       $db_changeset = array(
53 53
         'action' => SQL_OP_UPDATE,
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
   }
94 94
 
95 95
   public static function db_changeset_condition_compile(&$conditions, &$table_name = '') {
96
-    if(!$conditions[P_LOCATION] || $conditions[P_LOCATION] == LOC_NONE) {
96
+    if (!$conditions[P_LOCATION] || $conditions[P_LOCATION] == LOC_NONE) {
97 97
       $conditions[P_LOCATION] = LOC_NONE;
98
-      switch($table_name) {
98
+      switch ($table_name) {
99 99
         case 'users':
100 100
         case LOC_USER:
101 101
           $conditions[P_TABLE_NAME] = $table_name = 'users';
@@ -117,18 +117,18 @@  discard block
 block discarded – undo
117 117
     }
118 118
 
119 119
     $conditions[P_FIELDS_STR] = '';
120
-    if($conditions['fields']) {
120
+    if ($conditions['fields']) {
121 121
       $fields = array();
122
-      foreach($conditions['fields'] as $field_name => $field_data) {
122
+      foreach ($conditions['fields'] as $field_name => $field_data) {
123 123
         $condition = "`{$field_name}` = ";
124 124
         $value = '';
125
-        if($field_data['delta']) {
125
+        if ($field_data['delta']) {
126 126
           $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta'];
127
-        } elseif($field_data['set']) {
128
-          $value = (is_string($field_data['set']) ? "'{$field_data['set']}'": $field_data['set']);
127
+        } elseif ($field_data['set']) {
128
+          $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']);
129 129
         }
130 130
 
131
-        if($value) {
131
+        if ($value) {
132 132
           $fields[] = $condition . $value;
133 133
         }
134 134
       }
@@ -136,16 +136,14 @@  discard block
 block discarded – undo
136 136
     }
137 137
 
138 138
     $conditions[P_WHERE_STR] = '';
139
-    if(!empty($conditions['where'])) {
140
-      if($conditions[P_VERSION] == 1) {
139
+    if (!empty($conditions['where'])) {
140
+      if ($conditions[P_VERSION] == 1) {
141 141
         $the_conditions = array();
142
-        foreach($conditions['where'] as $field_id => $field_value) {
142
+        foreach ($conditions['where'] as $field_id => $field_value) {
143 143
           // Простое условие - $field_id = $field_value
144
-          if(is_string($field_id)) {
144
+          if (is_string($field_id)) {
145 145
             $field_value =
146
-              $field_value === null ? 'NULL' :
147
-                (is_string($field_value) ? "'" . db_escape($field_value) . "'" :
148
-                  (is_bool($field_value) ? intval($field_value) : $field_value));
146
+              $field_value === null ? 'NULL' : (is_string($field_value) ? "'" . db_escape($field_value) . "'" : (is_bool($field_value) ? intval($field_value) : $field_value));
149 147
             $the_conditions[] = "`{$field_id}` = {$field_value}";
150 148
           } else {
151 149
             die('Неподдерживаемый тип условия');
@@ -157,7 +155,7 @@  discard block
 block discarded – undo
157 155
       $conditions[P_WHERE_STR] = implode(' AND ', $the_conditions);
158 156
     }
159 157
 
160
-    switch($conditions['action']) {
158
+    switch ($conditions['action']) {
161 159
       case SQL_OP_DELETE: $conditions[P_ACTION_STR] = ("DELETE FROM {{{$table_name}}}"); break;
162 160
       case SQL_OP_UPDATE: $conditions[P_ACTION_STR] = ("UPDATE {{{$table_name}}} SET"); break;
163 161
       case SQL_OP_INSERT: $conditions[P_ACTION_STR] = ("INSERT INTO {{{$table_name}}} SET"); break;
@@ -176,17 +174,17 @@  discard block
 block discarded – undo
176 174
    */
177 175
   public static function db_changeset_apply($db_changeset) {
178 176
     $result = true;
179
-    if(!is_array($db_changeset) || empty($db_changeset)) return $result;
177
+    if (!is_array($db_changeset) || empty($db_changeset)) return $result;
180 178
 
181
-    foreach($db_changeset as $table_name => &$table_data) {
182
-      foreach($table_data as $record_id => &$conditions) {
179
+    foreach ($db_changeset as $table_name => &$table_data) {
180
+      foreach ($table_data as $record_id => &$conditions) {
183 181
         OldDbChangeSet::db_changeset_condition_compile($conditions, $table_name);
184 182
 
185
-        if($conditions['action'] != SQL_OP_DELETE && !$conditions[P_FIELDS_STR]) continue;
186
-        if($conditions['action'] == SQL_OP_DELETE && !$conditions[P_WHERE_STR]) continue; // Защита от случайного удаления всех данных в таблице
183
+        if ($conditions['action'] != SQL_OP_DELETE && !$conditions[P_FIELDS_STR]) continue;
184
+        if ($conditions['action'] == SQL_OP_DELETE && !$conditions[P_WHERE_STR]) continue; // Защита от случайного удаления всех данных в таблице
187 185
 
188
-        if($conditions[P_LOCATION] != LOC_NONE) {
189
-          switch($conditions['action'])
186
+        if ($conditions[P_LOCATION] != LOC_NONE) {
187
+          switch ($conditions['action'])
190 188
           {
191 189
             case SQL_OP_DELETE: $result = classSupernova::db_del_record_list($conditions[P_LOCATION], $conditions[P_WHERE_STR]) && $result; break;
192 190
             case SQL_OP_UPDATE: $result = classSupernova::db_upd_record_list($conditions[P_LOCATION], $conditions[P_WHERE_STR], $conditions[P_FIELDS_STR]) && $result; break;
Please login to merge, or discard this patch.