Passed
Push — trunk ( 338765...433e05 )
by SuperNova.WS
04:23
created
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 = SN::db_transaction_check(false) ? SN::$transaction_id : SN::$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 =
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
       $line = !empty($a_trace['line']) ? $a_trace['line'] : '_UNDEFINED_';
100 100
       $result[] = "{$function} - '{$file}' Line {$line}";
101 101
 
102
-      if(!$long_comment) {
102
+      if (!$long_comment) {
103 103
         break;
104 104
       }
105 105
     }
@@ -108,26 +108,26 @@  discard block
 block discarded – undo
108 108
   }
109 109
 
110 110
   function dump($dump = false, $force_base = false, $deadlock = false) {
111
-    if($dump === false) {
111
+    if ($dump === false) {
112 112
       return;
113 113
     }
114 114
 
115 115
     $error_backtrace = array();
116 116
     $base_dump = false;
117 117
 
118
-    if($force_base === true) {
118
+    if ($force_base === true) {
119 119
       $base_dump = true;
120 120
     }
121 121
 
122
-    if($dump === true) {
122
+    if ($dump === true) {
123 123
       $base_dump = true;
124 124
     } else {
125
-      if(!is_array($dump)) {
125
+      if (!is_array($dump)) {
126 126
         $dump = array('var' => $dump);
127 127
       }
128 128
 
129
-      foreach($dump as $dump_var_name => $dump_var) {
130
-        if($dump_var_name == 'base_dump') {
129
+      foreach ($dump as $dump_var_name => $dump_var) {
130
+        if ($dump_var_name == 'base_dump') {
131 131
           $base_dump = $dump_var;
132 132
         } else {
133 133
           $error_backtrace[$dump_var_name] = $dump_var;
@@ -135,24 +135,23 @@  discard block
 block discarded – undo
135 135
       }
136 136
     }
137 137
 
138
-    if($deadlock && ($q = db_fetch(SN::$db->mysql_get_innodb_status()))) {
138
+    if ($deadlock && ($q = db_fetch(SN::$db->mysql_get_innodb_status()))) {
139 139
       $error_backtrace['deadlock'] = explode("\n", $q['Status']);
140 140
       $error_backtrace['locks'] = _SnCacheInternal::$locks;
141 141
       $error_backtrace['cSN_data'] = _SnCacheInternal::$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
     }
150 149
 
151
-    if($base_dump) {
152
-      if(!is_array($this->log_array) || empty($this->log_array)) {
150
+    if ($base_dump) {
151
+      if (!is_array($this->log_array) || empty($this->log_array)) {
153 152
         $this->log_array = [];
154 153
       } else {
155
-        foreach($this->log_array as $log) {
154
+        foreach ($this->log_array as $log) {
156 155
           $error_backtrace['queries'][] = $log;
157 156
         }
158 157
       }
@@ -164,17 +163,17 @@  discard block
 block discarded – undo
164 163
       // Converting object instances to object names
165 164
 
166 165
       foreach ($error_backtrace['backtrace'] as &$backtrace) {
167
-        if(is_object($backtrace['object'])) {
166
+        if (is_object($backtrace['object'])) {
168 167
           $backtrace['object'] = get_class($backtrace['object']);
169 168
         }
170 169
 
171
-        if(empty($backtrace['args'])) {
170
+        if (empty($backtrace['args'])) {
172 171
           continue;
173 172
         }
174 173
 
175 174
         // Doing same conversion for backtrace params
176
-        foreach($backtrace['args'] as &$arg) {
177
-          if(is_object($arg)) {
175
+        foreach ($backtrace['args'] as &$arg) {
176
+          if (is_object($arg)) {
178 177
             $arg = 'object::' . get_class($arg);
179 178
           }
180 179
         }
@@ -203,14 +202,14 @@  discard block
 block discarded – undo
203 202
   function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) {
204 203
     global $config, $sys_stop_log_hit, $lang, $sys_log_disabled, $user;
205 204
 
206
-    if(empty(SN::$db->connected)) {
205
+    if (empty(SN::$db->connected)) {
207 206
       // TODO - писать ошибку в файл
208 207
       die('SQL server currently unavailable. Please contact Administration...');
209 208
     }
210 209
 
211 210
     sn_db_transaction_rollback();
212 211
 
213
-    if(SN::$config->debug == 1) {
212
+    if (SN::$config->debug == 1) {
214 213
       echo "<h2>{$title}</h2><br><font color=red>" . htmlspecialchars($message) . "</font><br><hr>";
215 214
       echo "<table>{$this->log}</table>";
216 215
     }
@@ -220,7 +219,7 @@  discard block
 block discarded – undo
220 219
     $error_text = db_escape($message);
221 220
     $error_backtrace = $this->dump($dump, true, strpos($message, 'Deadlock') !== false);
222 221
 
223
-    if(!$sys_log_disabled) {
222
+    if (!$sys_log_disabled) {
224 223
       $query = "INSERT INTO `{{logs}}` SET
225 224
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "',
226 225
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -238,7 +237,7 @@  discard block
 block discarded – undo
238 237
       ob_start();
239 238
       print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}");
240 239
 
241
-      foreach($error_backtrace as $name => $value) {
240
+      foreach ($error_backtrace as $name => $value) {
242 241
         print('<hr>');
243 242
         pdump($value, $name);
244 243
       }
@@ -250,14 +249,14 @@  discard block
 block discarded – undo
250 249
   function warning($message, $title = 'System Message', $log_code = 300, $dump = false) {
251 250
     global $user, $lang, $sys_log_disabled;
252 251
 
253
-    if(empty(SN::$db->connected)) {
252
+    if (empty(SN::$db->connected)) {
254 253
       // TODO - писать ошибку в файл
255 254
       die('SQL server currently unavailable. Please contact Administration...');
256 255
     }
257 256
 
258 257
     $error_backtrace = $this->dump($dump, false);
259 258
 
260
-    if(!$sys_log_disabled) {
259
+    if (!$sys_log_disabled) {
261 260
       $query = "INSERT INTO `{{logs}}` SET
262 261
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "',
263 262
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -275,11 +274,11 @@  discard block
 block discarded – undo
275 274
 // Dump variables nicer then var_dump()
276 275
 
277 276
 function dump($value, $varname = null, $level = 0, $dumper = '') {
278
-  if(isset($varname)) {
277
+  if (isset($varname)) {
279 278
     $varname .= " = ";
280 279
   }
281 280
 
282
-  if($level == -1) {
281
+  if ($level == -1) {
283 282
     $trans[' '] = '&there4;';
284 283
     $trans["\t"] = '&rArr;';
285 284
     $trans["\n"] = '&para;;';
@@ -288,7 +287,7 @@  discard block
 block discarded – undo
288 287
 
289 288
     return strtr(htmlspecialchars($value), $trans);
290 289
   }
291
-  if($level == 0) {
290
+  if ($level == 0) {
292 291
 //    $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname;
293 292
     $dumper = mt_rand(10, 99) . '|' . $varname;
294 293
   }
@@ -296,22 +295,22 @@  discard block
 block discarded – undo
296 295
   $type = gettype($value);
297 296
   $dumper .= $type;
298 297
 
299
-  if($type == 'string') {
298
+  if ($type == 'string') {
300 299
     $dumper .= '(' . strlen($value) . ')';
301 300
     $value = dump($value, '', -1);
302
-  } elseif($type == 'boolean') {
301
+  } elseif ($type == 'boolean') {
303 302
     $value = ($value ? 'true' : 'false');
304
-  } elseif($type == 'object') {
303
+  } elseif ($type == 'object') {
305 304
     $props = get_class_vars(get_class($value));
306 305
     $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>';
307
-    foreach($props as $key => $val) {
306
+    foreach ($props as $key => $val) {
308 307
       $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => ';
309 308
       $dumper .= dump($value->$key, '', $level + 1);
310 309
     }
311 310
     $value = '';
312
-  } elseif($type == 'array') {
311
+  } elseif ($type == 'array') {
313 312
     $dumper .= '(' . count($value) . ')';
314
-    foreach($value as $key => $val) {
313
+    foreach ($value as $key => $val) {
315 314
       $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => ';
316 315
       $dumper .= dump($val, '', $level + 1);
317 316
     }
@@ -331,7 +330,7 @@  discard block
 block discarded – undo
331 330
 //  $backtrace = $backtrace[1];
332 331
 
333 332
   $caller = '';
334
-  if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
333
+  if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
335 334
     $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') .
336 335
       (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') .
337 336
       $backtrace[1]['function'] .
@@ -358,7 +357,7 @@  discard block
 block discarded – undo
358 357
 }
359 358
 
360 359
 function pr($prePrint = false) {
361
-  if($prePrint) {
360
+  if ($prePrint) {
362 361
     print("<br>");
363 362
   }
364 363
   print(mt_rand() . "<br>");
@@ -368,7 +367,7 @@  discard block
 block discarded – undo
368 367
   global $_PRINT_COUNT_VALUE;
369 368
   $_PRINT_COUNT_VALUE++;
370 369
 
371
-  if($prePrint) {
370
+  if ($prePrint) {
372 371
     print("<br>");
373 372
   }
374 373
   print($_PRINT_COUNT_VALUE . "<br>");
Please login to merge, or discard this patch.
classes/Planet/DBStaticPlanet.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,8 +68,7 @@
 block discarded – undo
68 68
     $galaxy = isset($vector[$prefix . 'galaxy']) ? intval($vector[$prefix . 'galaxy']) : 0;
69 69
     $system = isset($vector[$prefix . 'system']) ? intval($vector[$prefix . 'system']) : 0;
70 70
     $planet = isset($vector[$prefix . 'planet']) ? intval($vector[$prefix . 'planet']) : 0;
71
-    $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) :
72
-      (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0);
71
+    $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) : (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0);
73 72
     $planet_type = $planet_type == PT_DEBRIS ? PT_PLANET : $planet_type;
74 73
 
75 74
     return DBStaticPlanet::db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update, $fields);
Please login to merge, or discard this patch.
classes/Universe/Universe.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@
 block discarded – undo
8 8
   const MOON_MIN_SIZE = 1100;
9 9
   const MOON_MAX_SIZE = 8999;
10 10
 
11
-  const MOON_DEBRIS_MIN = 1000000;    // Minimum amount of debris to span a moon
12
-  const MOON_CHANCE_MIN_PERCENT = 1;  // Minimum chance to span a moon
11
+  const MOON_DEBRIS_MIN = 1000000; // Minimum amount of debris to span a moon
12
+  const MOON_CHANCE_MIN_PERCENT = 1; // Minimum chance to span a moon
13 13
   const MOON_CHANCE_MAX_PERCENT = 30; // Maximum chance to span a moon
14 14
 
15 15
   /**
Please login to merge, or discard this patch.
classes/Fleet/FleetDispatcher.php 1 patch
Spacing   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -465,15 +465,11 @@
 block discarded – undo
465 465
   protected function flt_flyingFleetsSort($a, $b) {
466 466
     return
467 467
       // Сравниваем время флотов - кто раньше, тот и первый обрабатывается
468
-      $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 :
469
-        // Если время - одинаковое, сравниваем события флотов
468
+      $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов
470 469
         // Если события - одинаковые, то флоты равны
471
-        ($a['fleet_event'] == $b['fleet_event'] ? 0 :
472
-          // Если события разные - первыми считаем прибывающие флоты
473
-          ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 :
474
-            // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
475
-            ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 :
476
-              // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
470
+        ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты
471
+          ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
472
+            ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
477 473
               // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска
478 474
               (
479 475
               0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий
Please login to merge, or discard this patch.
classes/DBAL/OldDbChangeSet.php 1 patch
Spacing   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -142,9 +142,7 @@
 block discarded – undo
142 142
           // Простое условие - $field_id = $field_value
143 143
           if (is_string($field_id)) {
144 144
             $field_value =
145
-              $field_value === null ? 'NULL' :
146
-                (is_string($field_value) ? "'" . db_escape($field_value) . "'" :
147
-                  (is_bool($field_value) ? intval($field_value) : $field_value));
145
+              $field_value === null ? 'NULL' : (is_string($field_value) ? "'" . db_escape($field_value) . "'" : (is_bool($field_value) ? intval($field_value) : $field_value));
148 146
             $the_conditions[] = "`{$field_id}` = {$field_value}";
149 147
           } else {
150 148
             die('Неподдерживаемый тип условия');
Please login to merge, or discard this patch.
includes/alliance/ali_internal_admin_request.inc 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 use Alliance\DBStaticAlly;
4 4
 
5
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
5
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
6 6
   $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
7 7
 }
8 8
 
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 }
12 12
 
13 13
 $d = sys_get_param_id('d');
14
-if($d) {
14
+if ($d) {
15 15
   doquery("UPDATE {{alliance_requests}} SET `request_denied` = 1, `request_text` = '{$lang['ali_req_deny_reason']}' WHERE `id_user`= {$d} LIMIT 1;");
16 16
 }
17 17
 
18 18
 $id_user = sys_get_param_id('id_user');
19
-if($id_user) {
19
+if ($id_user) {
20 20
   $ally_name_safe = db_escape($ally['ally_name']);
21 21
   $ally_tag_safe = db_escape($ally['ally_tag']);
22 22
   db_user_set_by_id($id_user, "`ally_id` = '{$ally['id']}', `ally_name` = '{$ally_name_safe}', `ally_tag` = '{$ally_tag_safe}', `ally_register_time` = " . SN_TIME_NOW . ", `ally_rank_id` = 0");
Please login to merge, or discard this patch.
includes/alliance/ali_internal_admin.inc 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -2,26 +2,26 @@  discard block
 block discarded – undo
2 2
 
3 3
 use Alliance\DBStaticAlly;
4 4
 
5
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
5
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
6 6
   $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
7 7
 }
8 8
 
9
-if(!$user_admin) {
9
+if (!$user_admin) {
10 10
   messageBox($lang['Denied_access'], $lang['ally_admin']);
11 11
 }
12 12
 
13 13
 $template = gettemplate('ali_admin', $template);
14 14
 
15 15
 $text_list = array(
16
-  1 => array ('db_field' => 'ally_description', 'text_type' => 'Public_text_of_alliance'),
17
-  2 => array ('db_field' => 'ally_text', 'text_type' => 'Internal_text'),
18
-  3 => array ('db_field' => 'ally_request', 'text_type' => 'Show_of_request_text'),
16
+  1 => array('db_field' => 'ally_description', 'text_type' => 'Public_text_of_alliance'),
17
+  2 => array('db_field' => 'ally_text', 'text_type' => 'Internal_text'),
18
+  3 => array('db_field' => 'ally_request', 'text_type' => 'Show_of_request_text'),
19 19
 );
20 20
 
21 21
 $allyTextID = sys_get_param_int('t', 1);
22
-$allyTextID = ($allyTextID<1 || $allyTextID>3) ? 1 : $allyTextID;
22
+$allyTextID = ($allyTextID < 1 || $allyTextID > 3) ? 1 : $allyTextID;
23 23
 
24
-if(sys_get_param_str('isSaveOptions')) {
24
+if (sys_get_param_str('isSaveOptions')) {
25 25
   require_once('includes/includes/sys_avatar.php');
26 26
 
27 27
   $new_image = $ally['ally_image'];
@@ -33,32 +33,32 @@  discard block
 block discarded – undo
33 33
 //  $template->assign_block_vars('result', $avatar_upload_result);
34 34
 
35 35
   $ally_changeset = array();
36
-  if(($new_tag = sys_get_param_str_unsafe('tag', $ally['ally_tag'])) && $new_tag != $ally['ally_tag']) {
36
+  if (($new_tag = sys_get_param_str_unsafe('tag', $ally['ally_tag'])) && $new_tag != $ally['ally_tag']) {
37 37
     $new_tag_unsafe = $new_tag;
38 38
     $new_tag = db_escape($new_tag);
39 39
     $isTaggedAllyExists = DBStaticAlly::db_ally_get_by_tag($new_tag);
40
-    if(!empty($isTaggedAllyExists)) {
40
+    if (!empty($isTaggedAllyExists)) {
41 41
       messageBox(sprintf($lang['ally_message_tag_exists'], $new_tag_unsafe), '', 'alliance.php?mode=admin&edit=ally');
42 42
     }
43 43
     $ally_changeset[] = "`ally_tag`='{$new_tag}'";
44 44
     db_user_set_by_id($ally['ally_user_id'], "`username`='[{$new_tag}]'");
45 45
   }
46 46
 
47
-  if(($new_name = sys_get_param_str_unsafe('name', $ally['ally_name'])) && $new_name != $ally['ally_name']) {
47
+  if (($new_name = sys_get_param_str_unsafe('name', $ally['ally_name'])) && $new_name != $ally['ally_name']) {
48 48
     $new_name_unsafe = $new_name;
49 49
     $new_name = db_escape($new_name);
50 50
     $isTaggedAllyExists = DBStaticAlly::db_ally_get_by_name($new_name);
51
-    if(!empty($isTaggedAllyExists)) {
51
+    if (!empty($isTaggedAllyExists)) {
52 52
       messageBox(sprintf($lang['ally_message_name_exists'], $new_name_unsafe), '', 'alliance.php?mode=admin&edit=ally');
53 53
     }
54 54
     $ally_changeset[] = "`ally_name`='{$new_name}'";
55 55
   }
56 56
 
57
-  if(($new_owner_rank = sys_get_param_str_unsafe('owner_range', $ally['ally_owner_range'])) && $new_owner_rank != $ally['ally_owner_range']) {
57
+  if (($new_owner_rank = sys_get_param_str_unsafe('owner_range', $ally['ally_owner_range'])) && $new_owner_rank != $ally['ally_owner_range']) {
58 58
     $new_owner_rank = db_escape($new_owner_rank);
59 59
     $ally_changeset[] = "`ally_owner_range` = '{$new_owner_rank}'";
60 60
   }
61
-  if(($new_web = sys_get_param_str_unsafe('web', $ally['ally_web'])) && $new_web != $ally['ally_web']) {
61
+  if (($new_web = sys_get_param_str_unsafe('web', $ally['ally_web'])) && $new_web != $ally['ally_web']) {
62 62
     $new_web = db_escape($new_web);
63 63
     $ally_changeset[] = "`ally_web` = '{$new_web}'";
64 64
   }
@@ -67,31 +67,31 @@  discard block
 block discarded – undo
67 67
 //  if(($new_request = sys_get_param_int('request_notallow', $ally['ally_request_notallow'])) && $new_request != $ally['ally_request_notallow']) {
68 68
 //    $ally_changeset[] = "`ally_request_notallow` = '{$new_request}'";
69 69
 //  }
70
-  if($new_image != $ally['ally_image']) {
70
+  if ($new_image != $ally['ally_image']) {
71 71
     $new_image = intval($new_image);
72 72
     $ally_changeset[] = "`ally_image` = '{$new_image}'";
73 73
   }
74 74
 
75
-  if(!empty($ally_changeset)) {
75
+  if (!empty($ally_changeset)) {
76 76
     doquery("UPDATE {{alliance}} SET " . implode(',', $ally_changeset) . " WHERE `id`='{$ally['id']}' LIMIT 1;");
77 77
     sys_redirect('alliance.php?mode=admin&edit=ally');
78 78
   }
79 79
 }
80
-elseif(sys_get_param_str('isSaveText'))
80
+elseif (sys_get_param_str('isSaveText'))
81 81
 {
82 82
   $text = sys_get_param_str_both('text');
83 83
   doquery("UPDATE {{alliance}} SET `{$text_list[$allyTextID]['db_field']}`='{$text['safe']}' WHERE `id`='{$ally['id']}';");
84 84
   $ally[$text_list[$allyTextID]['db_field']] = $text['unsafe'];
85 85
 }
86
-elseif(sys_get_param_str('isTransfer') && $idNewLeader = sys_get_param_id('idNewLeader'))
86
+elseif (sys_get_param_str('isTransfer') && $idNewLeader = sys_get_param_id('idNewLeader'))
87 87
 {
88
-  if(!$isAllyOwner)
88
+  if (!$isAllyOwner)
89 89
   {
90 90
     messageBox($lang['Denied_access'], $lang['ally_admin']);
91 91
   }
92 92
 
93 93
   $newLeader = db_user_by_id($idNewLeader, false, `ally_id`);
94
-  if($newLeader['ally_id'] == $user['ally_id'])
94
+  if ($newLeader['ally_id'] == $user['ally_id'])
95 95
   {
96 96
     sn_db_transaction_start();
97 97
     db_user_set_by_id($user['id'], "`ally_rank_id`='0'");
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
     sys_redirect('alliance.php');
102 102
   }
103 103
 }
104
-elseif(sys_get_param_str('isDisband') && sys_get_param_str('isConfirmDisband'))
104
+elseif (sys_get_param_str('isDisband') && sys_get_param_str('isConfirmDisband'))
105 105
 {
106
-  if(!$isAllyOwner)
106
+  if (!$isAllyOwner)
107 107
   {
108 108
     messageBox($lang['Denied_access'], $lang['ally_admin']);
109 109
   }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
   'ally_name' => htmlspecialchars($ally['ally_name']),
127 127
   'ally_tag' => htmlspecialchars($ally['ally_tag']),
128 128
   'ally_web' => htmlspecialchars($ally['ally_web']),
129
-  'ally_request_notallow_0' => (( $ally['ally_request_notallow']) ? ' SELECTED' : ''),
129
+  'ally_request_notallow_0' => (($ally['ally_request_notallow']) ? ' SELECTED' : ''),
130 130
   'ally_request_notallow_1' => ((!$ally['ally_request_notallow']) ? ' SELECTED' : ''),
131 131
   'ally_owner_range' => htmlspecialchars($ally['ally_owner_range']),
132 132
   'hideNotOwner' => $ally['ally_owner'] != $user['id'] ? 'display: hide;' : '',
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 {
136 136
   $userAllyAdmins = db_user_list("`ally_id`= {$ally['id']}", false, '`id`, `username`');
137 137
   unset($tmp);
138
-  foreach($userAllyAdmins as $userAllyAdmin)
138
+  foreach ($userAllyAdmins as $userAllyAdmin)
139 139
   {
140 140
     $tmp .= "<option value={$userAllyAdmin['id']}>{$userAllyAdmin['username']}</option>";
141 141
   }
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
   $template->assign_var('adminMembers', $tmp);
144 144
 }
145 145
 
146
-foreach($sn_ali_admin_internal as $sn_ali_admin_action => $sn_ali_admin_action_locale)
146
+foreach ($sn_ali_admin_internal as $sn_ali_admin_action => $sn_ali_admin_action_locale)
147 147
 {
148
-  if(!$sn_ali_admin_action_locale['title'])
148
+  if (!$sn_ali_admin_action_locale['title'])
149 149
   {
150 150
     continue;
151 151
   }
Please login to merge, or discard this patch.
includes/alliance/ali_internal_admin_diplomacy.inc 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use Alliance\DBStaticAlly;
4 4
 use \DBAL\DbQuery;
5 5
 
6
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)
6
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)
7 7
 {
8 8
   $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
9 9
 }
@@ -18,28 +18,28 @@  discard block
 block discarded – undo
18 18
 $ally_name_safe = db_escape($user['ally_name']);
19 19
 
20 20
 $autoAccept = false;
21
-if(sys_get_param_str('ali_dip_offer_make'))
21
+if (sys_get_param_str('ali_dip_offer_make'))
22 22
 {
23 23
   $alliance_negotiation_relation = sys_get_param_str('alliance_negotiation_relation');
24
-  if(!array_key_exists($alliance_negotiation_relation, $sn_diplomacy_relation_list))
24
+  if (!array_key_exists($alliance_negotiation_relation, $sn_diplomacy_relation_list))
25 25
   {
26 26
     messageBox($lang['ali_dip_err_wrong_offer'], $page_title);
27 27
   }
28 28
 
29 29
   $alliance_negotiation_contr_ally_id = sys_get_param_id('alliance_negotiation_contr_ally_id');
30
-  if($alliance_negotiation_contr_ally_id == $user['ally_id'])
30
+  if ($alliance_negotiation_contr_ally_id == $user['ally_id'])
31 31
   {
32 32
     messageBox($lang['ali_dip_err_same_ally'], $page_title);
33 33
   }
34 34
 
35 35
   $contr_ally_row = doquery("SELECT `ally_name` FROM {{alliance}} WHERE `id` = {$alliance_negotiation_contr_ally_id} LIMIT 1;", '', true);
36
-  if(!$contr_ally_row)
36
+  if (!$contr_ally_row)
37 37
   {
38 38
     messageBox($lang['ali_dip_err_no_ally'], $page_title);
39 39
   }
40 40
 
41 41
   $relation_current_id = ali_relation($user['ally_id'], $alliance_negotiation_contr_ally_id);
42
-  if($alliance_negotiation_relation == $relation_current_id)
42
+  if ($alliance_negotiation_relation == $relation_current_id)
43 43
   {
44 44
     messageBox(sprintf($lang['ali_dip_err_offer_same'], $lang['ali_dip_relations'][$alliance_negotiation_relation]), $page_title);
45 45
   }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
   $relation_new = $sn_diplomacy_relation_list[$alliance_negotiation_relation];
53 53
   $relation_current = $sn_diplomacy_relation_list[$relation_current_id];
54
-  if($relation_new['enter_delay'] == -1 || $relation_current['exit_delay'] == -1)
54
+  if ($relation_new['enter_delay'] == -1 || $relation_current['exit_delay'] == -1)
55 55
   {
56 56
     DbQuery::build()
57 57
       ->setTable('alliance_negotiation')
@@ -85,39 +85,39 @@  discard block
 block discarded – undo
85 85
 else
86 86
 {
87 87
   $offer_id = sys_get_param_id('offer_id');
88
-  if($offer_id)
88
+  if ($offer_id)
89 89
   {
90 90
     $offer_answer = sys_get_param_str('answer');
91 91
 
92 92
     $negotiation = doquery("SELECT * FROM {{alliance_negotiation}} WHERE alliance_negotiation_id = {$offer_id} LIMIT 1;", '', true);
93
-    if(!$negotiation)
93
+    if (!$negotiation)
94 94
     {
95 95
       messageBox($lang['ali_dip_err_offer_none'], $page_title);
96 96
     }
97
-    elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id'])
97
+    elseif ($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id'])
98 98
     {
99 99
       // TODO: Add log of hack attempt
100 100
       messageBox($lang['ali_dip_err_offer_alien'], $page_title);
101 101
     }
102
-    elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id'])
102
+    elseif ($negotiation['alliance_negotiation_ally_id'] == $user['ally_id'])
103 103
     {
104
-      if($offer_answer == 'accept')
104
+      if ($offer_answer == 'accept')
105 105
       {
106 106
         // TODO: Add log of hack attempt
107 107
         messageBox($lang['ali_dip_err_offer_accept_own'], $page_title);
108 108
       }
109
-      elseif($offer_answer == 'deny')
109
+      elseif ($offer_answer == 'deny')
110 110
       {
111 111
         doquery("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_id = {$offer_id} LIMIT 1;");
112 112
       }
113 113
     }
114 114
     else
115 115
     {
116
-      if($offer_answer == 'accept')
116
+      if ($offer_answer == 'accept')
117 117
       {
118 118
         $accept_offer = true;
119 119
       }
120
-      elseif($offer_answer == 'deny')
120
+      elseif ($offer_answer == 'deny')
121 121
       {
122 122
         DBStaticAlly::db_ally_negotiation_update_status_1($offer_id);
123 123
       }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
   }
126 126
 }
127 127
 
128
-if($accept_offer)
128
+if ($accept_offer)
129 129
 {
130 130
   sn_db_transaction_start();
131 131
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
   sn_db_transaction_commit();
186 186
 }
187 187
 
188
-foreach($sn_diplomacy_relation_list as $diplomacy_relation_id => $diplomacy_relation)
188
+foreach ($sn_diplomacy_relation_list as $diplomacy_relation_id => $diplomacy_relation)
189 189
 {
190 190
   $template->assign_block_vars('relation', array(
191 191
     'ID'   => $diplomacy_relation_id,
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 }
195 195
 
196 196
 $query = doquery("SELECT id, ally_name, ally_tag FROM {{alliance}} WHERE `id` != {$user['ally_id']} ORDER BY ally_name;");
197
-while($alliance = db_fetch($query))
197
+while ($alliance = db_fetch($query))
198 198
 {
199 199
   $template->assign_block_vars('alliance', array(
200 200
     'ID'   => $alliance['id'],
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
   WHERE
214 214
     alliance_negotiation_ally_id = {$user['ally_id']} OR alliance_negotiation_contr_ally_id = {$user['ally_id']};"
215 215
 );
216
-while($offer = db_fetch($query))
216
+while ($offer = db_fetch($query))
217 217
 {
218 218
   $template->assign_block_vars('offer', array(
219 219
     'ID'       => $offer['alliance_negotiation_id'],
Please login to merge, or discard this patch.
includes/alliance/ali_info.inc 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -2,14 +2,14 @@  discard block
 block discarded – undo
2 2
 
3 3
 use Alliance\DBStaticAlly;
4 4
 
5
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)
5
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)
6 6
 {
7 7
   $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
8 8
 }
9 9
 
10 10
 $template = gettemplate('ali_info', true);
11 11
 
12
-if($mode == 'exit')
12
+if ($mode == 'exit')
13 13
 {
14 14
   if ($ally['ally_owner'] == $user['id'])
15 15
   {
@@ -26,25 +26,25 @@  discard block
 block discarded – undo
26 26
     messageBox(sprintf($lang['ali_info_leave_success'], $ally['ally_name']), $lang['sys_alliance']);
27 27
   }
28 28
 }
29
-elseif($mode == 'ainfo')
29
+elseif ($mode == 'ainfo')
30 30
 {
31 31
   $tag = sys_get_param_str('tag');
32 32
   $id_ally = sys_get_param_id('a');
33
-  if($tag)
33
+  if ($tag)
34 34
   {
35 35
     $ally = doquery("SELECT * FROM {{alliance}} WHERE ally_tag='{$tag}' LIMIT 1;", '', true);
36 36
   }
37
-  elseif($id_ally)
37
+  elseif ($id_ally)
38 38
   {
39 39
     $ally = doquery("SELECT * FROM {{alliance}} WHERE id='{$id_ally}' LIMIT 1;", '', true);
40 40
   }
41 41
 
42
-  if(!$ally)
42
+  if (!$ally)
43 43
   {
44 44
     messageBox($lang['ali_sys_notFound'], $lang['Ally_info_1']);
45 45
   }
46 46
 
47
-  if(!$ally['ally_description'])
47
+  if (!$ally['ally_description'])
48 48
   {
49 49
     $ally['ally_description'] = $lang['Ally_nodescription'];
50 50
   }
@@ -53,17 +53,17 @@  discard block
 block discarded – undo
53 53
     'EXTERNAL'     => true,
54 54
     'USER_ALLY_ID' => $user['ally_id'],
55 55
   ));
56
-  $page_header          = $lang['sys_alliance'];
56
+  $page_header = $lang['sys_alliance'];
57 57
 }
58 58
 else
59 59
 {
60 60
   $page_header = $lang['your_alliance'];
61 61
 
62
-  if($ally['ally_owner'] == $user['id'])
62
+  if ($ally['ally_owner'] == $user['id'])
63 63
   {
64 64
     $range = $ally['ally_owner_range'] ? $ally['ally_owner_range'] : $lang['Founder'];
65 65
   }
66
-  elseif($user['ally_rank_id'] != 0 && isset($ranks[$user['ally_rank_id']]['name']))
66
+  elseif ($user['ally_rank_id'] != 0 && isset($ranks[$user['ally_rank_id']]['name']))
67 67
   {
68 68
     $range = $ranks[$user['ally_rank_id']]['name'];
69 69
   }
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
 ));
108 108
 
109 109
 $relations = ali_relations($ally['id']);
110
-foreach($relations as $relation)
110
+foreach ($relations as $relation)
111 111
 {
112
-  if($relation['alliance_diplomacy_contr_ally_id'] && $relation['alliance_diplomacy_ally_id'])
112
+  if ($relation['alliance_diplomacy_contr_ally_id'] && $relation['alliance_diplomacy_ally_id'])
113 113
   {
114 114
     $template->assign_block_vars('relation', array(
115 115
       'NAME'     => $relation['alliance_diplomacy_contr_ally_name'],
Please login to merge, or discard this patch.