Passed
Push — master ( bc874f...230097 )
by SuperNova.WS
04:01
created
classes/debug.php 3 patches
Spacing   +38 added lines, -39 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;
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
     $result = array();
78 78
     $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++;
79 79
     $result[] = "tID {$transaction_id}";
80
-    foreach($backtrace as $a_trace) {
81
-      if(in_array($a_trace['function'], $exclude_functions)) {
80
+    foreach ($backtrace as $a_trace) {
81
+      if (in_array($a_trace['function'], $exclude_functions)) {
82 82
         continue;
83 83
       }
84 84
       $function =
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
       // $result[] = "{$function} ({$a_trace['line']})'{$file}'";
96 96
       $result[] = "{$function} - '{$file}' Line {$a_trace['line']}";
97 97
 
98
-      if(!$long_comment) {
98
+      if (!$long_comment) {
99 99
         break;
100 100
       }
101 101
     }
@@ -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;
@@ -135,26 +135,25 @@  discard block
 block discarded – undo
135 135
     }
136 136
 
137 137
 //    if($deadlock && ($q = db_fetch(classSupernova::$db->__db_query('SHOW ENGINE INNODB STATUS')))) {
138
-    if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
138
+    if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
139 139
       $error_backtrace['deadlock'] = explode("\n", $q['Status']);
140 140
       $error_backtrace['locks'] = classSupernova::$locks;
141 141
       $error_backtrace['cSN_data'] = classSupernova::$data;
142
-      foreach($error_backtrace['cSN_data'] as &$location) {
143
-        foreach($location as $location_id => &$location_data) //          $location_data = $location_id;
142
+      foreach ($error_backtrace['cSN_data'] as &$location) {
143
+        foreach ($location as $location_id => &$location_data) //          $location_data = $location_id;
144 144
         {
145
-          $location_data = isset($location_data['username']) ? $location_data['username'] :
146
-            (isset($location_data['name']) ? $location_data['name'] : $location_id);
145
+          $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id);
147 146
         }
148 147
       }
149 148
       $error_backtrace['cSN_queries'] = classSupernova::$queries;
150 149
     }
151 150
 
152
-    if($base_dump) {
153
-      if(is_array($this->log_array) && count($this->log_array) > 0) {
151
+    if ($base_dump) {
152
+      if (is_array($this->log_array) && count($this->log_array) > 0) {
154 153
         ;
155 154
       }
156 155
       {
157
-        foreach($this->log_array as $log) {
156
+        foreach ($this->log_array as $log) {
158 157
           $error_backtrace['queries'][] = $log;
159 158
         }
160 159
       }
@@ -185,14 +184,14 @@  discard block
 block discarded – undo
185 184
   function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) {
186 185
     global $config, $sys_stop_log_hit, $lang, $sys_log_disabled, $user;
187 186
 
188
-    if(empty(classSupernova::$db->connected)) {
187
+    if (empty(classSupernova::$db->connected)) {
189 188
       // TODO - писать ошибку в файл
190 189
       die('SQL server currently unavailable. Please contact Administration...');
191 190
     }
192 191
 
193 192
     sn_db_transaction_rollback();
194 193
 
195
-    if(classSupernova::$config->debug == 1) {
194
+    if (classSupernova::$config->debug == 1) {
196 195
       echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>";
197 196
       echo "<table>{$this->log}</table>";
198 197
     }
@@ -202,7 +201,7 @@  discard block
 block discarded – undo
202 201
     $error_text = db_escape($message);
203 202
     $error_backtrace = $this->dump($dump, true, strpos($message, 'Deadlock') !== false);
204 203
 
205
-    if(!$sys_log_disabled) {
204
+    if (!$sys_log_disabled) {
206 205
       $query = "INSERT INTO `{{logs}}` SET
207 206
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($user['id']) . "',
208 207
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -220,7 +219,7 @@  discard block
 block discarded – undo
220 219
       ob_start();
221 220
       print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}");
222 221
 
223
-      foreach($error_backtrace as $name => $value) {
222
+      foreach ($error_backtrace as $name => $value) {
224 223
         print('<hr>');
225 224
         pdump($value, $name);
226 225
       }
@@ -232,14 +231,14 @@  discard block
 block discarded – undo
232 231
   function warning($message, $title = 'System Message', $log_code = 300, $dump = false) {
233 232
     global $user, $lang, $sys_log_disabled;
234 233
 
235
-    if(empty(classSupernova::$db->connected)) {
234
+    if (empty(classSupernova::$db->connected)) {
236 235
       // TODO - писать ошибку в файл
237 236
       die('SQL server currently unavailable. Please contact Administration...');
238 237
     }
239 238
 
240 239
     $error_backtrace = $this->dump($dump, false);
241 240
 
242
-    if(!$sys_log_disabled) {
241
+    if (!$sys_log_disabled) {
243 242
       $query = "INSERT INTO `{{logs}}` SET
244 243
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($user['id']) . "',
245 244
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -257,11 +256,11 @@  discard block
 block discarded – undo
257 256
 // Dump variables nicer then var_dump()
258 257
 
259 258
 function dump($value, $varname = null, $level = 0, $dumper = '') {
260
-  if(isset($varname)) {
259
+  if (isset($varname)) {
261 260
     $varname .= " = ";
262 261
   }
263 262
 
264
-  if($level == -1) {
263
+  if ($level == -1) {
265 264
     $trans[' '] = '&there4;';
266 265
     $trans["\t"] = '&rArr;';
267 266
     $trans["\n"] = '&para;;';
@@ -270,7 +269,7 @@  discard block
 block discarded – undo
270 269
 
271 270
     return strtr(htmlspecialchars($value), $trans);
272 271
   }
273
-  if($level == 0) {
272
+  if ($level == 0) {
274 273
 //    $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname;
275 274
     $dumper = mt_rand(10, 99) . '|' . $varname;
276 275
   }
@@ -278,22 +277,22 @@  discard block
 block discarded – undo
278 277
   $type = gettype($value);
279 278
   $dumper .= $type;
280 279
 
281
-  if($type == 'string') {
280
+  if ($type == 'string') {
282 281
     $dumper .= '(' . strlen($value) . ')';
283 282
     $value = dump($value, '', -1);
284
-  } elseif($type == 'boolean') {
283
+  } elseif ($type == 'boolean') {
285 284
     $value = ($value ? 'true' : 'false');
286
-  } elseif($type == 'object') {
285
+  } elseif ($type == 'object') {
287 286
     $props = get_class_vars(get_class($value));
288 287
     $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>';
289
-    foreach($props as $key => $val) {
288
+    foreach ($props as $key => $val) {
290 289
       $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => ';
291 290
       $dumper .= dump($value->$key, '', $level + 1);
292 291
     }
293 292
     $value = '';
294
-  } elseif($type == 'array') {
293
+  } elseif ($type == 'array') {
295 294
     $dumper .= '(' . count($value) . ')';
296
-    foreach($value as $key => $val) {
295
+    foreach ($value as $key => $val) {
297 296
       $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => ';
298 297
       $dumper .= dump($val, '', $level + 1);
299 298
     }
@@ -313,7 +312,7 @@  discard block
 block discarded – undo
313 312
 //  $backtrace = $backtrace[1];
314 313
 
315 314
   $caller = '';
316
-  if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
315
+  if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
317 316
     $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') .
318 317
       (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') .
319 318
       $backtrace[1]['function'] .
@@ -340,7 +339,7 @@  discard block
 block discarded – undo
340 339
 }
341 340
 
342 341
 function pr($prePrint = false) {
343
-  if($prePrint) {
342
+  if ($prePrint) {
344 343
     print("<br>");
345 344
   }
346 345
   print(mt_rand() . "<br>");
@@ -350,7 +349,7 @@  discard block
 block discarded – undo
350 349
   global $_PRINT_COUNT_VALUE;
351 350
   $_PRINT_COUNT_VALUE++;
352 351
 
353
-  if($prePrint) {
352
+  if ($prePrint) {
354 353
     print("<br>");
355 354
   }
356 355
   print($_PRINT_COUNT_VALUE . "<br>");
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -140,11 +140,13 @@
 block discarded – undo
140 140
       $error_backtrace['locks'] = classSupernova::$locks;
141 141
       $error_backtrace['cSN_data'] = classSupernova::$data;
142 142
       foreach($error_backtrace['cSN_data'] as &$location) {
143
-        foreach($location as $location_id => &$location_data) //          $location_data = $location_id;
143
+        foreach($location as $location_id => &$location_data) {
144
+          //          $location_data = $location_id;
144 145
         {
145 146
           $location_data = isset($location_data['username']) ? $location_data['username'] :
146 147
             (isset($location_data['name']) ? $location_data['name'] : $location_id);
147 148
         }
149
+        }
148 150
       }
149 151
       $error_backtrace['cSN_queries'] = classSupernova::$queries;
150 152
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
 
77 77
     $result = array();
78 78
     $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++;
79
-    $result[] = "tID {$transaction_id}";
79
+    $result[] = "tid {$transaction_id}";
80 80
     foreach($backtrace as $a_trace) {
81 81
       if(in_array($a_trace['function'], $exclude_functions)) {
82 82
         continue;
Please login to merge, or discard this patch.
classes/userOptionsOld.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
     // Если в массиве индекса только один элемент - значит это просто индекс
79 79
     is_array($option_id) && count($option_id) == 1 ? $option_id = reset($option_id) : false;
80 80
 
81
-    if(!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) {
81
+    if (!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) {
82 82
       $this->load();
83 83
     }
84 84
 
85
-    if(is_array($option_id)) {
85
+    if (is_array($option_id)) {
86 86
       $result = $this->data;
87
-      foreach($option_id as $sub_key) {
88
-        if(!isset($result) || !isset($result[$sub_key])) {
87
+      foreach ($option_id as $sub_key) {
88
+        if (!isset($result) || !isset($result[$sub_key])) {
89 89
           $result = null;
90 90
           break;
91 91
         }
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
   public function __set($option, $value = null) {
106 106
     global $sn_cache;
107 107
 
108
-    if(empty($option) || !$this->user_id) {
108
+    if (empty($option) || !$this->user_id) {
109 109
       return;
110 110
     }
111 111
 
112 112
     // Если в массиве индекса только один элемент - значит это просто индекс
113
-    if(is_array($option) && count($option) == 1) {
113
+    if (is_array($option) && count($option) == 1) {
114 114
       // Разворачиваем его в индекс
115 115
       $option = array(reset($option) => $value);
116 116
       unset($value);
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 
120 120
     $to_write = array();
121 121
     // Адресация многомерного массива через массив индексов в $option
122
-    if(is_array($option) && isset($value)) {
122
+    if (is_array($option) && isset($value)) {
123 123
       $a_data = &$this->data;
124
-      foreach($option as $option_id) {
124
+      foreach ($option as $option_id) {
125 125
         !is_array($a_data[$option_id]) ? $a_data[$option_id] = array() : false;
126 126
         $a_data = &$a_data[$option_id];
127 127
       }
128
-      if($a_data != $value) {
128
+      if ($a_data != $value) {
129 129
         $a_data = $value;
130 130
         $to_write[reset($option)] = null;
131 131
       }
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
       // Пакетная запись из массива ключ -> значение
134 134
       !is_array($option) ? $option = array($option => $value) : false;
135 135
 
136
-      foreach($option as $option_id => $option_value) {
137
-        if($this->data[$option_id] !== $option_value) {
136
+      foreach ($option as $option_id => $option_value) {
137
+        if ($this->data[$option_id] !== $option_value) {
138 138
           // TODO - вынести отдельно в обработчик
139
-          if($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON &&  $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) {
139
+          if ($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) {
140 140
             sn_setcookie(SN_COOKIE . '_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE);
141 141
           }
142 142
 
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
       }
147 147
     }
148 148
 
149
-    if(!empty($to_write)) {
149
+    if (!empty($to_write)) {
150 150
       $field_name = $this->cached_name();
151 151
       $sn_cache->$field_name = $this->data;
152 152
 
153
-      foreach($to_write as $option_id => &$option_value) {
153
+      foreach ($to_write as $option_id => &$option_value) {
154 154
         $option_value = is_array($this->data[$option_id]) ? serialize($this->data[$option_id]) : $this->data[$option_id]; // Сериализация для массивов при сохранении в БД
155 155
         $to_write[$option_id] = "({$this->user_id}, '" . db_escape($option_id) . "', '" . db_escape($option_value) . "')";
156 156
       }
@@ -162,26 +162,26 @@  discard block
 block discarded – undo
162 162
   protected function load() {
163 163
     global $sn_cache;
164 164
 
165
-    if($this->loaded) {
165
+    if ($this->loaded) {
166 166
       return;
167 167
     }
168 168
 
169 169
     $this->data = $this->defaults;
170 170
 
171
-    if(!$this->user_id) {
171
+    if (!$this->user_id) {
172 172
       return;
173 173
     }
174 174
 
175 175
     $field_name = $this->cached_name();
176 176
     $a_data = $sn_cache->$field_name;
177 177
 
178
-    if(!empty($a_data)) {
178
+    if (!empty($a_data)) {
179 179
       $this->data = array_replace($this->data, $a_data);
180 180
       return;
181 181
     }
182 182
 
183 183
     $query = doquery("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE");
184
-    while($row = db_fetch($query)) {
184
+    while ($row = db_fetch($query)) {
185 185
       // $this->data[$row['option_id']] = $row['value'];
186 186
       $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация
187 187
     }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
     return $this->__get($offset);
198 198
   }
199 199
   public function offsetSet($offset, $value) {
200
-    if(!is_null($offset)) {
200
+    if (!is_null($offset)) {
201 201
       // $this->data[$offset] = $value;
202 202
       $this->__set($offset, $value);
203 203
     } else {
Please login to merge, or discard this patch.
flying_fleets.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2,9 +2,9 @@  discard block
 block discarded – undo
2 2
 
3 3
 include('common.' . substr(strrchr(__FILE__, '.'), 1));
4 4
 
5
-if(!empty($_POST['return']) && is_array($_POST['return'])) {
6
-  foreach($_POST['return'] as $fleet_id) {
7
-    if($fleet_id = idval($fleet_id)) {
5
+if (!empty($_POST['return']) && is_array($_POST['return'])) {
6
+  foreach ($_POST['return'] as $fleet_id) {
7
+    if ($fleet_id = idval($fleet_id)) {
8 8
       sn_db_transaction_start();
9 9
 //      $FleetRow = doquery("SELECT * FROM {{fleets}} WHERE `fleet_id` = '{$fleet_id}' LIMIT 1 FOR UPDATE;", true);
10 10
       $FleetRow = db_fleet_get($fleet_id);
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 lng_include('overview');
32 32
 lng_include('fleet');
33 33
 
34
-if(!$planetrow) {
34
+if (!$planetrow) {
35 35
   message($lang['fl_noplanetrow'], $lang['fl_error']);
36 36
 }
37 37
 
@@ -51,13 +51,13 @@  discard block
 block discarded – undo
51 51
 //}
52 52
 
53 53
 $fleet_list = fleet_list_by_owner_id($user['id']);
54
-foreach($fleet_list as $fleet_id => $fleet_row) {
54
+foreach ($fleet_list as $fleet_id => $fleet_row) {
55 55
   $i++;
56 56
   $fleet_data = tpl_parse_fleet_db($fleet_row, $i, $user);
57 57
 
58 58
   $template->assign_block_vars('fleets', $fleet_data['fleet']);
59 59
 
60
-  foreach($fleet_data['ships'] as $ship_data) {
60
+  foreach ($fleet_data['ships'] as $ship_data) {
61 61
     $template->assign_block_vars('fleets.ships', $ship_data);
62 62
   }
63 63
 }
Please login to merge, or discard this patch.
notes.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -15,34 +15,34 @@  discard block
 block discarded – undo
15 15
 $template = gettemplate('notes', true);
16 16
 
17 17
 $result = array();
18
-if(($result_message = sys_get_param_str('MESSAGE')) && isset($lang[$result_message])) {
18
+if (($result_message = sys_get_param_str('MESSAGE')) && isset($lang[$result_message])) {
19 19
   $result[] = array('STATUS' => sys_get_param_int('STATUS'), 'MESSAGE' => $lang[$result_message]);
20 20
 }
21 21
 
22 22
 $note_id_edit = sys_get_param_id('note_id_edit');
23
-if(sys_get_param('note_delete')) {
23
+if (sys_get_param('note_delete')) {
24 24
   try {
25 25
     $not = '';
26 26
     $query_where = '';
27
-    switch(sys_get_param_str('note_delete_range')) {
27
+    switch (sys_get_param_str('note_delete_range')) {
28 28
       case 'all':
29 29
       break;
30 30
 
31 31
       case 'marked_not':
32 32
         $not = 'NOT';
33 33
       case 'marked':
34
-        if(!is_array($notes_marked = sys_get_param('note'))) {
34
+        if (!is_array($notes_marked = sys_get_param('note'))) {
35 35
           throw new exception('note_err_none_selected', ERR_WARNING);
36 36
         }
37 37
 
38 38
         $notes_marked_filtered = array();
39
-        foreach($notes_marked as $note_id => $note_select) {
40
-          if($note_select == 'on' && $note_id = idval($note_id)) {
39
+        foreach ($notes_marked as $note_id => $note_select) {
40
+          if ($note_select == 'on' && $note_id = idval($note_id)) {
41 41
             $notes_marked_filtered[] = $note_id;
42 42
           }
43 43
         }
44 44
 
45
-        if(empty($notes_marked_filtered)) {
45
+        if (empty($notes_marked_filtered)) {
46 46
           throw new exception('note_err_none_selected', ERR_WARNING);
47 47
         }
48 48
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     doquery("DELETE FROM {{notes}} WHERE `owner` = {$user['id']} {$query_where};");
60 60
     sn_db_transaction_commit();
61 61
     throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE);
62
-  } catch(exception $e) {
62
+  } catch (exception $e) {
63 63
     $note_id_edit = 0;
64 64
     sn_db_transaction_rollback();
65 65
     $result[] = array(
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
       'MESSAGE' => $lang[$e->getMessage()],
68 68
     );
69 69
   }
70
-} elseif(($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) {
70
+} elseif (($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) {
71 71
   $note_title == db_escape($lang['note_new_title']) ? $note_title = '' : false;
72 72
   ($note_text = sys_get_param_str('note_text')) == db_escape($lang['note_new_text']) ? $note_text = '' : false;
73 73
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     $note_system = max(0, min(sys_get_param_id('note_system'), classSupernova::$config->game_maxSystem));
77 77
     $note_planet = max(0, min(sys_get_param_id('note_planet'), classSupernova::$config->game_maxPlanet + 1));
78 78
 
79
-    if(!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) {
79
+    if (!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) {
80 80
       throw new exception('note_err_note_empty', ERR_WARNING);
81 81
     }
82 82
 
@@ -85,15 +85,15 @@  discard block
 block discarded – undo
85 85
     $note_sticky = intval(sys_get_param_id('note_sticky')) ? 1 : 0;
86 86
 
87 87
     sn_db_transaction_start();
88
-    if($note_id_edit) {
88
+    if ($note_id_edit) {
89 89
       $check_note_id = doquery("SELECT `id`, `owner` FROM {{notes}} WHERE `id` = {$note_id_edit} LIMIT 1 FOR UPDATE", true);
90
-      if(!$check_note_id) {
90
+      if (!$check_note_id) {
91 91
         throw new exception('note_err_note_not_found', ERR_ERROR);
92 92
       }
93 93
     }
94 94
 
95
-    if($note_id_edit) {
96
-      if($check_note_id['owner'] != $user['id']) {
95
+    if ($note_id_edit) {
96
+      if ($check_note_id['owner'] != $user['id']) {
97 97
         throw new exception('note_err_owner_wrong', ERR_ERROR);
98 98
       }
99 99
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     sn_db_transaction_commit();
109 109
     sys_redirect('notes.php?STATUS=' . ERR_NONE . '&MESSAGE=' . ($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added'));
110 110
 //    throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE);
111
-  } catch(exception $e) {
111
+  } catch (exception $e) {
112 112
     $note_id_edit = 0;
113 113
     sn_db_transaction_rollback();
114 114
     $result[] = array(
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
   }
119 119
 }
120 120
 
121
-if(!$note_id_edit) {
121
+if (!$note_id_edit) {
122 122
   note_assign($template, array(
123 123
     'id' => 0,
124 124
     'time' => SN_TIME_NOW,
@@ -131,13 +131,13 @@  discard block
 block discarded – undo
131 131
 
132 132
 $note_exist = false;
133 133
 $notes_query = doquery("SELECT * FROM {{notes}} WHERE owner={$user['id']} ORDER BY priority DESC, galaxy ASC, system ASC, planet ASC, planet_type ASC, `time` DESC");
134
-while($note_row = db_fetch($notes_query)) {
134
+while ($note_row = db_fetch($notes_query)) {
135 135
   note_assign($template, $note_row);
136 136
   $note_exist = $note_exist || $note_row['id'] == $note_id_edit;
137 137
 }
138 138
 $note_id_edit = $note_exist ? $note_id_edit : 0;
139 139
 
140
-foreach($note_priority_classes as $note_priority_id => $note_priority_class) {
140
+foreach ($note_priority_classes as $note_priority_id => $note_priority_class) {
141 141
   $template->assign_block_vars('note_priority', array(
142 142
     'ID' => $note_priority_id,
143 143
     'CLASS' => $note_priority_classes[$note_priority_id],
@@ -145,14 +145,14 @@  discard block
 block discarded – undo
145 145
   ));
146 146
 }
147 147
 
148
-foreach($lang['sys_planet_type'] as $planet_type_id => $planet_type_string) {
148
+foreach ($lang['sys_planet_type'] as $planet_type_id => $planet_type_string) {
149 149
   $template->assign_block_vars('planet_type', array(
150 150
     'ID' => $planet_type_id,
151 151
     'TEXT' => $planet_type_string,
152 152
   ));
153 153
 }
154 154
 
155
-foreach($result as $result_data) {
155
+foreach ($result as $result_data) {
156 156
   $template->assign_block_vars('result', $result_data);
157 157
 }
158 158
 
Please login to merge, or discard this patch.
phalanx.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -18,17 +18,17 @@  discard block
 block discarded – undo
18 18
 
19 19
 $sensorLevel = mrc_get_level($user, $planetrow, STRUC_MOON_PHALANX);
20 20
 if (!intval($sensorLevel)) {
21
-  message ($lang['phalanx_nosensoravailable'], $lang['tech'][STRUC_MOON_PHALANX], '', 3);
21
+  message($lang['phalanx_nosensoravailable'], $lang['tech'][STRUC_MOON_PHALANX], '', 3);
22 22
 }
23 23
 
24 24
 if ($planetrow['planet_type'] != PT_MOON) {
25
-  message ($lang['phalanx_onlyformoons'], $lang['tech'][STRUC_MOON_PHALANX], '', 3);
25
+  message($lang['phalanx_onlyformoons'], $lang['tech'][STRUC_MOON_PHALANX], '', 3);
26 26
 }
27 27
 
28 28
 $scan_galaxy  = sys_get_param_int('galaxy');
29 29
 $scan_system  = sys_get_param_int('system');
30 30
 $scan_planet  = sys_get_param_int('planet');
31
-$scan_planet_type  = 1; // sys_get_param_int('planettype');
31
+$scan_planet_type = 1; // sys_get_param_int('planettype');
32 32
 $id = sys_get_param_id('id');
33 33
 
34 34
 $source_galaxy = $planetrow['galaxy'];
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 $sensorRange = GetPhalanxRange($sensorLevel);
39 39
 
40 40
 $system_distance = abs($source_system - $scan_system);
41
-if($system_distance > $sensorRange || $scan_galaxy != $source_galaxy)
41
+if ($system_distance > $sensorRange || $scan_galaxy != $source_galaxy)
42 42
 {
43
-  message ($lang['phalanx_rangeerror'], $lang['tech'][STRUC_MOON_PHALANX], '', 3);
43
+  message($lang['phalanx_rangeerror'], $lang['tech'][STRUC_MOON_PHALANX], '', 3);
44 44
 }
45 45
 
46 46
 $cost = $sensorLevel * 1000;
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 }
52 52
 
53 53
 $planet_scanned = DBStaticPlanet::db_planet_by_gspt($scan_galaxy, $scan_system, $scan_planet, $scan_planet_type);
54
-if(!$planet_scanned['id'])
54
+if (!$planet_scanned['id'])
55 55
 {
56 56
   message($lang['phalanx_planet_not_exists'], $lang['tech'][STRUC_MOON_PHALANX], '', 3);
57 57
 }
58 58
 
59
-if($planet_scanned['destruyed'])
59
+if ($planet_scanned['destruyed'])
60 60
 {
61
-  message ($lang['phalanx_planet_destroyed'], $lang['tech'][STRUC_MOON_PHALANX], '', 3);
61
+  message($lang['phalanx_planet_destroyed'], $lang['tech'][STRUC_MOON_PHALANX], '', 3);
62 62
 }
63 63
 
64 64
 DBStaticPlanet::db_planet_set_by_id($user['current_planet'], "deuterium = deuterium - {$cost}");
Please login to merge, or discard this patch.
blitz_register.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -2,12 +2,12 @@  discard block
 block discarded – undo
2 2
 
3 3
 include('common.' . substr(strrchr(__FILE__, '.'), 1));
4 4
 
5
-if($user['authlevel'] < AUTH_LEVEL_DEVELOPER) {
5
+if ($user['authlevel'] < AUTH_LEVEL_DEVELOPER) {
6 6
   $error_message = classSupernova::$config->game_mode == GAME_BLITZ ? 'sys_blitz_page_disabled' : (
7 7
     !classSupernova::$config->game_blitz_register ? 'sys_blitz_registration_disabled' : ''
8 8
   );
9 9
 
10
-  if($error_message) {
10
+  if ($error_message) {
11 11
     message($lang[$error_message], $lang['sys_error'], 'overview.php', 10);
12 12
     die();
13 13
   }
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
 $current_round = intval(classSupernova::$config->db_loadItem('game_blitz_register_round'));
18 18
 $current_price = intval(classSupernova::$config->db_loadItem('game_blitz_register_price'));
19 19
 
20
-if(classSupernova::$config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) {
20
+if (classSupernova::$config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) {
21 21
   sn_db_transaction_start();
22 22
   $user = db_user_by_id($user['id'], true);
23 23
   $is_registered = doquery("SELECT `id` FROM {{blitz_registrations}} WHERE `user_id` = {$user['id']} AND `round_number` = {$current_round} FOR UPDATE;", true);
24
-  if(sys_get_param_str('register_me')) {
25
-    if(empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) {
24
+  if (sys_get_param_str('register_me')) {
25
+    if (empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) {
26 26
       doquery("INSERT IGNORE INTO {{blitz_registrations}} SET `user_id` = {$user['id']}, `round_number` = {$current_round};");
27 27
       //mm_points_change($user['id'], RPG_BLITZ_REGISTRATION, -$current_price, "Регистрация в раунде {$current_round} Блица");
28 28
       classSupernova::$auth->account->metamatter_change(RPG_BLITZ_REGISTRATION, -$current_price, "Регистрация в раунде {$current_round} Блица");
@@ -43,17 +43,17 @@  discard block
 block discarded – undo
43 43
 $blitz_players = 0;
44 44
 $blitz_prize_dark_matter = 0;
45 45
 $blitz_prize_places = 0;
46
-if($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) {
47
-  if(sys_get_param_str('generate')) {
46
+if ($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) {
47
+  if (sys_get_param_str('generate')) {
48 48
     $next_id = 0;
49 49
     $query = doquery("SELECT `id` FROM {{blitz_registrations}} WHERE `round_number` = {$current_round} ORDER BY RAND();");
50
-    while($row = db_fetch($query)) {
50
+    while ($row = db_fetch($query)) {
51 51
       $next_id++;
52 52
       $blitz_name = 'Игрок' . $next_id;
53 53
       $blitz_password = sys_random_string(8);
54 54
       doquery("UPDATE {{blitz_registrations}} SET blitz_name = '{$blitz_name}', blitz_password = '{$blitz_password}' WHERE `id` = {$row['id']} AND `round_number` = {$current_round};");
55 55
     }
56
-  } elseif(sys_get_param_str('import_generated')) {
56
+  } elseif (sys_get_param_str('import_generated')) {
57 57
     // ЭТО НА БЛИЦЕ!!!
58 58
     doquery("DELETE FROM {{users}} WHERE username like 'Игрок%';");
59 59
     doquery("DELETE FROM {{planets}} WHERE id_owner not in (SELECT `id` FROM {{users}});");
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     $system = $system_step;
76 76
     $planet = round(classSupernova::$config->game_maxPlanet / 2);
77 77
 
78
-    foreach($imported_string as &$string_data) {
78
+    foreach ($imported_string as &$string_data) {
79 79
       $string_data = explode(',', $string_data);
80 80
       $username_safe = $string_data[0];
81 81
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
       $moon_row = uni_create_moon($galaxy, $system, $planet, $user_new['id'], 30, '', false);
97 97
 
98
-      if(($system += $system_step) >= classSupernova::$config->game_maxSystem) {
98
+      if (($system += $system_step) >= classSupernova::$config->game_maxSystem) {
99 99
         $galaxy++;
100 100
         $system = $system_step;
101 101
       }
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 
105 105
     classSupernova::$config->db_saveItem('users_amount', classSupernova::$config->users_amount + $new_players);
106 106
     // generated_string
107
-  } elseif(sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) {
107
+  } elseif (sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) {
108 108
     $blitz_result = explode(';', $blitz_result_string);
109 109
     $blitz_last_update = $blitz_result[0]; // Пока не используется
110 110
     unset($blitz_result[0]);
111
-    foreach($blitz_result as $blitz_result_data) {
111
+    foreach ($blitz_result as $blitz_result_data) {
112 112
       $blitz_result_data = explode(',', $blitz_result_data);
113
-      if(count($blitz_result_data) == 5) {
113
+      if (count($blitz_result_data) == 5) {
114 114
         $blitz_result_data[1] = db_escape($blitz_result_data[1]);
115 115
         doquery(
116 116
           "UPDATE `{{blitz_registrations}}` SET
@@ -124,15 +124,15 @@  discard block
 block discarded – undo
124 124
     $blitz_result = array();
125 125
   }
126 126
 
127
-  if(classSupernova::$config->game_mode == GAME_BLITZ) {
127
+  if (classSupernova::$config->game_mode == GAME_BLITZ) {
128 128
     $blitz_result = array(classSupernova::$config->db_loadItem('var_stat_update'));
129 129
     $query = doquery("SELECT id, username, total_rank, total_points, onlinetime FROM {{users}} ORDER BY `id`;");
130
-    while($row = db_fetch($query)) {
130
+    while ($row = db_fetch($query)) {
131 131
       $blitz_result[] = "{$row['id']},{$row['username']},{$row['onlinetime']},{$row['total_rank']},{$row['total_points']}";
132 132
     }
133 133
   } else {
134 134
     $query = doquery("SELECT blitz_name, blitz_password, blitz_online FROM {{blitz_registrations}} WHERE `round_number` = {$current_round} ORDER BY `id`;");
135
-    while($row = db_fetch($query)) {
135
+    while ($row = db_fetch($query)) {
136 136
       $blitz_generated[] = "{$row['blitz_name']},{$row['blitz_password']}";
137 137
       $row['blitz_online'] ? $blitz_prize_players_active++ : false;
138 138
       $blitz_players++;
@@ -147,13 +147,13 @@  discard block
 block discarded – undo
147 147
     'Игрок40'
148 148
     */
149 149
 
150
-    if(sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) {
150
+    if (sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) {
151 151
       // $blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter');
152 152
       $blitz_prize_places_actual = sys_get_param_int('blitz_prize_places');
153 153
       sn_db_transaction_start();
154 154
       $query = doquery("SELECT * FROM {{blitz_registrations}} WHERE `round_number` = {$current_round} ORDER BY `blitz_place` FOR UPDATE;");
155
-      while($row = db_fetch($query)) {
156
-        if(!$row['blitz_place']) {
155
+      while ($row = db_fetch($query)) {
156
+        if (!$row['blitz_place']) {
157 157
           continue;
158 158
         }
159 159
 
@@ -161,15 +161,15 @@  discard block
 block discarded – undo
161 161
         $blitz_prize_places_actual--;
162 162
 
163 163
         $reward = $blitz_prize_dark_matter_actual - $row['blitz_reward_dark_matter'];
164
-pdump("{{$row['id']}} {$row['blitz_name']}, Place {$row['blitz_place']}, Prize places {$blitz_prize_places_actual}, Prize {$reward}",$row['id']);
165
-        if($reward) {
164
+pdump("{{$row['id']}} {$row['blitz_name']}, Place {$row['blitz_place']}, Prize places {$blitz_prize_places_actual}, Prize {$reward}", $row['id']);
165
+        if ($reward) {
166 166
           rpg_points_change($row['user_id'], RPG_BLITZ, $reward, sprintf(
167 167
             $lang['sys_blitz_reward_log_message'], $row['blitz_place'], $row['blitz_name']
168 168
           ));
169 169
           doquery("UPDATE {{blitz_registrations}} SET blitz_reward_dark_matter = blitz_reward_dark_matter + ($reward) WHERE id = {$row['id']} AND `round_number` = {$current_round};");
170 170
         }
171 171
 
172
-        if(!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) {
172
+        if (!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) {
173 173
           break;
174 174
         }
175 175
       }
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
     JOIN {{users}} AS u ON u.id = br.user_id
190 190
   WHERE br.`round_number` = {$current_round}
191 191
   order by `blitz_place`, `timestamp`;");
192
-while($row = db_fetch($query)) {
192
+while ($row = db_fetch($query)) {
193 193
   $tpl_player_data = array(
194 194
     'NAME' => player_nick_render_to_html($row, array('icons' => true, 'color' => true, 'ally' => true)),
195 195
   );
196 196
 
197
-  if(classSupernova::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) {
197
+  if (classSupernova::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) {
198 198
     // Вот так хитро, что бы не было не единого шанса попадания на страницу данных об игроках Блиц-сервера до закрытия раунда
199 199
     $tpl_player_data = array_merge($tpl_player_data, array(
200 200
       'ID' => $row['id'],
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
   }
208 208
 
209 209
   $template->assign_block_vars('registrations', $tpl_player_data);
210
-  if($row['id'] == $user['id']) {
210
+  if ($row['id'] == $user['id']) {
211 211
     $player_registered = $row;
212 212
   }
213 213
 }
Please login to merge, or discard this patch.
fleet.php 2 patches
Switch Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -73,121 +73,121 @@  discard block
 block discarded – undo
73 73
 }
74 74
 
75 75
 switch ($fleet_page) {
76
-  case 3:
76
+    case 3:
77 77
 
78
-  case 2:
79
-    $fleet_group_mr = sys_get_param_id('fleet_group');
80
-    $fleetarray     = unserialize(base64_decode(str_rot13(sys_get_param('usedfleet'))));
81
-    $fleetarray = is_array($fleetarray) ? $fleetarray : array();
78
+    case 2:
79
+      $fleet_group_mr = sys_get_param_id('fleet_group');
80
+      $fleetarray     = unserialize(base64_decode(str_rot13(sys_get_param('usedfleet'))));
81
+      $fleetarray = is_array($fleetarray) ? $fleetarray : array();
82 82
 
83
-    foreach($fleetarray as $ship_id => &$ship_amount) {
84
-      if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) {
85
-        $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true));
86
-        die();
87
-      }
88
-      $ship_amount = floatval($ship_amount);
89
-    }
90
-
91
-    $UsedPlanet = false;
92
-    $YourPlanet = false;
93
-    $missiontype = array();
94
-    if ($planet > classSupernova::$config->game_maxPlanet) {
95
-      $target_mission = MT_EXPLORE;
96
-      $missiontype[MT_EXPLORE] = $lang['type_mission'][MT_EXPLORE];
97
-    } elseif ($galaxy && $system && $planet) {
98
-      $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET;
99
-
100
-      $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type);
101
-
102
-      if ($TargetPlanet['id_owner']) {
103
-        $UsedPlanet = true;
104
-        if ($TargetPlanet['id_owner'] == $user['id']) {
105
-          $YourPlanet = true;
83
+      foreach($fleetarray as $ship_id => &$ship_amount) {
84
+        if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) {
85
+          $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true));
86
+          die();
106 87
         }
88
+        $ship_amount = floatval($ship_amount);
107 89
       }
108 90
 
109
-      if (!$UsedPlanet) {
110
-        if ($fleetarray[SHIP_COLONIZER]) {
111
-          $missiontype[MT_COLONIZE] = $lang['type_mission'][MT_COLONIZE];
112
-          $target_mission = MT_COLONIZE;
113
-          $planet_type = PT_PLANET;
114
-        } else {
115
-          message ("<font color=\"red\"><b>". $lang['fl_no_planet_type'] ."</b></font>", $lang['fl_error']);
116
-        }
117
-      } else {
118
-        $recyclers = 0;
119
-        foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
120
-          $recyclers += $fleetarray[$recycler_id];
91
+      $UsedPlanet = false;
92
+      $YourPlanet = false;
93
+      $missiontype = array();
94
+      if ($planet > classSupernova::$config->game_maxPlanet) {
95
+        $target_mission = MT_EXPLORE;
96
+        $missiontype[MT_EXPLORE] = $lang['type_mission'][MT_EXPLORE];
97
+      } elseif ($galaxy && $system && $planet) {
98
+        $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET;
99
+
100
+        $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type);
101
+
102
+        if ($TargetPlanet['id_owner']) {
103
+          $UsedPlanet = true;
104
+          if ($TargetPlanet['id_owner'] == $user['id']) {
105
+            $YourPlanet = true;
106
+          }
121 107
         }
122
-        if ($recyclers > 0 && $planet_type == PT_DEBRIS) {
123
-          $target_mission = MT_RECYCLE;
124
-          $missiontype[MT_RECYCLE] = $lang['type_mission'][MT_RECYCLE];
125
-        } elseif ($planet_type == PT_PLANET || $planet_type == PT_MOON) {
126
-          if ($YourPlanet) {
127
-            $missiontype[MT_RELOCATE] = $lang['type_mission'][MT_RELOCATE];
128
-            $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT];
108
+
109
+        if (!$UsedPlanet) {
110
+          if ($fleetarray[SHIP_COLONIZER]) {
111
+            $missiontype[MT_COLONIZE] = $lang['type_mission'][MT_COLONIZE];
112
+            $target_mission = MT_COLONIZE;
113
+            $planet_type = PT_PLANET;
129 114
           } else {
130
-            // Not Your Planet
131
-            if ($fleetarray[SHIP_SPY]) {
132
-              // Only spy missions if any spy
133
-              $missiontype[MT_SPY] = $lang['type_mission'][MT_SPY];
115
+            message ("<font color=\"red\"><b>". $lang['fl_no_planet_type'] ."</b></font>", $lang['fl_error']);
116
+          }
117
+        } else {
118
+          $recyclers = 0;
119
+          foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
120
+            $recyclers += $fleetarray[$recycler_id];
121
+          }
122
+          if ($recyclers > 0 && $planet_type == PT_DEBRIS) {
123
+            $target_mission = MT_RECYCLE;
124
+            $missiontype[MT_RECYCLE] = $lang['type_mission'][MT_RECYCLE];
125
+          } elseif ($planet_type == PT_PLANET || $planet_type == PT_MOON) {
126
+            if ($YourPlanet) {
127
+              $missiontype[MT_RELOCATE] = $lang['type_mission'][MT_RELOCATE];
128
+              $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT];
134 129
             } else {
135
-              // If no spies...
136
-              if ($fleet_group_mr) {
137
-                $missiontype[MT_AKS] = $lang['type_mission'][MT_AKS];
130
+              // Not Your Planet
131
+              if ($fleetarray[SHIP_SPY]) {
132
+                // Only spy missions if any spy
133
+                $missiontype[MT_SPY] = $lang['type_mission'][MT_SPY];
138 134
               } else {
139
-                $missiontype[MT_ATTACK] = $lang['type_mission'][MT_ATTACK];
140
-                $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT];
141
-
142
-                $missiontype[MT_HOLD] = $lang['type_mission'][MT_HOLD];
143
-
144
-                if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) {
145
-                  $missiontype[MT_DESTROY] = $lang['type_mission'][MT_DESTROY];
135
+                // If no spies...
136
+                if ($fleet_group_mr) {
137
+                  $missiontype[MT_AKS] = $lang['type_mission'][MT_AKS];
138
+                } else {
139
+                  $missiontype[MT_ATTACK] = $lang['type_mission'][MT_ATTACK];
140
+                  $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT];
141
+
142
+                  $missiontype[MT_HOLD] = $lang['type_mission'][MT_HOLD];
143
+
144
+                  if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) {
145
+                    $missiontype[MT_DESTROY] = $lang['type_mission'][MT_DESTROY];
146
+                  }
146 147
                 }
147 148
               }
148 149
             }
149 150
           }
150 151
         }
151 152
       }
152
-    }
153
-
154
-    if (!$target_mission && is_array($missiontype)) {
155
-      $target_mission = MT_ATTACK;
156
-    }
157
-
158
-//    $sn_group_missions = sn_get_groups('missions');
159
-//    foreach($sn_group_missions as $mission_id => $cork) {
160
-//      $missiontype[$mission_id] = $lang['type_mission'][$mission_id];
161
-//    }
162
-//
163
-//
164
-    ksort($missiontype);
165
-
166
-    $speed_percent = sys_get_param_int('speed', 10);
167
-    $travel_data   = flt_travel_data($user, $planetrow, array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet), $fleetarray, $speed_percent);
168
-
169
-//    $fleet_speed   = flt_fleet_speed($user, $fleetarray);
170
-    $fleet_speed   = $travel_data['fleet_speed'];
171
-    $distance      = $travel_data['distance'];
172
-    $duration      = $travel_data['duration'];
173
-    $consumption   = $travel_data['consumption'];
174
-  // No Break
175
-
176
-  case 1:
177
-    if ($galaxy && $system && $planet) {
178
-      $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET;
179
-
180
-      $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type);
181
-    }
182
-
183
-  case 0:
184
-    $template_result += array(
185
-      'thisgalaxy'      => $planetrow['galaxy'],
186
-      'thissystem'      => $planetrow['system'],
187
-      'thisplanet'      => $planetrow['planet'],
188
-      'thisplanet_type' => $planetrow['planet_type'],
189
-    );
190
-  // no break
153
+
154
+      if (!$target_mission && is_array($missiontype)) {
155
+        $target_mission = MT_ATTACK;
156
+      }
157
+
158
+  //    $sn_group_missions = sn_get_groups('missions');
159
+  //    foreach($sn_group_missions as $mission_id => $cork) {
160
+  //      $missiontype[$mission_id] = $lang['type_mission'][$mission_id];
161
+  //    }
162
+  //
163
+  //
164
+      ksort($missiontype);
165
+
166
+      $speed_percent = sys_get_param_int('speed', 10);
167
+      $travel_data   = flt_travel_data($user, $planetrow, array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet), $fleetarray, $speed_percent);
168
+
169
+  //    $fleet_speed   = flt_fleet_speed($user, $fleetarray);
170
+      $fleet_speed   = $travel_data['fleet_speed'];
171
+      $distance      = $travel_data['distance'];
172
+      $duration      = $travel_data['duration'];
173
+      $consumption   = $travel_data['consumption'];
174
+    // No Break
175
+
176
+    case 1:
177
+      if ($galaxy && $system && $planet) {
178
+        $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET;
179
+
180
+        $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type);
181
+      }
182
+
183
+    case 0:
184
+      $template_result += array(
185
+        'thisgalaxy'      => $planetrow['galaxy'],
186
+        'thissystem'      => $planetrow['system'],
187
+        'thisplanet'      => $planetrow['planet'],
188
+        'thisplanet_type' => $planetrow['planet_type'],
189
+      );
190
+    // no break
191 191
 
192 192
 }
193 193
 
@@ -209,31 +209,31 @@  discard block
 block discarded – undo
209 209
 }
210 210
 
211 211
 switch($fleet_page) {
212
-  case 1:
213
-    require('includes/includes/flt_page1.inc');
214
-  break;
212
+    case 1:
213
+      require('includes/includes/flt_page1.inc');
214
+    break;
215 215
 
216
-  case 2:
217
-    require_once('includes/includes/flt_page2.inc');
218
-    sn_fleet_page2();
219
-  break;
216
+    case 2:
217
+      require_once('includes/includes/flt_page2.inc');
218
+      sn_fleet_page2();
219
+    break;
220 220
 
221
-  case 3:
222
-    require_once('includes/includes/flt_page3.inc');
223
-    sn_fleet_page3();
224
-  break;
221
+    case 3:
222
+      require_once('includes/includes/flt_page3.inc');
223
+      sn_fleet_page3();
224
+    break;
225 225
 
226
-  case 4:
227
-    require('includes/includes/flt_page4.inc');
228
-  break;
226
+    case 4:
227
+      require('includes/includes/flt_page4.inc');
228
+    break;
229 229
 
230
-  case 5:
231
-    require('includes/includes/flt_page5.inc');
232
-  break;
230
+    case 5:
231
+      require('includes/includes/flt_page5.inc');
232
+    break;
233 233
 
234
-  default:
235
-    define('SN_RENDER_NAVBAR_PLANET', true);
234
+    default:
235
+      define('SN_RENDER_NAVBAR_PLANET', true);
236 236
 
237
-    require('includes/includes/flt_page0.inc');
238
-  break;
237
+      require('includes/includes/flt_page0.inc');
238
+    break;
239 239
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 $planet = sys_get_param_int('planet', $planetrow['planet']);
40 40
 
41 41
 $target_mission = sys_get_param_int('target_mission');
42
-if($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) {
42
+if ($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) {
43 43
   $planet_type = PT_PLANET;
44
-} elseif($target_mission == MT_RECYCLE) {
44
+} elseif ($target_mission == MT_RECYCLE) {
45 45
   $planet_type = PT_DEBRIS;
46
-} elseif($target_mission == MT_DESTROY) {
46
+} elseif ($target_mission == MT_DESTROY) {
47 47
   $planet_type = PT_MOON;
48 48
 } else {
49 49
   $planet_type = sys_get_param_int('planet_type');
@@ -59,15 +59,15 @@  discard block
 block discarded – undo
59 59
 //$FlyingFleets = doquery("SELECT COUNT(fleet_id) as Number FROM {{fleets}} WHERE `fleet_owner`='{$user['id']}'", true);
60 60
 //$FlyingFleets = $FlyingFleets['Number'];
61 61
 $FlyingFleets = fleet_count_flying($user['id']);
62
-if($MaxFleets <= $FlyingFleets && $fleet_page && $fleet_page != 4) {
62
+if ($MaxFleets <= $FlyingFleets && $fleet_page && $fleet_page != 4) {
63 63
   message($lang['fl_noslotfree'], $lang['fl_error'], "fleet." . PHP_EX, 5);
64 64
 }
65 65
 
66 66
 $MaxExpeditions = get_player_max_expeditons($user);
67
-if($MaxExpeditions) {
67
+if ($MaxExpeditions) {
68 68
 //  $FlyingExpeditions  = doquery("SELECT COUNT(fleet_owner) AS `expedi` FROM {{fleets}} WHERE `fleet_owner` = {$user['id']} AND `fleet_mission` = '" . MT_EXPLORE . "';", '', true);
69 69
 //  $FlyingExpeditions  = $FlyingExpeditions['expedi'];
70
-  $FlyingExpeditions  = fleet_count_flying($user['id'], MT_EXPLORE);
70
+  $FlyingExpeditions = fleet_count_flying($user['id'], MT_EXPLORE);
71 71
 } else {
72 72
   $FlyingExpeditions = 0;
73 73
 }
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
     $fleetarray     = unserialize(base64_decode(str_rot13(sys_get_param('usedfleet'))));
81 81
     $fleetarray = is_array($fleetarray) ? $fleetarray : array();
82 82
 
83
-    foreach($fleetarray as $ship_id => &$ship_amount) {
84
-      if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) {
83
+    foreach ($fleetarray as $ship_id => &$ship_amount) {
84
+      if (!in_array($ship_id, sn_get_groups('fleet')) || (string) floatval($ship_amount) != $ship_amount || $ship_amount < 1) {
85 85
         $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true));
86 86
         die();
87 87
       }
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
           $target_mission = MT_COLONIZE;
113 113
           $planet_type = PT_PLANET;
114 114
         } else {
115
-          message ("<font color=\"red\"><b>". $lang['fl_no_planet_type'] ."</b></font>", $lang['fl_error']);
115
+          message("<font color=\"red\"><b>" . $lang['fl_no_planet_type'] . "</b></font>", $lang['fl_error']);
116 116
         }
117 117
       } else {
118 118
         $recyclers = 0;
119
-        foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
119
+        foreach (sn_get_groups('flt_recyclers') as $recycler_id) {
120 120
           $recyclers += $fleetarray[$recycler_id];
121 121
         }
122 122
         if ($recyclers > 0 && $planet_type == PT_DEBRIS) {
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 
142 142
                 $missiontype[MT_HOLD] = $lang['type_mission'][MT_HOLD];
143 143
 
144
-                if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) {
144
+                if ($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) {
145 145
                   $missiontype[MT_DESTROY] = $lang['type_mission'][MT_DESTROY];
146 146
                 }
147 147
               }
@@ -201,14 +201,14 @@  discard block
 block discarded – undo
201 201
 );
202 202
 
203 203
 $is_transport_missions = false;
204
-if($missiontype) {
204
+if ($missiontype) {
205 205
   $sn_group_missions = sn_get_groups('missions');
206
-  foreach($missiontype as $mission_data_id => $mission_data) {
206
+  foreach ($missiontype as $mission_data_id => $mission_data) {
207 207
     $is_transport_missions = $is_transport_missions || (isset($sn_group_missions[$mission_data_id]['transport']) && $sn_group_missions[$mission_data_id]['transport']);
208 208
   }
209 209
 }
210 210
 
211
-switch($fleet_page) {
211
+switch ($fleet_page) {
212 212
   case 1:
213 213
     require('includes/includes/flt_page1.inc');
214 214
   break;
Please login to merge, or discard this patch.
includes/alliance/ali_internal_admin_diplomacy.inc 2 patches
Spacing   +19 added lines, -19 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_ALLY') || SN_IN_ALLY !== true)
3
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)
4 4
 {
5 5
   $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
6 6
 }
@@ -14,28 +14,28 @@  discard block
 block discarded – undo
14 14
 
15 15
 $ally_name_safe = db_escape($user['ally_name']);
16 16
 
17
-if(sys_get_param_str('ali_dip_offer_make'))
17
+if (sys_get_param_str('ali_dip_offer_make'))
18 18
 {
19 19
   $alliance_negotiation_relation = sys_get_param_str('alliance_negotiation_relation');
20
-  if(!array_key_exists($alliance_negotiation_relation, $sn_diplomacy_relation_list))
20
+  if (!array_key_exists($alliance_negotiation_relation, $sn_diplomacy_relation_list))
21 21
   {
22 22
     message($lang['ali_dip_err_wrong_offer'], $page_title);
23 23
   }
24 24
 
25 25
   $alliance_negotiation_contr_ally_id = sys_get_param_id('alliance_negotiation_contr_ally_id');
26
-  if($alliance_negotiation_contr_ally_id == $user['ally_id'])
26
+  if ($alliance_negotiation_contr_ally_id == $user['ally_id'])
27 27
   {
28 28
     message($lang['ali_dip_err_same_ally'], $page_title);
29 29
   }
30 30
 
31 31
   $contr_ally_row = doquery("SELECT `ally_name` FROM {{alliance}} WHERE `id` = {$alliance_negotiation_contr_ally_id} LIMIT 1;", '', true);
32
-  if(!$contr_ally_row)
32
+  if (!$contr_ally_row)
33 33
   {
34 34
     message($lang['ali_dip_err_no_ally'], $page_title);
35 35
   }
36 36
 
37 37
   $relation_current_id = ali_relation($user['ally_id'], $alliance_negotiation_contr_ally_id);
38
-  if($alliance_negotiation_relation == $relation_current_id)
38
+  if ($alliance_negotiation_relation == $relation_current_id)
39 39
   {
40 40
     message(sprintf($lang['ali_dip_err_offer_same'], $lang['ali_dip_relations'][$alliance_negotiation_relation]), $page_title);
41 41
   }
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
   $relation_new = $sn_diplomacy_relation_list[$alliance_negotiation_relation];
49 49
   $relation_current = $sn_diplomacy_relation_list[$relation_current_id];
50
-  if($relation_new['enter_delay'] == -1 || $relation_current['exit_delay'] == -1)
50
+  if ($relation_new['enter_delay'] == -1 || $relation_current['exit_delay'] == -1)
51 51
   {
52 52
     sn_db_perform('{{alliance_negotiation}}',
53 53
       array(
@@ -79,39 +79,39 @@  discard block
 block discarded – undo
79 79
 else
80 80
 {
81 81
   $offer_id = sys_get_param_id('offer_id');
82
-  if($offer_id)
82
+  if ($offer_id)
83 83
   {
84 84
     $offer_answer = sys_get_param_str('answer');
85 85
 
86 86
     $negotiation = doquery("SELECT * FROM {{alliance_negotiation}} WHERE alliance_negotiation_id = {$offer_id} LIMIT 1;", '', true);
87
-    if(!$negotiation)
87
+    if (!$negotiation)
88 88
     {
89 89
       message($lang['ali_dip_err_offer_none'], $page_title);
90 90
     }
91
-    elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id'])
91
+    elseif ($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id'])
92 92
     {
93 93
       // TODO: Add log of hack attempt
94 94
       message($lang['ali_dip_err_offer_alien'], $page_title);
95 95
     }
96
-    elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id'])
96
+    elseif ($negotiation['alliance_negotiation_ally_id'] == $user['ally_id'])
97 97
     {
98
-      if($offer_answer == 'accept')
98
+      if ($offer_answer == 'accept')
99 99
       {
100 100
         // TODO: Add log of hack attempt
101 101
         message($lang['ali_dip_err_offer_accept_own'], $page_title);
102 102
       }
103
-      elseif($offer_answer == 'deny')
103
+      elseif ($offer_answer == 'deny')
104 104
       {
105 105
         doquery("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_id = {$offer_id} LIMIT 1;");
106 106
       }
107 107
     }
108 108
     else
109 109
     {
110
-      if($offer_answer == 'accept')
110
+      if ($offer_answer == 'accept')
111 111
       {
112 112
         $accept_offer = true;
113 113
       }
114
-      elseif($offer_answer == 'deny')
114
+      elseif ($offer_answer == 'deny')
115 115
       {
116 116
         DBStaticAlly::db_ally_negotiation_update_status_1($offer_id);
117 117
       }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
   }
120 120
 }
121 121
 
122
-if($accept_offer)
122
+if ($accept_offer)
123 123
 {
124 124
   sn_db_transaction_start();
125 125
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
   sn_db_transaction_commit();
156 156
 }
157 157
 
158
-foreach($sn_diplomacy_relation_list as $diplomacy_relation_id => $diplomacy_relation)
158
+foreach ($sn_diplomacy_relation_list as $diplomacy_relation_id => $diplomacy_relation)
159 159
 {
160 160
   $template->assign_block_vars('relation', array(
161 161
     'ID'   => $diplomacy_relation_id,
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 }
165 165
 
166 166
 $query = doquery("SELECT id, ally_name, ally_tag FROM {{alliance}} WHERE `id` != {$user['ally_id']} ORDER BY ally_name;");
167
-while($alliance = db_fetch($query))
167
+while ($alliance = db_fetch($query))
168 168
 {
169 169
   $template->assign_block_vars('alliance', array(
170 170
     'ID'   => $alliance['id'],
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
   WHERE
184 184
     alliance_negotiation_ally_id = {$user['ally_id']} OR alliance_negotiation_contr_ally_id = {$user['ally_id']};"
185 185
 );
186
-while($offer = db_fetch($query))
186
+while ($offer = db_fetch($query))
187 187
 {
188 188
   $template->assign_block_vars('offer', array(
189 189
     'ID'       => $offer['alliance_negotiation_id'],
Please login to merge, or discard this patch.
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -63,8 +63,7 @@  discard block
 block discarded – undo
63 63
   );
64 64
 
65 65
   $accept_offer = false;
66
-  }
67
-  else
66
+  } else
68 67
   {
69 68
     $accept_offer = true;
70 69
     $negotiation = array(
@@ -75,8 +74,7 @@  discard block
 block discarded – undo
75 74
       'alliance_negotiation_relation' => $alliance_negotiation_relation,
76 75
     );
77 76
   }
78
-}
79
-else
77
+} else
80 78
 {
81 79
   $offer_id = sys_get_param_id('offer_id');
82 80
   if($offer_id)
@@ -87,31 +85,26 @@  discard block
 block discarded – undo
87 85
     if(!$negotiation)
88 86
     {
89 87
       message($lang['ali_dip_err_offer_none'], $page_title);
90
-    }
91
-    elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id'])
88
+    } elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id'])
92 89
     {
93 90
       // TODO: Add log of hack attempt
94 91
       message($lang['ali_dip_err_offer_alien'], $page_title);
95
-    }
96
-    elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id'])
92
+    } elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id'])
97 93
     {
98 94
       if($offer_answer == 'accept')
99 95
       {
100 96
         // TODO: Add log of hack attempt
101 97
         message($lang['ali_dip_err_offer_accept_own'], $page_title);
102
-      }
103
-      elseif($offer_answer == 'deny')
98
+      } elseif($offer_answer == 'deny')
104 99
       {
105 100
         doquery("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_id = {$offer_id} LIMIT 1;");
106 101
       }
107
-    }
108
-    else
102
+    } else
109 103
     {
110 104
       if($offer_answer == 'accept')
111 105
       {
112 106
         $accept_offer = true;
113
-      }
114
-      elseif($offer_answer == 'deny')
107
+      } elseif($offer_answer == 'deny')
115 108
       {
116 109
         DBStaticAlly::db_ally_negotiation_update_status_1($offer_id);
117 110
       }
Please login to merge, or discard this patch.
includes/pages/chat.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
   $user_auth_level = isset($user['authlevel']) ? $user['authlevel'] : AUTH_LEVEL_ANONYMOUS;
38 38
 
39 39
   $mode = sys_get_param_int('mode');
40
-  switch($mode)
40
+  switch ($mode)
41 41
   {
42 42
     case CHAT_MODE_ALLY:
43 43
       $template_result['ALLY'] = intval($user['ally_id']);
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
51 51
   }
52 52
 
53 53
   $template_result['.']['smiles'] = array();
54
-  foreach(classSupernova::$design['smiles'] as $auth_level => $replaces) {
55
-    if($auth_level > $user_auth_level) {
54
+  foreach (classSupernova::$design['smiles'] as $auth_level => $replaces) {
55
+    if ($auth_level > $user_auth_level) {
56 56
       continue;
57 57
     }
58 58
 
59
-    foreach($replaces as $bbcode => $filename)
59
+    foreach ($replaces as $bbcode => $filename)
60 60
     {
61 61
       $template_result['.']['smiles'][] = array(
62 62
         'BBCODE' => $bbcode,
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
   define('IN_AJAX', true);
82 82
   $skip_fleet_update = true;
83 83
 
84
-  if($config->_MODE != CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout)
84
+  if ($config->_MODE != CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout)
85 85
   {
86 86
     die();
87 87
   }
88 88
 
89
-  if(($message = sys_get_param_str('message')) && $user['username'])
89
+  if (($message = sys_get_param_str('message')) && $user['username'])
90 90
   {
91 91
     $ally_id = sys_get_param('ally') && $user['ally_id'] ? $user['ally_id'] : 0;
92 92
     $nick = db_escape(player_nick_compact(player_nick_render_current_to_array($user, array('color' => true, 'icons' => true, 'ally' => !$ally_id))));
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
   $skip_fleet_update = true;
109 109
 
110 110
   $history = sys_get_param_str('history');
111
-  if(!$history)
111
+  if (!$history)
112 112
   {
113 113
     $config->array_set('users', $user['id'], 'chat_last_refresh', SN_TIME_MICRO);
114 114
   }
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
   $last_message = '';
118 118
   $alliance = 0;
119 119
   $template_result['.']['chat'] = array();
120
-  if(!$history && $config->_MODE != CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout)
120
+  if (!$history && $config->_MODE != CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout)
121 121
   {
122 122
     $result['disable'] = true;
123 123
     $template_result['.']['chat'][] = array(
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
 
134 134
     $where_add = '';
135 135
     $last_message = 0;
136
-    if($history)
136
+    if ($history)
137 137
     {
138 138
       $rows = doquery("SELECT count(1) AS CNT FROM {{chat}} WHERE ally_id = '{$alliance}';", true);
139 139
       $page_count = ceil($rows['CNT'] / $page_limit);
140 140
 
141
-      for($i = 0; $i < $page_count; $i++)
141
+      for ($i = 0; $i < $page_count; $i++)
142 142
       {
143 143
         $template_result['.']['page'][] = array(
144 144
           'NUMBER' => $i
@@ -160,13 +160,13 @@  discard block
 block discarded – undo
160 160
         {{chat}} AS c
161 161
         LEFT JOIN {{users}} AS u ON u.id = c.chat_message_sender_id
162 162
       WHERE c.chat_message_recipient_id IS NULL AND c.ally_id = '{$alliance}' {$where_add} ORDER BY messageid DESC LIMIT {$start_row}, {$page_limit};");
163
-    while($chat_row = db_fetch($query))
163
+    while ($chat_row = db_fetch($query))
164 164
     {
165 165
       // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick
166 166
       $chat_row['user'] = player_nick_render_to_html($chat_row['user']);
167 167
       $nick_stripped = htmlentities(strip_tags($chat_row['user']), ENT_QUOTES, 'utf-8');
168 168
       $nick = str_replace(strip_tags($chat_row['user']), $nick_stripped, $chat_row['user']);
169
-      if(!$history)
169
+      if (!$history)
170 170
       {
171 171
         $nick = "<span style=\"cursor: pointer;\" onclick=\"addSmiley('({$nick_stripped})');\">{$nick}</span>";
172 172
       }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
   $template = gettemplate('chat_messages', $template);
193 193
   $template->assign_recursive($template_result);
194 194
 
195
-  if($history)
195
+  if ($history)
196 196
   {
197 197
     display($template, "{$lang['chat_history']} - {$lang[$alliance ? 'chat_ally' : 'chat_common']}", true, '', false, true);
198 198
   }
Please login to merge, or discard this patch.
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -27,8 +27,7 @@  discard block
 block discarded – undo
27 27
 $sn_mvc['view']['chat'][] = 'sn_chat_view';
28 28
 $sn_mvc['view']['chat_msg'][] = 'sn_chat_msg_view';
29 29
 */
30
-function sn_chat_model()
31
-{
30
+function sn_chat_model() {
32 31
   global $config, $user, $template_result, $lang;
33 32
 
34 33
   $config->array_set('users', $user['id'], 'chat_last_activity', SN_TIME_MICRO);
@@ -67,15 +66,13 @@  discard block
 block discarded – undo
67 66
 
68 67
   $template_result['PAGE_HEADER'] = $page_title;
69 68
 }
70
-function sn_chat_view($template = null)
71
-{
69
+function sn_chat_view($template = null) {
72 70
   $template = gettemplate('chat_body', $template);
73 71
 
74 72
   return $template;
75 73
 }
76 74
 
77
-function sn_chat_add_model()
78
-{
75
+function sn_chat_add_model() {
79 76
   global $skip_fleet_update, $config, $user;
80 77
 
81 78
   define('IN_AJAX', true);
@@ -100,8 +97,7 @@  discard block
 block discarded – undo
100 97
 
101 98
   die();
102 99
 }
103
-function sn_chat_msg_view($template = null)
104
-{
100
+function sn_chat_msg_view($template = null) {
105 101
   global $config, $skip_fleet_update, $user, $lang;
106 102
 
107 103
   define('IN_AJAX', true);
@@ -124,8 +120,7 @@  discard block
 block discarded – undo
124 120
       'TIME' => date(FMT_DATE_TIME, htmlentities(SN_CLIENT_TIME_LOCAL, ENT_QUOTES, 'utf-8')),
125 121
       'DISABLE' => true,
126 122
     );
127
-  }
128
-  else
123
+  } else
129 124
   {
130 125
     $alliance = sys_get_param_str('ally') && $user['ally_id'] ? $user['ally_id'] : 0;
131 126
 
@@ -146,8 +141,7 @@  discard block
 block discarded – undo
146 141
       }
147 142
 
148 143
       $page = min($page_count, max(0, sys_get_param_int('sheet')));
149
-    }
150
-    else
144
+    } else
151 145
     {
152 146
       $last_message = sys_get_param_id('last_message');
153 147
       $where_add = $last_message ? "AND `messageid` > {$last_message}" : '';
@@ -195,8 +189,7 @@  discard block
 block discarded – undo
195 189
   if($history)
196 190
   {
197 191
     display($template, "{$lang['chat_history']} - {$lang[$alliance ? 'chat_ally' : 'chat_common']}", true, '', false, true);
198
-  }
199
-  else
192
+  } else
200 193
   {
201 194
     $result['last_message'] = $last_message;
202 195
     ob_start();
Please login to merge, or discard this patch.