Completed
Push — work-fleets ( 22b5bc...08ace7 )
by SuperNova.WS
06:13
created
common.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,25 +12,25 @@  discard block
 block discarded – undo
12 12
 global $debug, $sn_mvc, $template_result, $user;
13 13
 
14 14
 // Напоминание для Администрации, что игра отключена
15
-if($template_result[F_GAME_DISABLE]) {
15
+if ($template_result[F_GAME_DISABLE]) {
16 16
   // $disable_reason = sys_bbcodeParse($config->game_disable_reason); // Должна быть инициализирована выше по коду - в init.php
17 17
   echo '<div class="global_admin_warning">', $template_result[F_GAME_DISABLE_REASON], '</div>';
18 18
 }
19 19
 unset($disable_reason);
20 20
 
21 21
 
22
-if(defined('IN_ADMIN') && IN_ADMIN === true) {
22
+if (defined('IN_ADMIN') && IN_ADMIN === true) {
23 23
   lng_include('admin');
24
-} elseif($sys_user_logged_in) {
24
+} elseif ($sys_user_logged_in) {
25 25
   sys_user_vacation($user);
26 26
 
27 27
   $planet_id = SetSelectedPlanet($user);
28 28
 
29 29
   // TODO НЕ НУЖНО АЛЬЯНС КАЖДЫЙ РАЗ ОБНОВЛЯТЬ!!!
30
-  if($user['ally_id']) {
30
+  if ($user['ally_id']) {
31 31
     sn_db_transaction_start();
32 32
     sn_ali_fill_user_ally($user);
33
-    if(!$user['ally']['player']['id']) {
33
+    if (!$user['ally']['player']['id']) {
34 34
       // sn_sys_logout(false, true);
35 35
       // core_auth::logout(false);
36 36
       classSupernova::$auth->logout(false);
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
   sn_db_transaction_commit();
50 50
 
51 51
   $planetrow = $global_data['planet'];
52
-  if(!($planetrow && isset($planetrow['id']) && $planetrow['id'])) {
52
+  if (!($planetrow && isset($planetrow['id']) && $planetrow['id'])) {
53 53
     // sn_sys_logout(false, true);
54 54
     // core_auth::logout(false);
55 55
     classSupernova::$auth->logout(false);
Please login to merge, or discard this patch.
includes/functions/_news.php 1 patch
Spacing   +14 added lines, -15 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@  discard block
 block discarded – undo
11 11
   $announce_list = db_news_list_get_by_query($template, $query_where, $query_limit);
12 12
 
13 13
   $users = array();
14
-  while($announce = db_fetch($announce_list)) {
15
-    if($announce['user_id'] && !isset($users[$announce['user_id']])) {
14
+  while ($announce = db_fetch($announce_list)) {
15
+    if ($announce['user_id'] && !isset($users[$announce['user_id']])) {
16 16
       $users[$announce['user_id']] = db_user_by_id($announce['user_id']);
17 17
     }
18 18
 
19 19
     $survey_vote = array('survey_vote_id' => 1);
20 20
     $survey_complete = strtotime($announce['survey_until']) < SN_TIME_NOW;
21 21
 
22
-    if($announce['survey_id'] && !empty($user['id'])) {
22
+    if ($announce['survey_id'] && !empty($user['id'])) {
23 23
       $survey_vote = !$survey_complete ? db_survey_get_vote($announce, $user) : array();
24 24
     }
25 25
 
@@ -31,8 +31,7 @@  discard block
 block discarded – undo
31 31
       'ANNOUNCE'        => cht_message_parse($announce['strAnnounce'], false, intval($announce['authlevel'])),
32 32
       'DETAIL_URL'      => $announce['detail_url'],
33 33
       'USER_NAME'       =>
34
-        isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) :
35
-          js_safe_string($announce['user_name']),
34
+        isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) : js_safe_string($announce['user_name']),
36 35
       'NEW'             => $announce['unix_time'] + $config->game_news_actual >= SN_TIME_NOW,
37 36
       'FUTURE'          => $announce['unix_time'] > SN_TIME_NOW,
38 37
       'SURVEY_ID'       => $announce['survey_id'],
@@ -42,25 +41,25 @@  discard block
 block discarded – undo
42 41
       'SURVEY_UNTIL'    => $announce['survey_until'],
43 42
     ));
44 43
 
45
-    foreach($announce_exploded as $announce_paragraph) {
44
+    foreach ($announce_exploded as $announce_paragraph) {
46 45
       $template->assign_block_vars('announces.paragraph', array(
47 46
         'TEXT' => $announce_paragraph,
48 47
       ));
49 48
     }
50 49
 
51
-    if($announce['survey_id']) {
50
+    if ($announce['survey_id']) {
52 51
       $survey_query = db_survey_get_answer_texts($announce);
53 52
       $survey_vote_result = array();
54 53
       $total_votes = 0;
55
-      while($row = db_fetch($survey_query)) {
54
+      while ($row = db_fetch($survey_query)) {
56 55
         $survey_vote_result[] = $row;
57 56
         $total_votes += $row['VOTES'];
58 57
       }
59 58
 
60
-      if(empty($survey_vote) && !$survey_complete) {
59
+      if (empty($survey_vote) && !$survey_complete) {
61 60
         // Can vote
62 61
         $survey_query = db_survey_answers_get_list_by_parent($announce);
63
-        while($row = db_fetch($survey_query)) {
62
+        while ($row = db_fetch($survey_query)) {
64 63
           $template->assign_block_vars('announces.survey_answers', array(
65 64
             'ID'   => $row['survey_answer_id'],
66 65
             'TEXT' => $row['survey_answer_text'],
@@ -68,7 +67,7 @@  discard block
 block discarded – undo
68 67
         }
69 68
       } else {
70 69
         // Show result
71
-        foreach($survey_vote_result as &$vote_result) {
70
+        foreach ($survey_vote_result as &$vote_result) {
72 71
           $vote_percent = $total_votes ? $vote_result['VOTES'] / $total_votes * 100 : 0;
73 72
           $vote_result['PERCENT'] = $vote_percent;
74 73
           $vote_result['PERCENT_TEXT'] = round($vote_percent, 1);
@@ -85,7 +84,7 @@  discard block
 block discarded – undo
85 84
 }
86 85
 
87 86
 function nws_mark_read(&$user) {
88
-  if(isset($user['id'])) {
87
+  if (isset($user['id'])) {
89 88
     db_user_set_by_id($user['id'], '`news_lastread` = ' . SN_TIME_NOW);
90 89
     $user['news_lastread'] = SN_TIME_NOW;
91 90
   }
@@ -94,17 +93,17 @@  discard block
 block discarded – undo
94 93
 }
95 94
 
96 95
 function survey_vote(&$user) {
97
-  if(empty($user['id'])) {
96
+  if (empty($user['id'])) {
98 97
     return true;
99 98
   }
100 99
 
101 100
   sn_db_transaction_start();
102 101
   $survey_id = sys_get_param_id('survey_id');
103 102
   $is_voted = db_survey_vote_get($user, $survey_id);
104
-  if(empty($is_voted)) {
103
+  if (empty($is_voted)) {
105 104
     $survey_vote_id = sys_get_param_id('survey_vote');
106 105
     $is_answer_exists = db_survey_answer_get($survey_id, $survey_vote_id);
107
-    if(!empty($is_answer_exists)) {
106
+    if (!empty($is_answer_exists)) {
108 107
       $user_name_safe = db_escape($user['username']);
109 108
       db_survey_vote_insert($user, $survey_id, $survey_vote_id, $user_name_safe);
110 109
     }
Please login to merge, or discard this patch.
includes/classes/db_mysql.php 1 patch
Doc Comments   +30 added lines, -5 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
   /**
158 158
    * @param string $query
159 159
    *
160
-   * @return mixed|string
160
+   * @return string
161 161
    */
162 162
   public function replaceTablePlaceholders($query) {
163 163
     $sql = $query;
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
   }
172 172
 
173 173
   /**
174
-   * @param $query
174
+   * @param string $query
175 175
    */
176 176
   protected function logQuery($query) {
177 177
     if (!classSupernova::$config->debug) {
@@ -301,6 +301,11 @@  discard block
 block discarded – undo
301 301
 
302 302
 
303 303
   // INSERT/REPLACE
304
+
305
+  /**
306
+   * @param string $table
307
+   * @param integer $replace
308
+   */
304 309
   protected function doSet($table, $fieldsAndValues, $replace = DB_INSERT_PLAIN) {
305 310
     $query = DbQuery::build($this)
306 311
       ->setTable($table)
@@ -338,6 +343,10 @@  discard block
 block discarded – undo
338 343
 
339 344
 
340 345
   // INSERTERS
346
+
347
+  /**
348
+   * @param string $query
349
+   */
341 350
   public function doInsertComplex($query) {
342 351
     return $this->doSql($query);
343 352
   }
@@ -355,7 +364,7 @@  discard block
 block discarded – undo
355 364
    * Values should be passed as-is
356 365
    *
357 366
    * @param string   $table
358
-   * @param array    $fields
367
+   * @param string[]    $fields
359 368
    * @param string[] $values
360 369
    *
361 370
    * @return array|bool|mysqli_result|null
@@ -407,7 +416,7 @@  discard block
 block discarded – undo
407 416
    * Self-contained - means no params used
408 417
    * Such queries usually used to make large amount of in-base calculations
409 418
    *
410
-   * @param $query
419
+   * @param string $query
411 420
    *
412 421
    * @return array|bool|mysqli_result|null
413 422
    */
@@ -425,13 +434,16 @@  discard block
 block discarded – undo
425 434
   }
426 435
 
427 436
   /**
428
-   * @param $DbQuery DbQuery
437
+   * @param DbQuery $DbQuery DbQuery
429 438
    */
430 439
   public function doUpdateDbQueryAdjust($DbQuery) {
431 440
     return $this->doUpdateDbQuery($DbQuery);
432 441
   }
433 442
 
434 443
 
444
+  /**
445
+   * @param boolean $isOneRecord
446
+   */
435 447
   protected function doUpdateWhere($table, $fieldsSet, $fieldsAdjust = array(), $where = array(), $isOneRecord = DB_RECORDS_ALL, $whereDanger = array()) {
436 448
 //    $query = DbQuery::build($this)
437 449
 //      ->setTable($table)
@@ -467,10 +479,16 @@  discard block
 block discarded – undo
467 479
     return $this->doSql($query);
468 480
   }
469 481
 
482
+  /**
483
+   * @param string $table
484
+   */
470 485
   public function doUpdateRowSet($table, $fieldsAndValues, $where) {
471 486
     return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORD_ONE);
472 487
   }
473 488
 
489
+  /**
490
+   * @param string $table
491
+   */
474 492
   public function doUpdateTableSet($table, $fieldsAndValues, $where = array()) {
475 493
     return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORDS_ALL);
476 494
   }
@@ -677,6 +695,10 @@  discard block
 block discarded – undo
677 695
   }
678 696
 
679 697
   // TODO Заменить это на новый логгер
698
+
699
+  /**
700
+   * @param string $query
701
+   */
680 702
   protected function security_watch_user_queries($query) {
681 703
     global $user;
682 704
 
@@ -700,6 +722,9 @@  discard block
 block discarded – undo
700 722
   }
701 723
 
702 724
 
725
+  /**
726
+   * @param string $query
727
+   */
703 728
   public function security_query_check_bad_words($query) {
704 729
     if ($this->skipQueryCheck) {
705 730
       return;
Please login to merge, or discard this patch.
includes/classes/DBStaticUser.php 2 patches
Doc Comments   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -104,6 +104,9 @@  discard block
 block discarded – undo
104 104
     return $result;
105 105
   }
106 106
 
107
+  /**
108
+   * @param integer $config_user_birthday_range
109
+   */
107 110
   public static function db_user_list_to_celebrate($config_user_birthday_range) {
108 111
     $query = static::buildDBQ()
109 112
       ->field('id', 'username', 'user_birthday', 'user_birthday_celebrated')
@@ -193,6 +196,9 @@  discard block
 block discarded – undo
193 196
   }
194 197
 
195 198
 
199
+  /**
200
+   * @param string $username_unsafe
201
+   */
196 202
   public static function db_user_by_username($username_unsafe, $for_update = false, $fields = '*', $player = null, $like = false) {
197 203
     // TODO Проверить, кстати - а везде ли нужно выбирать юзеров или где-то все-таки ищутся Альянсы ?
198 204
     if (!($username_unsafe = trim($username_unsafe))) {
@@ -247,7 +253,6 @@  discard block
 block discarded – undo
247 253
 
248 254
   /**
249 255
    * @param $user_id
250
-   * @param array $set
251 256
    * @param array $adjust
252 257
    *
253 258
    * @return array|bool|mysqli_result|null
@@ -264,8 +269,8 @@  discard block
 block discarded – undo
264 269
    *    <p>array - запись пользователя с установленным полем ['id']</p>
265 270
    * @param bool      $for_update @deprecated
266 271
    * @param string    $fields @deprecated список полей или '*'/'' для всех полей
267
-   * @param null      $player
268
-   * @param bool|null $player Признак выбора записи пользователь типа "игрок"
272
+   * @param boolean      $player
273
+   * @param boolean $player Признак выбора записи пользователь типа "игрок"
269 274
    *    <p>null - Можно выбрать запись любого типа</p>
270 275
    *    <p>true - Выбирается только запись типа "игрок"</p>
271 276
    *    <p>false - Выбирается только запись типа "альянс"</p>
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
         ->where('`user_as_ally` IS NULL')
24 24
         ->orderBy(array('`id` DESC'));
25 25
 
26
-    return (string)$query->selectValue();
26
+    return (string) $query->selectValue();
27 27
   }
28 28
 
29 29
   /**
@@ -48,15 +48,15 @@  discard block
 block discarded – undo
48 48
       static::buildDBQ()
49 49
         ->field('id')
50 50
         ->where("`user_as_ally` IS NULL")
51
-        ->where("`user_bot` = " . USER_BOT_PLAYER)
51
+        ->where("`user_bot` = ".USER_BOT_PLAYER)
52 52
         ->setForUpdate();
53 53
 
54 54
     return $query->selectIterator();
55 55
   }
56 56
 
57 57
   public static function db_user_lock_with_target_owner_and_acs($user, $planet = array()) {
58
-    $query = "SELECT 1 FROM `{{users}}` WHERE `id` = " . idval($user['id']) .
59
-      (!empty($planet['id_owner']) ? ' OR `id` = ' . idval($planet['id_owner']) : '')
58
+    $query = "SELECT 1 FROM `{{users}}` WHERE `id` = ".idval($user['id']).
59
+      (!empty($planet['id_owner']) ? ' OR `id` = '.idval($planet['id_owner']) : '')
60 60
       . " FOR UPDATE";
61 61
 
62 62
     static::getDb()->doSelect($query);
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
       FROM `{{users}}` 
74 74
       WHERE 
75 75
         `user_as_ally` IS NULL" .
76
-        ($online ? ' AND `onlinetime` > ' . (SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '')
76
+        ($online ? ' AND `onlinetime` > '.(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '')
77 77
     ));
78 78
   }
79 79
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
       ->fieldCount('r.id', 'referral_count')
96 96
       ->fieldSingleFunction('sum', 'r.dark_matter', 'referral_dm')
97 97
       ->join('LEFT JOIN {{referrals}} as r on r.id_partner = u.id')
98
-      ->where($online ? "`onlinetime` >= " . intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL')
98
+      ->where($online ? "`onlinetime` >= ".intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL')
99 99
       ->groupBy('u.id')
100 100
       ->orderBy("user_as_ally, {$sort} ASC");
101 101
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
       ->where('(`user_birthday_celebrated` IS NULL OR DATE_ADD(`user_birthday_celebrated`, INTERVAL 1 YEAR) < CURRENT_DATE)')
114 114
       ->where('`user_as_ally` IS NULL')
115 115
       ->having('`days_after_birthday` >= 0')
116
-      ->having('`days_after_birthday` < ' . intval($config_user_birthday_range))
116
+      ->having('`days_after_birthday` < '.intval($config_user_birthday_range))
117 117
       ->setForUpdate();
118 118
 
119 119
     $result = $query->selectIterator();
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
       $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет
223 223
 
224 224
       $user = classSupernova::$db->doSelectFetch(
225
-        "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'"
225
+        "SELECT * FROM {{users}} WHERE `username` ".($like ? 'LIKE' : '=')." '{$username_safe}'"
226 226
         . " FOR UPDATE"
227 227
       );
228 228
       classSupernova::$gc->snCache->cache_set(LOC_USER, $user); // В кэш-юзер так же заполнять индексы
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
    * @param array $playerArray
314 314
    */
315 315
   public static function renderNameAndCoordinates($playerArray) {
316
-    return "{$playerArray['username']} " . uni_render_coordinates($playerArray);
316
+    return "{$playerArray['username']} ".uni_render_coordinates($playerArray);
317 317
   }
318 318
 
319 319
   /**
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
     foreach ($playerRowFieldChanges as $resourceId => $value) {
348 348
       $fields[pname_resource_name($resourceId)] = $value;
349 349
     }
350
-    if(!empty($fields)) {
350
+    if (!empty($fields)) {
351 351
       classSupernova::$gc->db->doUpdateRowAdjust(
352 352
         TABLE_USERS,
353 353
         array(),
Please login to merge, or discard this patch.
includes/db.php 2 patches
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,6 @@  discard block
 block discarded – undo
16 16
  * @param       $user
17 17
  * @param       $planet
18 18
  * @param array $unit_list
19
- * @param null  $query
20 19
  */
21 20
 function db_change_resources(&$user, &$planet, $unit_list) {
22 21
   $group = sn_get_groups('resources_loot');
@@ -56,6 +55,9 @@  discard block
 block discarded – undo
56 55
 
57 56
 }
58 57
 
58
+/**
59
+ * @param boolean $transaction_should_be_started
60
+ */
59 61
 function sn_db_transaction_check($transaction_should_be_started = null) {
60 62
   return classSupernova::$gc->db->getTransaction()->check($transaction_should_be_started);
61 63
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,22 +24,22 @@
 block discarded – undo
24 24
   $locationType = sys_get_unit_location($user, $planet, key($unit_list));
25 25
 
26 26
   $resourcesChange = array();
27
-  foreach($unit_list as $unit_id => $unit_amount) {
28
-    if(!in_array($unit_id, $group)) {
27
+  foreach ($unit_list as $unit_id => $unit_amount) {
28
+    if (!in_array($unit_id, $group)) {
29 29
       // TODO - remove later
30 30
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: db_change_resources() вызван для не-ресурсов!</h1>');
31 31
       pdump(debug_backtrace());
32 32
       die('db_change_resources() вызван для не-ресурсов!');
33 33
     }
34 34
 
35
-    if(empty($unit_amount)) {
35
+    if (empty($unit_amount)) {
36 36
       continue;
37 37
     }
38 38
 
39 39
     $resourcesChange[pname_resource_name($unit_id)] += $unit_amount;
40 40
   }
41 41
 
42
-  if($locationType == LOC_USER) {
42
+  if ($locationType == LOC_USER) {
43 43
     $locationId = $user['id'];
44 44
   } else {
45 45
     $locationId = $planet['id'];
Please login to merge, or discard this patch.
resources.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *
23 23
  **/
24 24
 
25
-include('common.' . substr(strrchr(__FILE__, '.'), 1));
25
+include('common.'.substr(strrchr(__FILE__, '.'), 1));
26 26
 
27 27
 /**
28 28
  * @param          $resource_id
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
   $storage_fill = $caps_real['total_storage'][$resource_id] ? floor(mrc_get_level($user, $planetrow, $resource_id) / $caps_real['total_storage'][$resource_id] * 100) : 0;
37 37
 
38 38
   $template->assign_block_vars('resources', array(
39
-    'NAME' => classLocale::$lang["sys_" . pname_resource_name($resource_id)],
39
+    'NAME' => classLocale::$lang["sys_".pname_resource_name($resource_id)],
40 40
 
41 41
     'HOURLY'  => pretty_number($totalProduction, true, true),
42 42
     'WEEKLY'  => pretty_number($totalProduction * 24 * 7, true, true),
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
       $planetrow[$field_name] = $percent;
77 77
       $SubQry[$field_name] = $percent;
78 78
     } else {
79
-      classSupernova::$debug->warning('Supplying wrong ID in production array - attempt to change some field - ID' . $prod_id, 'Resource Page', 301);
79
+      classSupernova::$debug->warning('Supplying wrong ID in production array - attempt to change some field - ID'.$prod_id, 'Resource Page', 301);
80 80
       continue;
81 81
     }
82 82
   }
83 83
 
84
-  if(!empty($SubQry)) {
84
+  if (!empty($SubQry)) {
85 85
     DBStaticPlanet::db_planet_update_set_by_id(
86 86
       $planetrow['id'],
87 87
       $SubQry
Please login to merge, or discard this patch.
phalanx.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,24 +11,24 @@  discard block
 block discarded – undo
11 11
  * @copyright 2008 by Pada for XNova.project.es
12 12
  */
13 13
 
14
-include('common.' . substr(strrchr(__FILE__, '.'), 1));
14
+include('common.'.substr(strrchr(__FILE__, '.'), 1));
15 15
 
16 16
 lng_include('overview');
17 17
 lng_include('universe');
18 18
 
19 19
 $sensorLevel = mrc_get_level($user, $planetrow, STRUC_MOON_PHALANX);
20 20
 if (!intval($sensorLevel)) {
21
-  message (classLocale::$lang['phalanx_nosensoravailable'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3);
21
+  message(classLocale::$lang['phalanx_nosensoravailable'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3);
22 22
 }
23 23
 
24 24
 if ($planetrow['planet_type'] != PT_MOON) {
25
-  message (classLocale::$lang['phalanx_onlyformoons'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3);
25
+  message(classLocale::$lang['phalanx_onlyformoons'], classLocale::$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 (classLocale::$lang['phalanx_rangeerror'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3);
43
+  message(classLocale::$lang['phalanx_rangeerror'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3);
44 44
 }
45 45
 
46 46
 $cost = $sensorLevel * 1000;
@@ -51,20 +51,20 @@  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(classLocale::$lang['phalanx_planet_not_exists'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3);
57 57
 }
58 58
 
59
-if($planet_scanned['destruyed'])
59
+if ($planet_scanned['destruyed'])
60 60
 {
61
-  message (classLocale::$lang['phalanx_planet_destroyed'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3);
61
+  message(classLocale::$lang['phalanx_planet_destroyed'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3);
62 62
 }
63 63
 
64 64
 DBStaticPlanet::db_planet_update_adjust_by_id(
65 65
   $user['current_planet'],
66 66
   array(
67
-    'deuterium' => - $cost,
67
+    'deuterium' => -$cost,
68 68
   )
69 69
 );
70 70
 
Please login to merge, or discard this patch.
overview.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
 //define('SN_RENDER_NAVBAR_PLANET', false);
32 32
 
33
-include('common.' . substr(strrchr(__FILE__, '.'), 1));
33
+include('common.'.substr(strrchr(__FILE__, '.'), 1));
34 34
 
35 35
 //$ccc = 0;
36 36
 //foreach(DBStaticUser::db_user_list_non_bots() as $ip) {
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 $result = array();
51 51
 
52
-switch($mode = sys_get_param_str('mode')) {
52
+switch ($mode = sys_get_param_str('mode')) {
53 53
   case 'manage':
54 54
     sn_sys_sector_buy('overview.php?mode=manage');
55 55
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     $template  = gettemplate('planet_manage', true);
60 60
     $planet_id = sys_get_param_id('planet_id');
61 61
 
62
-    if(sys_get_param_str('rename') && ($new_name_unsafe = sys_get_param_str_unsafe('new_name'))) {
62
+    if (sys_get_param_str('rename') && ($new_name_unsafe = sys_get_param_str_unsafe('new_name'))) {
63 63
       $planetrow['name'] = $new_name_unsafe;
64 64
       DBStaticPlanet::db_planet_update_set_by_id(
65 65
         $planetrow['id'],
@@ -67,21 +67,21 @@  discard block
 block discarded – undo
67 67
           'name' => $new_name_unsafe,
68 68
         )
69 69
       );
70
-    } elseif(sys_get_param_str('action') == 'make_capital') {
70
+    } elseif (sys_get_param_str('action') == 'make_capital') {
71 71
       try {
72 72
         sn_db_transaction_start();
73 73
         $user = DBStaticUser::db_user_by_id($user['id'], true, '*');
74 74
         $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true, '*');
75 75
 
76
-        if($planetrow['planet_type'] != PT_PLANET) {
76
+        if ($planetrow['planet_type'] != PT_PLANET) {
77 77
           throw new exception(classLocale::$lang['ov_capital_err_not_a_planet'], ERR_ERROR);
78 78
         }
79 79
 
80
-        if($planetrow['id'] == $user['id_planet']) {
80
+        if ($planetrow['id'] == $user['id_planet']) {
81 81
           throw new exception(classLocale::$lang['ov_capital_err_capital_already'], ERR_ERROR);
82 82
         }
83 83
 
84
-        if($user_dark_matter < classSupernova::$config->planet_capital_cost) {
84
+        if ($user_dark_matter < classSupernova::$config->planet_capital_cost) {
85 85
           throw new exception(classLocale::$lang['ov_capital_err_no_dark_matter'], ERR_ERROR);
86 86
         }
87 87
 
@@ -106,16 +106,16 @@  discard block
 block discarded – undo
106 106
         );
107 107
         sn_db_transaction_commit();
108 108
         sys_redirect('overview.php?mode=manage');
109
-      } catch(exception $e) {
109
+      } catch (exception $e) {
110 110
         sn_db_transaction_rollback();
111 111
         $result[] = array(
112 112
           'STATUS'  => $e->getCode(),
113 113
           'MESSAGE' => $e->getMessage(),
114 114
         );
115 115
       }
116
-    } elseif(sys_get_param_str('action') == 'planet_teleport') {
116
+    } elseif (sys_get_param_str('action') == 'planet_teleport') {
117 117
       try {
118
-        if(!uni_coordinates_valid($new_coordinates = array(
118
+        if (!uni_coordinates_valid($new_coordinates = array(
119 119
           'galaxy' => sys_get_param_int('new_galaxy'),
120 120
           'system' => sys_get_param_int('new_system'),
121 121
           'planet' => sys_get_param_int('new_planet')))
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 //        $planetrow = $global_data['planet'];
133 133
 
134 134
         $can_teleport = uni_planet_teleport_check($user, $planetrow, $new_coordinates);
135
-        if($can_teleport['result'] != ERR_NONE) {
135
+        if ($can_teleport['result'] != ERR_NONE) {
136 136
           throw new exception($can_teleport['message'], $can_teleport['result']);
137 137
         }
138 138
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
           array()
152 152
         );
153 153
 
154
-        if($planetrow['id'] == $user['id_planet']) {
154
+        if ($planetrow['id'] == $user['id_planet']) {
155 155
           DBStaticUser::db_user_set_by_id(
156 156
             $user['id'],
157 157
             array(
@@ -171,17 +171,17 @@  discard block
 block discarded – undo
171 171
           'MESSAGE' => classLocale::$lang['ov_teleport_err_none'],
172 172
         );
173 173
         sys_redirect('overview.php?mode=manage');
174
-      } catch(exception $e) {
174
+      } catch (exception $e) {
175 175
         sn_db_transaction_rollback();
176 176
         $result[] = array(
177 177
           'STATUS'  => $e->getCode(),
178 178
           'MESSAGE' => $e->getMessage(),
179 179
         );
180 180
       }
181
-    } elseif(sys_get_param_str('action') == 'planet_abandon') {
181
+    } elseif (sys_get_param_str('action') == 'planet_abandon') {
182 182
       // if(sec_password_check($user['id'], sys_get_param('abandon_confirm'))) {
183
-      if(classSupernova::$auth->password_check(sys_get_param('abandon_confirm'))) {
184
-        if($user['id_planet'] != $user['current_planet'] && $user['current_planet'] == $planet_id) {
183
+      if (classSupernova::$auth->password_check(sys_get_param('abandon_confirm'))) {
184
+        if ($user['id_planet'] != $user['current_planet'] && $user['current_planet'] == $planet_id) {
185 185
           $destroyed = SN_TIME_NOW + 60 * 60 * 24;
186 186
           DBStaticPlanet::db_planet_update_set_by_id(
187 187
             $user['current_planet'],
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
           message(classLocale::$lang['ov_delete_wrong_planet'], classLocale::$lang['colony_abandon'], 'overview.php?mode=manage');
208 208
         }
209 209
       } else {
210
-        message(classLocale::$lang['ov_delete_wrong_pass'] , classLocale::$lang['colony_abandon'], 'overview.php?mode=manage');
210
+        message(classLocale::$lang['ov_delete_wrong_pass'], classLocale::$lang['colony_abandon'], 'overview.php?mode=manage');
211 211
       }
212
-    } elseif(
212
+    } elseif (
213 213
       ($hire = sys_get_param_int('hire')) && in_array($hire, sn_get_groups('governors'))
214 214
       && (
215 215
         !get_unit_param($hire, P_MAX_STACK) ||
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
       $user = DBStaticUser::db_user_by_id($user['id'], true);
225 225
       $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true);
226 226
       $build_data = eco_get_build_data($user, $planetrow, $hire, $planetrow['PLANET_GOVERNOR_ID'] == $hire ? $planetrow['PLANET_GOVERNOR_LEVEL'] : 0);
227
-      if($build_data['CAN'][BUILD_CREATE]) {
228
-        if($planetrow['PLANET_GOVERNOR_ID'] == $hire) {
227
+      if ($build_data['CAN'][BUILD_CREATE]) {
228
+        if ($planetrow['PLANET_GOVERNOR_ID'] == $hire) {
229 229
           $planetrow['PLANET_GOVERNOR_LEVEL']++;
230 230
         } else {
231 231
           $planetrow['PLANET_GOVERNOR_LEVEL'] = 1;
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
 
258 258
     lng_include('mrc_mercenary');
259 259
     int_planet_pretemplate($planetrow, $template);
260
-    foreach(sn_get_groups('governors') as $governor_id) {
261
-      if($planetrow['planet_type'] == PT_MOON && $governor_id == MRC_TECHNOLOGIST) {
260
+    foreach (sn_get_groups('governors') as $governor_id) {
261
+      if ($planetrow['planet_type'] == PT_MOON && $governor_id == MRC_TECHNOLOGIST) {
262 262
         continue;
263 263
       }
264 264
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
       'PAGE_HINT'   => classLocale::$lang['ov_manage_page_hint'],
311 311
     ));
312 312
 
313
-    foreach($result as &$a_result) {
313
+    foreach ($result as &$a_result) {
314 314
       $template->assign_block_vars('result', $a_result);
315 315
     }
316 316
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
   default:
321 321
     sn_sys_sector_buy();
322 322
 
323
-    if(sys_get_param_str('rename') && $new_name_unsafe = sys_get_param_str_unsafe('new_name')) {
323
+    if (sys_get_param_str('rename') && $new_name_unsafe = sys_get_param_str_unsafe('new_name')) {
324 324
       $planetrow['name'] = $new_name_unsafe;
325 325
       DBStaticPlanet::db_planet_update_set_by_id(
326 326
         $planetrow['id'],
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 
356 356
     $planet_count = 0;
357 357
     $planets_query = DBStaticPlanet::db_planet_list_sorted($user, false, '*');
358
-    foreach($planets_query as $an_id => $UserPlanet) {
358
+    foreach ($planets_query as $an_id => $UserPlanet) {
359 359
       sn_db_transaction_start();
360 360
       $UserPlanet = sys_o_get_updated($user, $UserPlanet['id'], SN_TIME_NOW, false, true);
361 361
       sn_db_transaction_commit();
@@ -366,16 +366,16 @@  discard block
 block discarded – undo
366 366
 
367 367
       $planet_fleet_id = 0;
368 368
       $fleet_list = $template_planet['fleet_list'];
369
-      if($fleet_list['own']['count']) {
369
+      if ($fleet_list['own']['count']) {
370 370
         $planet_fleet_id = "p{$UserPlanet['id']}";
371 371
         $fleets_to_planet[$UserPlanet['id']] = tpl_parse_fleet_sn($fleet_list['own']['total'], $planet_fleet_id);
372 372
 //        $fleet_id++;tpl_parse_fleet_sn
373 373
       }
374
-      if($UserPlanet['planet_type'] == PT_MOON) {
374
+      if ($UserPlanet['planet_type'] == PT_MOON) {
375 375
         continue;
376 376
       }
377 377
       $moon = DBStaticPlanet::db_planet_by_parent($UserPlanet['id']);
378
-      if($moon) {
378
+      if ($moon) {
379 379
         $moon_fill = min(100, floor($moon['field_current'] / eco_planet_fields_max($moon) * 100));
380 380
       } else {
381 381
         $moon_fill = 0;
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
     tpl_assign_fleet($template, $fleets);
416 416
 
417 417
     $lune = $planetrow['planet_type'] == PT_PLANET ? DBStaticPlanet::db_planet_by_parent($planetrow['id']) : DBStaticPlanet::db_planet_by_id($planetrow['parent_planet']);
418
-    if($lune) {
418
+    if ($lune) {
419 419
       $template->assign_vars(array(
420 420
         'MOON_ID' => $lune['id'],
421 421
         'MOON_IMG' => $lune['image'],
@@ -427,15 +427,15 @@  discard block
 block discarded – undo
427 427
     $planet_fill = $planet_fill > 100 ? 100 : $planet_fill;
428 428
 
429 429
     $planet_recyclers_orbiting = 0;
430
-    foreach(Fleet::$snGroupRecyclers as $recycler_id) {
430
+    foreach (Fleet::$snGroupRecyclers as $recycler_id) {
431 431
       $planet_recyclers_orbiting += mrc_get_level($user, $planetrow, $recycler_id);
432 432
     }
433 433
 
434 434
     int_planet_pretemplate($planetrow, $template);
435 435
 
436 436
     $sn_group_ques = sn_get_groups('ques');
437
-    if(!defined('GAME_STRUCTURES_DISABLED') || !GAME_STRUCTURES_DISABLED) {
438
-      foreach(array(QUE_STRUCTURES => $sn_group_ques[QUE_STRUCTURES]) as $que_id => $que_type_data) {
437
+    if (!defined('GAME_STRUCTURES_DISABLED') || !GAME_STRUCTURES_DISABLED) {
438
+      foreach (array(QUE_STRUCTURES => $sn_group_ques[QUE_STRUCTURES]) as $que_id => $que_type_data) {
439 439
         $this_que = $que['ques'][$que_id][$user['id']][$planetrow['id']];
440 440
         $template->assign_block_vars('ques', array(
441 441
           'ID'     => $que_id,
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
           'LENGTH' => empty($this_que) ? 0 : count($this_que),
444 444
         ));
445 445
 
446
-        if(!empty($this_que)) {
447
-          foreach($this_que as $que_item) {
446
+        if (!empty($this_que)) {
447
+          foreach ($this_que as $que_item) {
448 448
             $template->assign_block_vars('que', que_tpl_parse_element($que_item));
449 449
           }
450 450
         }
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
       'LENGTH' => $que_hangar_length,
459 459
     ));
460 460
 
461
-    if(!defined('GAME_DEFENSE_DISABLED') || !GAME_DEFENSE_DISABLED) {
461
+    if (!defined('GAME_DEFENSE_DISABLED') || !GAME_DEFENSE_DISABLED) {
462 462
       $que_hangar_length = tpl_assign_hangar($template, $planetrow, SUBQUE_DEFENSE);
463 463
       $template->assign_block_vars('ques', array(
464 464
         'ID'     => SUBQUE_DEFENSE,
@@ -470,12 +470,12 @@  discard block
 block discarded – undo
470 470
     $overview_planet_rows = $user['opt_int_overview_planet_rows'];
471 471
     $overview_planet_columns = $user['opt_int_overview_planet_columns'];
472 472
 
473
-    if($overview_planet_rows <= 0 && $overview_planet_columns <= 0) {
473
+    if ($overview_planet_rows <= 0 && $overview_planet_columns <= 0) {
474 474
       $overview_planet_rows = $user_option_list[OPT_INTERFACE]['opt_int_overview_planet_rows'];
475 475
       $overview_planet_columns = $user_option_list[OPT_INTERFACE]['opt_int_overview_planet_columns'];
476 476
     }
477 477
 
478
-    if($overview_planet_rows > 0 && $overview_planet_columns <= 0) {
478
+    if ($overview_planet_rows > 0 && $overview_planet_columns <= 0) {
479 479
       $overview_planet_columns = ceil($planet_count / $overview_planet_rows);
480 480
     }
481 481
 
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
     ));
533 533
     tpl_set_resource_info($template, $planetrow, $fleets_to_planet, 2);
534 534
 
535
-    foreach($result as &$a_result) {
535
+    foreach ($result as &$a_result) {
536 536
       $template->assign_block_vars('result', $a_result);
537 537
     }
538 538
 
Please login to merge, or discard this patch.
jumpgate.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -10,34 +10,34 @@  discard block
 block discarded – undo
10 10
  * @copyright 2008 By Chlorel for XNova
11 11
  */
12 12
 
13
-include('common.' . substr(strrchr(__FILE__, '.'), 1));
13
+include('common.'.substr(strrchr(__FILE__, '.'), 1));
14 14
 
15 15
 lng_include('fleet');
16 16
 
17
-if($TargetPlanet = sys_get_param_id('jmpto'))
17
+if ($TargetPlanet = sys_get_param_id('jmpto'))
18 18
 {
19 19
   sn_db_transaction_start();
20 20
   DBStaticUser::db_user_by_id($user['id'], true, 'id');
21 21
   $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true);
22
-  if(!($NextJumpTime = uni_get_time_to_jump($planetrow)))
22
+  if (!($NextJumpTime = uni_get_time_to_jump($planetrow)))
23 23
   {
24 24
     $TargetGate = DBStaticPlanet::db_planet_by_id($TargetPlanet, true, '`id`, `last_jump_time`');
25
-    if(mrc_get_level($user, $TargetGate, STRUC_MOON_GATE) > 0)
25
+    if (mrc_get_level($user, $TargetGate, STRUC_MOON_GATE) > 0)
26 26
     {
27
-      $NextDestTime = uni_get_time_to_jump ( $TargetGate );
28
-      if(!$NextDestTime)
27
+      $NextDestTime = uni_get_time_to_jump($TargetGate);
28
+      if (!$NextDestTime)
29 29
       {
30 30
         $ship_list = sys_get_param('ships');
31 31
         $jumpMade = false;
32
-        foreach($ship_list as $ship_id => $ship_count)
32
+        foreach ($ship_list as $ship_id => $ship_count)
33 33
         {
34
-          if(!in_array($ship_id, Fleet::$snGroupFleet))
34
+          if (!in_array($ship_id, Fleet::$snGroupFleet))
35 35
           {
36 36
             continue;
37 37
           }
38 38
 
39 39
           $ship_count = max(0, min(floor($ship_count), mrc_get_level($user, $planetrow, $ship_id)));
40
-          if($ship_count)
40
+          if ($ship_count)
41 41
           {
42 42
             $jumpMade = true;
43 43
             DBStaticUnit::dbUpdateOrInsertUnit($ship_id, -$ship_count, $user, $planetrow['id']);
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
           }
46 46
         }
47 47
 
48
-        if($jumpMade)
48
+        if ($jumpMade)
49 49
         {
50 50
           DBStaticPlanet::db_planet_update_set_by_id(
51 51
             $TargetGate['id'],
@@ -67,31 +67,31 @@  discard block
 block discarded – undo
67 67
           );
68 68
 
69 69
           $planetrow['last_jump_time'] = SN_TIME_NOW;
70
-          $RetMessage = classLocale::$lang['gate_jump_done'] ." - ". pretty_time(uni_get_time_to_jump($planetrow));
70
+          $RetMessage = classLocale::$lang['gate_jump_done']." - ".pretty_time(uni_get_time_to_jump($planetrow));
71 71
         } else {
72 72
           $RetMessage = classLocale::$lang['gate_wait_data'];
73 73
         }
74 74
       } else {
75
-        $RetMessage = classLocale::$lang['gate_wait_dest'] ." - ". pretty_time($NextDestTime);
75
+        $RetMessage = classLocale::$lang['gate_wait_dest']." - ".pretty_time($NextDestTime);
76 76
       }
77 77
     } else {
78 78
       $RetMessage = classLocale::$lang['gate_no_dest_g'];
79 79
     }
80 80
   } else {
81
-    $RetMessage = classLocale::$lang['gate_wait_star'] ." - ". pretty_time($NextJumpTime);
81
+    $RetMessage = classLocale::$lang['gate_wait_star']." - ".pretty_time($NextJumpTime);
82 82
   }
83 83
   sn_db_transaction_commit();
84 84
   message($RetMessage, classLocale::$lang['tech'][STRUC_MOON_GATE], "jumpgate.php", 10);
85 85
 } else {
86 86
   $template = gettemplate('jumpgate', true);
87
-  if(mrc_get_level($user, $planetrow, STRUC_MOON_GATE) > 0)
87
+  if (mrc_get_level($user, $planetrow, STRUC_MOON_GATE) > 0)
88 88
   {
89 89
     $Combo = '';
90 90
     $MoonList = DBStaticPlanet::db_planet_list_moon_other($user['id'], $planetrow['id']);
91 91
     // while($CurMoon = db_fetch($MoonList))
92
-    foreach($MoonList as $CurMoon)
92
+    foreach ($MoonList as $CurMoon)
93 93
     {
94
-      if(mrc_get_level($user, $CurMoon, STRUC_MOON_GATE) >= 1)
94
+      if (mrc_get_level($user, $CurMoon, STRUC_MOON_GATE) >= 1)
95 95
       {
96 96
         $NextJumpTime = uni_get_time_to_jump($CurMoon);
97 97
         $template->assign_block_vars('moon', array(
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
       }
106 106
     }
107 107
 
108
-    foreach(Fleet::$snGroupFleet as $Ship)
108
+    foreach (Fleet::$snGroupFleet as $Ship)
109 109
     {
110
-      if(($ship_count = mrc_get_level($user, $planetrow, $Ship)) <= 0)
110
+      if (($ship_count = mrc_get_level($user, $planetrow, $Ship)) <= 0)
111 111
       {
112 112
         continue;
113 113
       }
Please login to merge, or discard this patch.