Test Failed
Branch trunk (c9c94d)
by SuperNova.WS
10:03 queued 05:45
created
classes/userOptions.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 
123 123
     $update_cache = false;
124 124
 
125
-    if(!empty($this->to_write)) {
126
-      foreach($this->to_write as $key => $cork) {
125
+    if (!empty($this->to_write)) {
126
+      foreach ($this->to_write as $key => $cork) {
127 127
         $value = is_array($this->data[$key]) ? serialize($this->data[$key]) : $this->data[$key]; // Сериализация для массивов при сохранении в БД
128 128
         $this->to_write[$key] = "({$this->user_id}, '" . db_escape($key) . "', '" . db_escape($value) . "')";
129 129
       }
@@ -134,18 +134,18 @@  discard block
 block discarded – undo
134 134
       $update_cache = true;
135 135
     }
136 136
 
137
-    if(!empty($this->to_delete)) {
138
-      foreach($this->to_delete as $key => &$value) {
139
-        $value = is_string($key) ? "'". db_escape($key) . "'" : $key;
137
+    if (!empty($this->to_delete)) {
138
+      foreach ($this->to_delete as $key => &$value) {
139
+        $value = is_string($key) ? "'" . db_escape($key) . "'" : $key;
140 140
       }
141 141
 
142
-      doquery("DELETE FROM {{player_options}} WHERE `player_id` = {$this->user_id} AND `option_id` IN (". implode(',', $this->to_delete) . ") ");
142
+      doquery("DELETE FROM {{player_options}} WHERE `player_id` = {$this->user_id} AND `option_id` IN (" . implode(',', $this->to_delete) . ") ");
143 143
 
144 144
       $this->to_delete = array();
145 145
       $update_cache = true;
146 146
     }
147 147
 
148
-    if($update_cache) {
148
+    if ($update_cache) {
149 149
       global $sn_cache;
150 150
 
151 151
       $field_name = $this->cached_name();
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
   protected function load() {
173 173
     global $sn_cache;
174 174
 
175
-    if($this->loaded) {
175
+    if ($this->loaded) {
176 176
       return;
177 177
     }
178 178
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
     $this->to_write = array();
181 181
     $this->to_delete = array();
182 182
 
183
-    if(!$this->user_id) {
183
+    if (!$this->user_id) {
184 184
       $this->loaded = true;
185 185
       return;
186 186
     }
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
     $field_name = $this->cached_name();
189 189
     $a_data = $sn_cache->$field_name;
190 190
 
191
-    if(!empty($a_data)) {
191
+    if (!empty($a_data)) {
192 192
       $this->data = array_replace_recursive($this->data, $a_data);
193 193
       return;
194 194
     }
195 195
 
196 196
     $query = doquery("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE");
197
-    while($row = db_fetch($query)) {
197
+    while ($row = db_fetch($query)) {
198 198
       // $this->data[$row['option_id']] = $row['value'];
199 199
       $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация
200 200
     }
Please login to merge, or discard this patch.
classes/RequestInfo.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -89,15 +89,15 @@  discard block
 block discarded – undo
89 89
     // Инфа об устройстве и браузере - общая для всех
90 90
     sn_db_transaction_start();
91 91
     $this->device_cypher = $_COOKIE[SN_COOKIE_D];
92
-    if($this->device_cypher) {
92
+    if ($this->device_cypher) {
93 93
       $cypher_safe = db_escape($this->device_cypher);
94 94
       $device_id = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true);
95
-      if(!empty($device_id['device_id'])) {
95
+      if (!empty($device_id['device_id'])) {
96 96
         $this->device_id = $device_id['device_id'];
97 97
       }
98 98
     }
99 99
 
100
-    if($this->device_id <= 0) {
100
+    if ($this->device_id <= 0) {
101 101
       do {
102 102
         $cypher_safe = db_escape($this->device_cypher = sys_random_string());
103 103
         $row = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true);
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
     $this->page_address_id = db_get_set_unique_id_value($this->page_address, 'url_id', 'security_url', 'url_string');
119 119
     sn_db_transaction_commit();
120 120
 
121
-    if($this->write_full_url) {
121
+    if ($this->write_full_url) {
122 122
       sn_db_transaction_start();
123 123
       $this->page_url = substr($_SERVER['REQUEST_URI'], strlen(SN_ROOT_RELATIVE));
124
-      if(strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) {
124
+      if (strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) {
125 125
         $this->page_url = '/simulator.php';
126 126
       }
127 127
       $this->page_url_id = db_get_set_unique_id_value($this->page_url, 'url_id', 'security_url', 'url_string');
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
    */
145 145
   public function db_security_entry_insert($user_id_unsafe) {
146 146
     // TODO $user_id = !empty(self::$user['id']) ? self::$user['id'] : 'NULL';
147
-    if(empty($user_id_unsafe)) {
147
+    if (empty($user_id_unsafe)) {
148 148
       // self::flog('Нет ИД пользователя');
149 149
       return true;
150 150
     }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
   public function db_counter_insert($user_id_unsafe) {
168 168
     global $config, $sys_stop_log_hit, $is_watching;
169 169
 
170
-    if($sys_stop_log_hit || !$config->game_counter) {
170
+    if ($sys_stop_log_hit || !$config->game_counter) {
171 171
       return;
172 172
     }
173 173
 
@@ -183,14 +183,14 @@  discard block
 block discarded – undo
183 183
 //      $this->ip_v4_int . ", '{$proxy_safe}', " . $this->page_address_id . ", " . $this->page_url_id . ");");
184 184
     doquery(
185 185
       "INSERT INTO {{counter}} SET
186
-        `visit_time` = '" . SN_TIME_SQL. "',
186
+        `visit_time` = '" . SN_TIME_SQL . "',
187 187
         `user_id` = {$user_id_safe},
188 188
         `device_id` = {$this->device_id},
189 189
         `browser_id` = {$this->browser_id},
190 190
         `user_ip` = {$this->ip_v4_int},
191 191
         `user_proxy` = '{$proxy_safe}',
192 192
         `page_url_id` = {$this->page_address_id}" .
193
-        ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '' ).
193
+        ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '') .
194 194
       ";");
195 195
 
196 196
     $is_watching = false;
Please login to merge, or discard this patch.
classes/db_mysql_v4.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,17 +30,17 @@  discard block
 block discarded – undo
30 30
 
31 31
     static $need_keys = array('server', 'user', 'pass', 'name', 'prefix');
32 32
 
33
-    if($this->connected) {
33
+    if ($this->connected) {
34 34
       return true;
35 35
     }
36 36
 
37
-    if(empty($settings) || !is_array($settings) || array_intersect($need_keys, array_keys($settings)) != $need_keys) {
37
+    if (empty($settings) || !is_array($settings) || array_intersect($need_keys, array_keys($settings)) != $need_keys) {
38 38
       $debug->error_fatal('There is missconfiguration in your config.php. Check it again', $this->mysql_error());
39 39
     }
40 40
 
41 41
     // TODO !!!!!! DEBUG -> error!!!!
42 42
     @$this->link = mysql_connect($settings['server'], $settings['user'], $settings['pass']);
43
-    if(!is_resource($this->link)) {
43
+    if (!is_resource($this->link)) {
44 44
       $debug->error_fatal('DB Error - cannot connect to server', $this->mysql_error());
45 45
     }
46 46
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     return mysql_real_escape_string($unescaped_string, $this->link);
69 69
   }
70 70
   function mysql_close_link() {
71
-    if($this->connected) {
71
+    if ($this->connected) {
72 72
       $this->connected = false;
73 73
       mysql_close($this->link);
74 74
       unset($this->link);
Please login to merge, or discard this patch.
classes/Account.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
     $this->cookie_name_impersonate = $this->cookie_name . AUTH_COOKIE_IMPERSONATE_SUFFIX;
89 89
     $this->secret_word = classSupernova::$sn_secret_word;
90 90
 
91
-    foreach($this->table_check as $table_name) {
92
-      if(empty($this->db->table_list[$table_name])) {
91
+    foreach ($this->table_check as $table_name) {
92
+      if (empty($this->db->table_list[$table_name])) {
93 93
         die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br />
94 94
               В противном случае - сообщите Администрации сервера об ошибке.<br/>
95 95
               Не хватает таблицы для работы системы авторизации: ' . $table_name);
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
    */
114 114
   // OK v4.6
115 115
   public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) {
116
-    if(!$this->password_check($old_password_unsafe)) {
116
+    if (!$this->password_check($old_password_unsafe)) {
117 117
       return false;
118 118
     }
119 119
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
   // OK v4.5
135 135
   public function assign_from_db_row($row) {
136 136
     $this->reset();
137
-    if(empty($row) || !is_array($row)) {
137
+    if (empty($row) || !is_array($row)) {
138 138
       return false;
139 139
     }
140 140
     $this->account_id = $row['account_id'];
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
     $this->reset();
200 200
 
201 201
     $email_safe = $this->db->db_escape($email_unsafe);
202
-    if($email_safe) {
202
+    if ($email_safe) {
203 203
       $account_row = $this->db->doquery("SELECT * FROM {{account}} WHERE LOWER(`account_email`) = LOWER('{$email_safe}') FOR UPDATE;", true);
204 204
 
205 205
       return $this->assign_from_db_row($account_row);
@@ -251,11 +251,11 @@  discard block
 block discarded – undo
251 251
         `account_email` = LOWER('{$email_safe}'),
252 252
         `account_language` = '{$language_safe}'"
253 253
     );
254
-    if(!$result) {
254
+    if (!$result) {
255 255
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
256 256
     }
257 257
 
258
-    if(!($account_id = $this->db->db_insert_id())) {
258
+    if (!($account_id = $this->db->db_insert_id())) {
259 259
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
260 260
     }
261 261
 
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
       WHERE `account_id` = '{$account_id_safe}'"
286 286
     ) ? true : false;
287 287
 
288
-    if($result) {
288
+    if ($result) {
289 289
       $result = $this->db_get_by_id($this->account_id);
290 290
     }
291 291
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
   public function metamatter_change($change_type, $metamatter, $comment = false, $already_changed = false) {
366 366
     global $debug, $mm_change_legit, $config;
367 367
 
368
-    if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
368
+    if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
369 369
       $debug->error('Ошибка при попытке манипуляции с ММ');
370 370
       return false;
371 371
     }
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 
375 375
     $mm_change_legit = true;
376 376
     // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER);
377
-    if($already_changed) {
377
+    if ($already_changed) {
378 378
       $metamatter_total_delta = 0;
379 379
       $result = -1;
380 380
     } else {
@@ -387,13 +387,13 @@  discard block
 block discarded – undo
387 387
           ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$config->player_metamatter_immortal}, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '') .
388 388
         " WHERE `account_id` = {$account_id_safe}"
389 389
       );
390
-      if(!$result) {
390
+      if (!$result) {
391 391
         $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
392 392
       }
393 393
       $result = classSupernova::$db->db_affected_rows();
394 394
     }
395 395
 
396
-    if(empty(core_auth::$user['id'])) {
396
+    if (empty(core_auth::$user['id'])) {
397 397
       $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id);
398 398
       reset($user_list);
399 399
       $user_id_unsafe = key($user_list);
@@ -402,30 +402,30 @@  discard block
 block discarded – undo
402 402
     }
403 403
     $user_id_safe = $this->db->db_escape($user_id_unsafe);
404 404
 
405
-    if(!$result) {
405
+    if (!$result) {
406 406
       $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
407 407
     }
408 408
 
409
-    if(!$already_changed) {
409
+    if (!$already_changed) {
410 410
       $this->account_metamatter += $metamatter;
411 411
       $this->account_metamatter_total += $metamatter_total_delta;
412 412
     }
413 413
 
414
-    if(is_array($comment)) {
414
+    if (is_array($comment)) {
415 415
       $comment = call_user_func_array('sprintf', $comment);
416 416
     }
417 417
 
418 418
     $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe);
419 419
 
420
-    if($metamatter > 0 && !empty($user_id_safe)) {
420
+    if ($metamatter > 0 && !empty($user_id_safe)) {
421 421
       $old_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;", '', true);
422
-      if($old_referral['id']) {
422
+      if ($old_referral['id']) {
423 423
         $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM;
424 424
         doquery("UPDATE {{referrals}} SET dark_matter = dark_matter + '{$dark_matter_from_metamatter}' WHERE `id` = {$user_id_safe} LIMIT 1;");
425 425
         $new_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1;", '', true);
426 426
 
427 427
         $partner_bonus = floor($new_referral['dark_matter'] / $config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= $config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / $config->rpg_bonus_divisor) : 0);
428
-        if($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) {
428
+        if ($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) {
429 429
           rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}");
430 430
         }
431 431
       }
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
    * @throws Exception
442 442
    */
443 443
   public function cookieSet($rememberMe = false, $domain = null) {
444
-    if(!$this->is_exists) {
444
+    if (!$this->is_exists) {
445 445
       throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR);
446 446
     }
447 447
 
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
   // OK v4.1
461 461
   public function cookieClear($domain = null) {
462 462
     // Автоматически вообще-то - если установлена кука имперсонатора - то чистим обычную, а куку имперсонатора - копируем в неё
463
-    if(!empty($_COOKIE[$this->cookie_name_impersonate])) {
463
+    if (!empty($_COOKIE[$this->cookie_name_impersonate])) {
464 464
       sn_setcookie($this->cookie_name, $_COOKIE[$this->cookie_name_impersonate], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $domain);
465 465
       sn_setcookie($this->cookie_name_impersonate, '', SN_TIME_NOW - PERIOD_WEEK, $this->sn_root_path, $domain);
466 466
     } else {
@@ -470,14 +470,14 @@  discard block
 block discarded – undo
470 470
 
471 471
   public function cookieLogin(&$rememberMe = false) {
472 472
     // Пытаемся войти по куке
473
-    if(!empty($_COOKIE[$this->cookie_name])) {
474
-      if(count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) {
473
+    if (!empty($_COOKIE[$this->cookie_name])) {
474
+      if (count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) {
475 475
         list($account_id_unsafe, $cookie_password_hash_salted, $user_remember_me) = explode(AUTH_COOKIE_DELIMETER, $_COOKIE[$this->cookie_name]);
476 476
       } else {
477 477
         list($account_id_unsafe, $user_name, $cookie_password_hash_salted, $user_remember_me) = explode("/%/", $_COOKIE[$this->cookie_name]);
478 478
       }
479 479
 
480
-      if(
480
+      if (
481 481
         $this->db_get_by_id($account_id_unsafe)
482 482
         && ($this->password_encode_for_cookie($this->account_password) == $cookie_password_hash_salted)
483 483
       ) {
Please login to merge, or discard this patch.
classes/Vector.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
   public $type = PT_NONE;
14 14
 
15 15
   public static function _staticInit() {
16
-    if(static::$_isStaticInit) {
16
+    if (static::$_isStaticInit) {
17 17
       return;
18 18
     }
19 19
     static::$knownGalaxies = intval(classSupernova::$config->game_maxGalaxy);
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
   public function __construct($galaxy = 0, $system = 0, $planet = 0, $type = PT_NONE) {
34 34
     // static::_staticInit();
35 35
 
36
-    if(is_string($galaxy) && $galaxy == VECTOR_READ_VECTOR && is_object($system) && $system instanceof Vector) {
36
+    if (is_string($galaxy) && $galaxy == VECTOR_READ_VECTOR && is_object($system) && $system instanceof Vector) {
37 37
       $this->readFromVector($system);
38
-    } elseif(is_string($galaxy) && $galaxy == VECTOR_READ_PARAMS && is_array($system)) {
38
+    } elseif (is_string($galaxy) && $galaxy == VECTOR_READ_PARAMS && is_array($system)) {
39 39
       $this->readFromParamFleets($system);
40 40
     } else {
41 41
       $this->galaxy = intval($galaxy);
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
    * @param Vector $vector
75 75
    */
76 76
   public function distance($vector) {
77
-    if($this->galaxy != $vector->galaxy) {
77
+    if ($this->galaxy != $vector->galaxy) {
78 78
       $distance = abs($this->galaxy - $vector->galaxy) * classSupernova::$config->uni_galaxy_distance;
79
-    } elseif($this->system != $vector->system) {
79
+    } elseif ($this->system != $vector->system) {
80 80
       $distance = abs($this->system - $vector->system) * 5 * 19 + 2700;
81
-    } elseif($this->planet != $vector->planet) {
81
+    } elseif ($this->planet != $vector->planet) {
82 82
       $distance = abs($this->planet - $vector->planet) * 5 + 1000;
83 83
       // TODO - uncomment
84 84
 //    } elseif($this->type != PT_NONE && $vector->type != PT_NONE && $this->type == $vector->type) {
Please login to merge, or discard this patch.
classes/core_auth.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -205,18 +205,18 @@  discard block
 block discarded – undo
205 205
     // TODO Хотя тут может получится вечный цикл - ПОДУМАТЬ
206 206
     // TODO Тут же можно пробовать провести попытку слияния аккаунтов - хотя это и очень небезопасно
207 207
 
208
-    if(sys_get_param('login_player_register_logout')) {
208
+    if (sys_get_param('login_player_register_logout')) {
209 209
       $this->logout();
210 210
     }
211 211
 
212 212
     $original_suggest = '';
213 213
     // Смотрим - есть ли у нас данные от пользователя
214
-    if(($player_name_submitted = sys_get_param('submit_player_name'))) {
214
+    if (($player_name_submitted = sys_get_param('submit_player_name'))) {
215 215
       // Попытка регистрации нового игрока из данных, введенных пользователем
216 216
       $this->player_suggested_name = sys_get_param_str_unsafe('player_suggested_name');
217 217
     } else {
218
-      foreach($this->providers_authorised as $provider) {
219
-        if($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5
218
+      foreach ($this->providers_authorised as $provider) {
219
+        if ($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5
220 220
           $original_suggest = $provider->player_name_suggest();
221 221
           break;
222 222
         }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
     }
225 225
 
226 226
     // Если у нас провайдеры не дают имени и пользователь не дал свой вариант - это у нас первый логин в игру
227
-    if(!$this->player_suggested_name) {
227
+    if (!$this->player_suggested_name) {
228 228
       $max_user_id = db_player_get_max_id(); // 4.5
229 229
       // TODO - предлагать имя игрока по локали
230 230
 
@@ -233,15 +233,15 @@  discard block
 block discarded – undo
233 233
         sn_db_transaction_rollback();
234 234
         $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000);
235 235
         sn_db_transaction_start();
236
-      } while(db_player_name_exists($this->player_suggested_name));
236
+      } while (db_player_name_exists($this->player_suggested_name));
237 237
 
238 238
     }
239 239
 
240
-    if($player_name_submitted) {
240
+    if ($player_name_submitted) {
241 241
       $this->register_player_db_create($this->player_suggested_name); // OK 4.5
242
-      if($this->register_status == LOGIN_SUCCESS) {
242
+      if ($this->register_status == LOGIN_SUCCESS) {
243 243
         sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
244
-      } elseif($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) {
244
+      } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) {
245 245
         // self::$player_suggested_name .= ' ' . $this->account->account_id;
246 246
       }
247 247
 //      if(self::$login_status != LOGIN_SUCCESS) {
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         : false
266 266
       );
267 267
 
268
-    if($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
268
+    if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
269 269
       $prohibited_characters = array_map(function($value) {
270 270
         return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
271 271
       }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
@@ -297,27 +297,27 @@  discard block
 block discarded – undo
297 297
     global $sn_module_list, $lang;
298 298
 
299 299
     // !self::$is_init ? self::init() : false;
300
-    if(empty($sn_module_list['auth'])) {
300
+    if (empty($sn_module_list['auth'])) {
301 301
       die('{Не обнаружено ни одного провайдера авторизации в core_auth::login()!}');
302 302
     }
303 303
 
304 304
     !empty($_POST) ? self::flog(dump($_POST, '$_POST')) : false;
305 305
     !empty($_GET) ? self::flog(dump($_GET, '$_GET')) : false;
306
-    !empty($_COOKIE) ? self::flog(dump($_COOKIE,'$_COOKIE')) : false;
306
+    !empty($_COOKIE) ? self::flog(dump($_COOKIE, '$_COOKIE')) : false;
307 307
 
308 308
     $this->auth_reset(); // OK v4.5
309 309
 
310 310
     $this->providers = array();
311
-    foreach($sn_module_list['auth'] as $module_name => $module) {
311
+    foreach ($sn_module_list['auth'] as $module_name => $module) {
312 312
       $this->providers[$module->provider_id] = $module;
313 313
     }
314 314
 
315 315
     // $this->providers = array_reverse($this->providers, true); // НИНАДА! СН-аккаунт должен всегда авторизироваться первым!
316 316
 //pdump($this->providers);
317
-    foreach($this->providers as $provider_id => $provider) {
317
+    foreach ($this->providers as $provider_id => $provider) {
318 318
       $login_status = $provider->login(); // OK v4.5
319 319
       self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? $lang['sys_login_messages'][$provider->account_login_status] : dump($provider)));
320
-      if($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) {
320
+      if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) {
321 321
         $this->providers_authorised[$provider_id] = &$this->providers[$provider_id];
322 322
 
323 323
         $this->user_id_to_provider = array_replace_recursive(
@@ -325,20 +325,20 @@  discard block
 block discarded – undo
325 325
           // static::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5
326 326
           PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5
327 327
         );
328
-      } elseif($login_status != LOGIN_UNDEFINED) {
328
+      } elseif ($login_status != LOGIN_UNDEFINED) {
329 329
         $this->provider_error_list[$provider_id] = $login_status;
330 330
       }
331 331
     }
332 332
 
333
-    if(empty($this->providers_authorised)) {
333
+    if (empty($this->providers_authorised)) {
334 334
       // Ни один аккаунт не авторизирован
335 335
       // Проверяем - есть ли у нас ошибки в аккаунтах?
336
-      if(!empty($this->provider_error_list)) {
336
+      if (!empty($this->provider_error_list)) {
337 337
         // Если есть - выводим их
338 338
         self::$login_status = reset($this->provider_error_list);
339 339
         $providerError = $this->providers[key($this->provider_error_list)]->account_login_message;
340 340
 
341
-        if(!empty($providerError)) {
341
+        if (!empty($providerError)) {
342 342
           self::$login_message = $providerError;
343 343
         }
344 344
       }
@@ -353,12 +353,12 @@  discard block
 block discarded – undo
353 353
       // В self::$accessible_user_row_list - список доступных игроков для данных аккаунтов с соответствующими записями из таблицы `users`
354 354
 
355 355
       // Остались ли у нас в списке доступные игроки?
356
-      if(empty($this->accessible_user_row_list)) {
356
+      if (empty($this->accessible_user_row_list)) {
357 357
         // Нет ни одного игрока ни на одном авторизированном аккаунте
358 358
         // Надо регать нового игрока
359 359
 
360 360
         // Сейчас происходит процесс регистрации игрока?
361
-        if(!$this->is_player_register) {
361
+        if (!$this->is_player_register) {
362 362
           // Нет - отправляем на процесс регистрации
363 363
           $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id'));
364 364
           sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : ''));
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
         // Да, есть доступные игроки, которые так же прописаны в базе
368 368
         $this->get_active_user(); // 4.5
369 369
 
370
-        if($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) {
370
+        if ($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) {
371 371
           $a_user = db_user_by_id($this->is_impersonating);
372 372
           $this->impersonator_username = $a_user['username'];
373 373
         }
@@ -375,9 +375,9 @@  discard block
 block discarded – undo
375 375
 
376 376
         //Прописываем текущего игрока на все авторизированные аккаунты
377 377
         // TODO - ИЛИ ВСЕХ ИГРОКОВ??
378
-        if(empty($this->is_impersonating)) {
379
-          foreach($this->providers_authorised as $provider_id => $provider) {
380
-            if(empty($this->user_id_to_provider[self::$user['id']][$provider_id])) {
378
+        if (empty($this->is_impersonating)) {
379
+          foreach ($this->providers_authorised as $provider_id => $provider) {
380
+            if (empty($this->user_id_to_provider[self::$user['id']][$provider_id])) {
381 381
               // self::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']);
382 382
               PlayerToAccountTranslate::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']);
383 383
               $this->user_id_to_provider[self::$user['id']][$provider_id][$provider->account->account_id] = true;
@@ -387,9 +387,9 @@  discard block
 block discarded – undo
387 387
       }
388 388
     }
389 389
 
390
-    if(empty(self::$user['id'])) {
390
+    if (empty(self::$user['id'])) {
391 391
       self::cookie_set(''); // OK 4.5
392
-    } elseif(self::$user['id'] != $_COOKIE[SN_COOKIE_U]) {
392
+    } elseif (self::$user['id'] != $_COOKIE[SN_COOKIE_U]) {
393 393
       self::cookie_set(self::$user['id']); // OK 4.5
394 394
     }
395 395
 
@@ -408,21 +408,21 @@  discard block
 block discarded – undo
408 408
    */
409 409
   // OK v4.7
410 410
   public function logout($redirect = true) {
411
-    if(!empty($_COOKIE[SN_COOKIE_U_I])) {
411
+    if (!empty($_COOKIE[SN_COOKIE_U_I])) {
412 412
       self::cookie_set($_COOKIE[SN_COOKIE_U_I]);
413 413
       self::cookie_set(0, true);
414 414
       self::$main_provider->logout();
415 415
     } else {
416
-      foreach($this->providers as $provider_name => $provider) {
416
+      foreach ($this->providers as $provider_name => $provider) {
417 417
         $provider->logout();
418 418
       }
419 419
 
420 420
       self::cookie_set(0);
421 421
     }
422 422
 
423
-    if($redirect === true) {
423
+    if ($redirect === true) {
424 424
       sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php'));
425
-    } elseif($redirect !== false) {
425
+    } elseif ($redirect !== false) {
426 426
       sys_redirect($redirect);
427 427
     }
428 428
   }
@@ -433,15 +433,15 @@  discard block
 block discarded – undo
433 433
    * @param $user_selected
434 434
    */
435 435
   public function impersonate($user_selected) {
436
-    if($_COOKIE[SN_COOKIE_U_I]) {
436
+    if ($_COOKIE[SN_COOKIE_U_I]) {
437 437
       die('You already impersonating someone. Go back to living other\'s life! Or clear your cookies and try again'); // TODO: Log it
438 438
     }
439 439
 
440
-    if($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) {
440
+    if ($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) {
441 441
       die('You can\'t impersonate - too low level'); // TODO: Log it
442 442
     }
443 443
 
444
-    if($this->auth_level_max_local <= $user_selected['authlevel']) {
444
+    if ($this->auth_level_max_local <= $user_selected['authlevel']) {
445 445
       die('You can\'t impersonate this account - level is greater or equal to yours'); // TODO: Log it
446 446
     }
447 447
 
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
     $account_translate = reset($account_translate[$user_selected['id']][self::$main_provider->provider_id]);
450 450
     $account_to_impersonate = new Account(self::$main_provider->db);
451 451
     $account_to_impersonate->db_get_by_id($account_translate['provider_account_id']);
452
-    if(!$account_to_impersonate->is_exists) {
452
+    if (!$account_to_impersonate->is_exists) {
453 453
       die('Какая-то ошибка - не могу найти аккаунт для имперсонации'); // TODO: Log it
454 454
     }
455 455
     self::$main_provider->impersonate($account_to_impersonate);
@@ -475,12 +475,12 @@  discard block
 block discarded – undo
475 475
   public function password_check($password_unsafe) {
476 476
     $result = false;
477 477
 
478
-    if(empty($this->providers_authorised)) {
478
+    if (empty($this->providers_authorised)) {
479 479
       // TODO - такого быть не может!
480 480
       self::flog("password_check: Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true);
481 481
     } else {
482
-      foreach($this->providers_authorised as $provider_id => $provider) {
483
-        if($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) {
482
+      foreach ($this->providers_authorised as $provider_id => $provider) {
483
+        if ($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) {
484 484
           $result = $result || $provider->password_check($password_unsafe);
485 485
         }
486 486
       }
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
   public function password_change($old_password_unsafe, $new_password_unsafe) {
502 502
     global $lang;
503 503
 
504
-    if(empty($this->providers_authorised)) {
504
+    if (empty($this->providers_authorised)) {
505 505
       // TODO - такого быть не может!
506 506
       self::flog("Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true);
507 507
       return false;
@@ -514,8 +514,8 @@  discard block
 block discarded – undo
514 514
     $salt_unsafe = self::password_salt_generate();
515 515
 
516 516
     $providers_changed_password = array();
517
-    foreach($this->providers_authorised as $provider_id => $provider) {
518
-      if(
517
+    foreach ($this->providers_authorised as $provider_id => $provider) {
518
+      if (
519 519
         !$provider->is_feature_supported(AUTH_FEATURE_PASSWORD_CHANGE)
520 520
         || !$provider->password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe)
521 521
       ) {
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
       $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id);
528 528
 
529 529
       // Рассылаем уведомления о смене пароля в ЛС
530
-      foreach($account_translation as $user_id => $provider_info) {
530
+      foreach ($account_translation as $user_id => $provider_info) {
531 531
         // TODO - УКазывать тип аккаунта, на котором сменён пароль
532 532
         msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN,
533 533
           $lang['sys_administration'], $lang['sys_login_register_message_title'],
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
       sn_db_transaction_start();
575 575
       // Проверить наличие такого имени в истории имён
576 576
 
577
-      if(db_player_name_exists($player_name_unsafe)) {
577
+      if (db_player_name_exists($player_name_unsafe)) {
578 578
         throw new Exception(REGISTER_ERROR_PLAYER_NAME_EXISTS, ERR_ERROR);
579 579
       }
580 580
 
@@ -582,11 +582,11 @@  discard block
 block discarded – undo
582 582
       $player_language = '';
583 583
       $player_email = '';
584 584
       // TODO - порнография - работа должна происходить над списком аккаунтов, а не только на одном аккаунте...
585
-      foreach($this->providers_authorised as $provider) {
586
-        if(!$player_language && $provider->account->account_language) {
585
+      foreach ($this->providers_authorised as $provider) {
586
+        if (!$player_language && $provider->account->account_language) {
587 587
           $player_language = $provider->account->account_language;
588 588
         }
589
-        if(!$player_email && $provider->account->account_email) {
589
+        if (!$player_email && $provider->account->account_email) {
590 590
           $player_email = $provider->account->account_email;
591 591
         }
592 592
       }
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
       ));
603 603
       // Зарегестрировать на него аккаунты из self::$accounts_authorised
604 604
       $a_user = self::$user;
605
-      foreach($this->providers_authorised as $provider) {
605
+      foreach ($this->providers_authorised as $provider) {
606 606
         // TODO - порнография. Должен быть отдельный класс трансляторов - в т.ч. и кэширующий транслятор
607 607
         // TODO - ну и работа должна происходить над списком аккаунтов, а не только на одном аккаунте...
608 608
         // self::db_translate_register_user($provider->provider_id, $provider->account->account_id, $a_user['id']);
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 
615 615
       sn_db_transaction_commit();
616 616
       $this->register_status = LOGIN_SUCCESS;
617
-    } catch(Exception $e) {
617
+    } catch (Exception $e) {
618 618
       sn_db_transaction_rollback();
619 619
 
620 620
       // Если старое имя занято
@@ -633,10 +633,10 @@  discard block
 block discarded – undo
633 633
     // Пробиваем все ИД игроков по базе - есть ли вообще такие записи
634 634
     // Вообще-то это не особо нужно - у нас по определению стоят констраинты
635 635
     // Зато так мы узнаем максимальный authlevel, проверим права имперсонейта и вытащим все записи юзеров
636
-    foreach($this->user_id_to_provider as $user_id => $cork) {
636
+    foreach ($this->user_id_to_provider as $user_id => $cork) {
637 637
       $user = db_user_by_id($user_id);
638 638
       // Если записи игрока в БД не существует?
639
-      if(empty($user['id'])) {
639
+      if (empty($user['id'])) {
640 640
         // Удаляем этого и переходим к следующему
641 641
         unset($this->user_id_to_provider[$user_id]);
642 642
         // Де-регистрируем игрока из таблицы трансляции игроков
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
   // OK v4.5
658 658
   protected function get_active_user() {
659 659
     // Проверяем куку "текущего игрока" из браузера
660
-    if(
660
+    if (
661 661
       // Кука не пустая
662 662
       ($_COOKIE[SN_COOKIE_U] = trim($_COOKIE[SN_COOKIE_U])) && !empty($_COOKIE[SN_COOKIE_U])
663 663
       // И в куке находится ID
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
     }
683 683
 
684 684
     // В куке нет валидного ИД записи игрока, доступной с текущих аккаунтов
685
-    if(empty(self::$user['id'])) {
685
+    if (empty(self::$user['id'])) {
686 686
       // Берем первого из доступных
687 687
       // TODO - default_user
688 688
       self::$user = reset($this->accessible_user_row_list);
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 
707 707
     $result = array();
708 708
 
709
-    if($user_id && empty($this->is_impersonating)) {
709
+    if ($user_id && empty($this->is_impersonating)) {
710 710
       // self::db_counter_insert();
711 711
       self::$device->db_counter_insert($user_id);
712 712
 
@@ -714,12 +714,12 @@  discard block
 block discarded – undo
714 714
 
715 715
       sys_user_options_unpack($user);
716 716
 
717
-      if($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) {
717
+      if ($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) {
718 718
         $user['banaday'] = 0;
719 719
         $user['vacation'] = SN_TIME_NOW;
720 720
       }
721 721
 
722
-      $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip'];
722
+      $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip'];
723 723
       $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain'];
724 724
 
725 725
       $result[F_BANNED_STATUS] = $user['banaday'];
@@ -733,13 +733,13 @@  discard block
 block discarded – undo
733 733
       );
734 734
     }
735 735
 
736
-    if($extra = $config->security_ban_extra) {
736
+    if ($extra = $config->security_ban_extra) {
737 737
       $extra = explode(',', $extra);
738
-      array_walk($extra,'trim');
738
+      array_walk($extra, 'trim');
739 739
       in_array(self::$device->device_id, $extra) and die();
740 740
     }
741 741
 
742
-    if(self::$login_message) {
742
+    if (self::$login_message) {
743 743
       $result[F_LOGIN_MESSAGE] = self::$login_message;
744 744
     }
745 745
 
@@ -775,21 +775,21 @@  discard block
 block discarded – undo
775 775
   protected function register_player_name_validate($player_name_unsafe) {
776 776
     // TODO - переделать под RAW-строки
777 777
     // Если имя игрока пустое - NO GO!
778
-    if(trim($player_name_unsafe) == '') {
778
+    if (trim($player_name_unsafe) == '') {
779 779
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_EMPTY, ERR_ERROR);
780 780
     }
781 781
     // Проверяем, что бы в начале и конце не было пустых символов
782
-    if($player_name_unsafe != trim($player_name_unsafe)) {
782
+    if ($player_name_unsafe != trim($player_name_unsafe)) {
783 783
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_TRIMMED, ERR_ERROR);
784 784
     }
785 785
     // Если логин имеет запрещенные символы - NO GO!
786
-    if(strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
786
+    if (strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
787 787
       // TODO - выдавать в сообщение об ошибке список запрещенных символов
788 788
       // TODO - заранее извещать игрока, какие символы являются запрещенными
789 789
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_RESTRICTED_CHARACTERS, ERR_ERROR);
790 790
     }
791 791
     // Если логин меньше минимальной длины - NO GO!
792
-    if(strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) {
792
+    if (strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) {
793 793
       // TODO - выдавать в сообщение об ошибке минимальную длину имени игрока
794 794
       // TODO - заранее извещать игрока, какая минимальная и максимальная длина имени
795 795
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_SHORT, ERR_ERROR);
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
   }
848 848
 
849 849
   protected static function flog($message, $die = false) {
850
-    if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
850
+    if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
851 851
       return;
852 852
     }
853 853
     list($called, $caller) = debug_backtrace(false);
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
     $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false;
861 861
 
862 862
     classSupernova::log_file("$message - $caller_name");
863
-    if($die) {
863
+    if ($die) {
864 864
       $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>");
865 865
     }
866 866
   }
Please login to merge, or discard this patch.
classes/classCache.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -35,19 +35,19 @@  discard block
 block discarded – undo
35 35
   protected static $cacheObject;
36 36
 
37 37
   public function __construct($prefIn = 'CACHE_', $init_mode = false) {
38
-    if( !($init_mode === false || $init_mode === CACHER_NO_CACHE || ($init_mode === CACHER_XCACHE && extension_loaded('xcache')) )) {
38
+    if (!($init_mode === false || $init_mode === CACHER_NO_CACHE || ($init_mode === CACHER_XCACHE && extension_loaded('xcache')))) {
39 39
       throw new UnexpectedValueException('Wrong work mode or current mode does not supported on your server');
40 40
     }
41 41
 
42 42
     $this->prefix = $prefIn;
43
-    if(extension_loaded('xcache') && ($init_mode === CACHER_XCACHE || $init_mode === false)) {
44
-      if(self::$mode === CACHER_NOT_INIT) {
43
+    if (extension_loaded('xcache') && ($init_mode === CACHER_XCACHE || $init_mode === false)) {
44
+      if (self::$mode === CACHER_NOT_INIT) {
45 45
         self::$mode = CACHER_XCACHE;
46 46
       }
47 47
     } else {
48
-      if(self::$mode === CACHER_NOT_INIT) {
48
+      if (self::$mode === CACHER_NOT_INIT) {
49 49
         self::$mode = CACHER_NO_CACHE;
50
-        if(!self::$data) {
50
+        if (!self::$data) {
51 51
          self::$data = array();
52 52
         }
53 53
       }
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
       default:
84 84
         switch (self::$mode) {
85 85
           case CACHER_NO_CACHE:
86
-            self::$data[$this->prefix.$name] = $value;
86
+            self::$data[$this->prefix . $name] = $value;
87 87
           break;
88 88
 
89 89
           case CACHER_XCACHE:
90
-            xcache_set($this->prefix.$name, $value);
90
+            xcache_set($this->prefix . $name, $value);
91 91
           break;
92 92
         }
93 93
       break;
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
       default:
108 108
         switch (self::$mode) {
109 109
           case CACHER_NO_CACHE:
110
-            return self::$data[$this->prefix.$name];
110
+            return self::$data[$this->prefix . $name];
111 111
           break;
112 112
 
113 113
           case CACHER_XCACHE:
114
-            return xcache_get($this->prefix.$name);
114
+            return xcache_get($this->prefix . $name);
115 115
           break;
116 116
 
117 117
         }
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
   public function __isset($name) {
125 125
     switch (self::$mode) {
126 126
       case CACHER_NO_CACHE:
127
-        return isset(self::$data[$this->prefix.$name]);
127
+        return isset(self::$data[$this->prefix . $name]);
128 128
       break;
129 129
 
130 130
       case CACHER_XCACHE:
131
-        return xcache_isset($this->prefix.$name) && ($this->__get($name) !== null);
131
+        return xcache_isset($this->prefix . $name) && ($this->__get($name) !== null);
132 132
       break;
133 133
     }
134 134
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
   public function unset_by_prefix($prefix_unset = '') {
151 151
     static $array_clear;
152
-    !$array_clear ? $array_clear = function(&$v,$k,$p) {
152
+    !$array_clear ? $array_clear = function(&$v, $k, $p) {
153 153
       strpos($k, $p) === 0 ? $v = NULL : false;
154 154
     } : false;
155 155
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
       break;
162 162
 
163 163
       case CACHER_XCACHE:
164
-        if(!function_exists('xcache_unset_by_prefix')) {
164
+        if (!function_exists('xcache_unset_by_prefix')) {
165 165
           return false;
166 166
         }
167 167
         return xcache_unset_by_prefix($this->prefix . $prefix_unset);
@@ -177,13 +177,13 @@  discard block
 block discarded – undo
177 177
   protected function make_element_name($args, $diff = 0) {
178 178
     $num_args = count($args);
179 179
 
180
-    if($num_args < 1) {
180
+    if ($num_args < 1) {
181 181
       return false;
182 182
     }
183 183
 
184 184
     $name = '';
185 185
     $aName = array();
186
-    for($i = 0; $i <= $num_args - 1 - $diff; $i++) {
186
+    for ($i = 0; $i <= $num_args - 1 - $diff; $i++) {
187 187
       $name .= "[{$args[$i]}]";
188 188
       array_unshift($aName, $name);
189 189
     }
@@ -195,15 +195,15 @@  discard block
 block discarded – undo
195 195
     $args = func_get_args();
196 196
     $name = $this->make_element_name($args, 1);
197 197
 
198
-    if(!$name) {
198
+    if (!$name) {
199 199
       return NULL;
200 200
     }
201 201
 
202
-    if($this->$name[0] === NULL) {
203
-      for($i = count($name) - 1; $i > 0; $i--) {
202
+    if ($this->$name[0] === NULL) {
203
+      for ($i = count($name) - 1; $i > 0; $i--) {
204 204
         $cName = "{$name[$i]}_COUNT";
205
-        $cName1 = "{$name[$i-1]}_COUNT";
206
-        if($this->$cName1 == NULL || $i == 1) {
205
+        $cName1 = "{$name[$i - 1]}_COUNT";
206
+        if ($this->$cName1 == NULL || $i == 1) {
207 207
           $this->$cName++;
208 208
         }
209 209
       }
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 
216 216
   public function array_get() {
217 217
     $name = $this->make_element_name(func_get_args());
218
-    if(!$name) {
218
+    if (!$name) {
219 219
       return NULL;
220 220
     }
221 221
     return $this->$name[0];
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
 
224 224
   public function array_count() {
225 225
     $name = $this->make_element_name(func_get_args());
226
-    if(!$name) {
226
+    if (!$name) {
227 227
       return 0;
228 228
     }
229 229
     $cName = "{$name[0]}_COUNT";
230 230
     $retVal = $this->$cName;
231
-    if(!$retVal) {
231
+    if (!$retVal) {
232 232
       $retVal = NULL;
233 233
     }
234 234
     return $retVal;
@@ -237,18 +237,18 @@  discard block
 block discarded – undo
237 237
   public function array_unset() {
238 238
     $name = $this->make_element_name(func_get_args());
239 239
 
240
-    if(!$name) {
240
+    if (!$name) {
241 241
       return false;
242 242
     }
243 243
     $this->unset_by_prefix($name[0]);
244 244
 
245
-    for($i = 1; $i < count($name); $i++) {
245
+    for ($i = 1; $i < count($name); $i++) {
246 246
       $cName = "{$name[$i]}_COUNT";
247
-      $cName1 = "{$name[$i-1]}_COUNT";
247
+      $cName1 = "{$name[$i - 1]}_COUNT";
248 248
 
249
-      if($i == 1 || $this->$cName1 === NULL) {
249
+      if ($i == 1 || $this->$cName1 === NULL) {
250 250
         $this->$cName--;
251
-        if($this->$cName <= 0) {
251
+        if ($this->$cName <= 0) {
252 252
           unset($this->$cName);
253 253
         }
254 254
       }
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.