Completed
Push — work-fleets ( 6257a1...22b5bc )
by SuperNova.WS
06:47
created
includes/classes/RequestInfo.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -87,15 +87,15 @@  discard block
 block discarded – undo
87 87
     // Инфа об устройстве и браузере - общая для всех
88 88
     sn_db_transaction_start();
89 89
     $this->device_cypher = $_COOKIE[SN_COOKIE_D];
90
-    if($this->device_cypher) {
90
+    if ($this->device_cypher) {
91 91
       $cypher_safe = db_escape($this->device_cypher);
92 92
       $device_id = classSupernova::$db->doSelectFetch("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE");
93
-      if(!empty($device_id['device_id'])) {
93
+      if (!empty($device_id['device_id'])) {
94 94
         $this->device_id = $device_id['device_id'];
95 95
       }
96 96
     }
97 97
 
98
-    if($this->device_id <= 0) {
98
+    if ($this->device_id <= 0) {
99 99
       do {
100 100
         $cypher_safe = db_escape($this->device_cypher = sys_random_string());
101 101
         $row = classSupernova::$db->doSelectFetch("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE");
@@ -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
     }
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
   public function db_counter_insert($user_id_unsafe) {
167 167
     global $sys_stop_log_hit;
168 168
 
169
-    if($sys_stop_log_hit || !classSupernova::$config->game_counter) {
169
+    if ($sys_stop_log_hit || !classSupernova::$config->game_counter) {
170 170
       return;
171 171
     }
172 172
 
Please login to merge, or discard this patch.
includes/classes/DbRowDirectOperator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
       ->setIdField($entity->getIdFieldName())
19 19
       ->field('*')
20 20
       ->from($entity->getTableName())
21
-      ->where($entity->getIdFieldName() . ' = "' . $entity->dbId . '"');
21
+      ->where($entity->getIdFieldName().' = "'.$entity->dbId.'"');
22 22
 
23 23
     return $stmt->selectRow();
24 24
   }
Please login to merge, or discard this patch.
includes/classes/DBStaticNews.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
       LEFT JOIN {{survey}} AS s ON s.survey_announce_id = a.idAnnounce
44 44
       LEFT JOIN {{users}} AS u ON u.id = a.user_id
45 45
     {$query_where}
46
-    ORDER BY `tsTimeStamp` DESC, idAnnounce" .
46
+    ORDER BY `tsTimeStamp` DESC, idAnnounce".
47 47
       ($query_limit ? " LIMIT {$query_limit}" : ''));
48 48
 
49 49
     $template->assign_var('NEWS_COUNT', classSupernova::$db->db_num_rows($announce_list));
Please login to merge, or discard this patch.
includes/classes/UBE/UBEDebris.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
    */
28 28
   public function debris_add_resource($resource_id, $resource_amount) {
29 29
     // В обломках может быть только металл или кристалл
30
-    if($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) {
30
+    if ($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) {
31 31
       return;
32 32
     }
33 33
     $this->debris[$resource_id] += $resource_amount;
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
    * @param bool  $is_simulator
39 39
    */
40 40
   public function add_wrecks(array $wreckage, $is_simulator) {
41
-    foreach($wreckage as $resource_id => $resource_amount) {
41
+    foreach ($wreckage as $resource_id => $resource_amount) {
42 42
       $this->debris_add_resource($resource_id, floor($resource_amount *
43 43
         ($is_simulator
44 44
           ? UBE_SHIP_WRECKS_TO_DEBRIS_AVG
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
    * @param bool  $is_simulator
55 55
    */
56 56
   public function add_cargo_drop(array $dropped_resources, $is_simulator) {
57
-    foreach($dropped_resources as $resource_id => $resource_amount) {
57
+    foreach ($dropped_resources as $resource_id => $resource_amount) {
58 58
       $this->debris_add_resource($resource_id, floor($resource_amount *
59 59
         ($is_simulator
60 60
           ? UBE_CARGO_DROPPED_TO_DEBRIS_AVG
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
    * @param $moon_debris_left_part
94 94
    */
95 95
   public function debris_adjust_proportional($moon_debris_left_part) {
96
-    foreach($this->debris as $resource_id => &$resource_amount) {
96
+    foreach ($this->debris as $resource_id => &$resource_amount) {
97 97
       $resource_amount = floor($resource_amount * $moon_debris_left_part);
98 98
     }
99 99
   }
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
    */
115 115
   public function report_generate_array() {
116 116
     return array(
117
-      'ube_report_debris_metal'          => (float)$this->debris_get_resource(RES_METAL),
118
-      'ube_report_debris_crystal'        => (float)$this->debris_get_resource(RES_CRYSTAL),
119
-      'ube_report_debris_total_in_metal' => (float)$this->debris_in_metal(),
117
+      'ube_report_debris_metal'          => (float) $this->debris_get_resource(RES_METAL),
118
+      'ube_report_debris_crystal'        => (float) $this->debris_get_resource(RES_CRYSTAL),
119
+      'ube_report_debris_total_in_metal' => (float) $this->debris_in_metal(),
120 120
     );
121 121
   }
122 122
 
Please login to merge, or discard this patch.
includes/classes/UBE/UBEMoonCalculator.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
     $debris_for_moon = $debris->debris_total();
72 72
 
73
-    if(!$debris_for_moon) {
73
+    if (!$debris_for_moon) {
74 74
       return;
75 75
     }
76 76
 
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
     $moon_chance = min($debris_for_moon / UBE_MOON_DEBRIS_PER_PERCENT, UBE_MOON_PERCENT_MAX); // TODO Configure
79 79
     $moon_chance = $moon_chance >= UBE_MOON_PERCENT_MIN ? $moon_chance : 0;
80 80
     $this->create_chance = $moon_chance;
81
-    if($moon_chance) {
82
-      if($is_simulator || mt_rand(1, 100) <= $moon_chance) {
81
+    if ($moon_chance) {
82
+      if ($is_simulator || mt_rand(1, 100) <= $moon_chance) {
83 83
         $this->status = UBE_MOON_CREATE_SUCCESS;
84 84
         $this->moon_diameter = round($is_simulator ? $moon_chance * 150 + 1999 : mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999));
85 85
 
86
-        if($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) {
86
+        if ($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) {
87 87
           $debris->_reset();
88 88
         } else {
89 89
           $moon_debris_left_percent = ($debris_for_moon - UBE_MOON_DEBRIS_MAX_SPENT) / $debris_for_moon;
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
    */
103 103
   protected function moon_destroy_try($reapers) {
104 104
     // TODO: $is_simulator
105
-    if($reapers <= 0) {
105
+    if ($reapers <= 0) {
106 106
       return;
107 107
     }
108 108
 
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
    * @version 2016-02-25 23:42:45 41a4.68
121 121
    */
122 122
   public function calculate_moon(UBE $ube) {
123
-    if(UBE_MOON_EXISTS == $this->status) {
124
-      if($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) {
123
+    if (UBE_MOON_EXISTS == $this->status) {
124
+      if ($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) {
125 125
         $reapers = $ube->fleet_list->ube_calculate_attack_reapers();
126 126
         $this->moon_destroy_try($reapers);
127 127
       }
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
    */
136 136
   public function report_generate_array() {
137 137
     return array(
138
-      'ube_report_moon'                    => (int)$this->status,
139
-      'ube_report_moon_chance'             => (int)$this->create_chance,
140
-      'ube_report_moon_size'               => (float)$this->moon_diameter,
141
-      'ube_report_moon_reapers'            => (int)$this->reapers_status,
142
-      'ube_report_moon_destroy_chance'     => (int)$this->destroy_chance,
143
-      'ube_report_moon_reapers_die_chance' => (int)$this->reaper_die_chance,
138
+      'ube_report_moon'                    => (int) $this->status,
139
+      'ube_report_moon_chance'             => (int) $this->create_chance,
140
+      'ube_report_moon_size'               => (float) $this->moon_diameter,
141
+      'ube_report_moon_reapers'            => (int) $this->reapers_status,
142
+      'ube_report_moon_destroy_chance'     => (int) $this->destroy_chance,
143
+      'ube_report_moon_reapers_die_chance' => (int) $this->reaper_die_chance,
144 144
     );
145 145
   }
146 146
 
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
    * @param $planet_id
172 172
    */
173 173
   public function db_apply_result($planet_info, $destination_user_id) {
174
-    if($this->status == UBE_MOON_CREATE_SUCCESS) {
174
+    if ($this->status == UBE_MOON_CREATE_SUCCESS) {
175 175
       $moon_row = uni_create_moon($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], $destination_user_id, $this->moon_diameter, '', false);
176 176
       $this->moon_name = $moon_row['name'];
177 177
       unset($moon_row);
178
-    } elseif($this->status == UBE_MOON_DESTROY_SUCCESS) {
178
+    } elseif ($this->status == UBE_MOON_DESTROY_SUCCESS) {
179 179
       DBStaticPlanet::db_planet_delete_by_id($planet_info[PLANET_ID]);
180 180
     }
181 181
   }
@@ -184,18 +184,18 @@  discard block
 block discarded – undo
184 184
     $classLocale = classLocale::$lang;
185 185
 
186 186
     $text_defender = '';
187
-    if($this->status == UBE_MOON_CREATE_SUCCESS) {
187
+    if ($this->status == UBE_MOON_CREATE_SUCCESS) {
188 188
       $text_defender .= "{$classLocale['ube_report_moon_created']} {$this->moon_diameter} {$classLocale['sys_kilometers_short']}<br /><br />";
189
-    } elseif($this->status == UBE_MOON_CREATE_FAILED) {
189
+    } elseif ($this->status == UBE_MOON_CREATE_FAILED) {
190 190
       $text_defender .= "{$classLocale['ube_report_moon_chance']} {$this->create_chance}%<br /><br />";
191 191
     }
192 192
 
193
-    if($ube->mission_type_id == MT_DESTROY) {
194
-      if($this->reapers_status == UBE_MOON_REAPERS_NONE) {
193
+    if ($ube->mission_type_id == MT_DESTROY) {
194
+      if ($this->reapers_status == UBE_MOON_REAPERS_NONE) {
195 195
         $text_defender .= classLocale::$lang['ube_report_moon_reapers_none'];
196 196
       } else {
197 197
         $text_defender .= "{$classLocale['ube_report_moon_reapers_wave']}. {$classLocale['ube_report_moon_reapers_chance']} {$this->destroy_chance}%. ";
198
-        $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure'] . "<br />";
198
+        $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure']."<br />";
199 199
 
200 200
         $text_defender .= "{$classLocale['ube_report_moon_reapers_outcome']} {$this->reaper_die_chance}%. ";
201 201
         $text_defender .= classLocale::$lang[$this->reapers_status == UBE_MOON_REAPERS_RETURNED ? 'ube_report_moon_reapers_survive' : 'ube_report_moon_reapers_died'];
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
    * @version 2016-02-25 23:42:45 41a4.68
221 221
    */
222 222
   public function ubeInitLoadStatis($destination_planet) {
223
-    if($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) {
223
+    if ($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) {
224 224
       $this->status = UBE_MOON_EXISTS;
225 225
       $this->moon_diameter = !empty($moon['planet_type']) && $moon['planet_type'] == PT_MOON ? $moon['diameter'] : $destination_planet['diameter'];
226 226
       $this->reapers_status = UBE_MOON_REAPERS_NONE;
Please login to merge, or discard this patch.
includes/classes/UBE/UBEReport.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
    */
14 14
   public function sn_ube_report_save($ube) {
15 15
     // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем
16
-    if($ube->get_cypher()) {
16
+    if ($ube->get_cypher()) {
17 17
       return false;
18 18
     }
19 19
 
20 20
     // Генерируем уникальный секретный ключ и проверяем наличие в базе
21 21
     do {
22 22
       $ube->report_cypher = sys_random_string(32);
23
-    } while(classSupernova::$db->doSelectFetch("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE"));
23
+    } while (classSupernova::$db->doSelectFetch("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE"));
24 24
 
25 25
     // Инициализация таблицы для пакетной вставки информации
26 26
     $sql_perform = array(
@@ -106,21 +106,21 @@  discard block
 block discarded – undo
106 106
 
107 107
     // Сохраняем общую информацию о бое
108 108
     classSupernova::$db->doInsertSet(TABLE_UBE_REPORT, array(
109
-        'ube_report_cypher'             => (string)$ube->report_cypher,
110
-        'ube_report_time_combat'        => (string)date(FMT_DATE_TIME_SQL, $ube->combat_timestamp),
111
-        'ube_report_time_spent'         => (float)$ube->time_spent,
112
-        'ube_report_combat_admin'       => (int)$ube->is_admin_in_combat,
113
-        'ube_report_mission_type'       => (int)$ube->mission_type_id,
114
-        'ube_report_combat_result'      => (int)$ube->combat_result,
115
-        'ube_report_combat_sfr'         => (int)$ube->is_small_fleet_recce,
116
-        'ube_report_planet_id'          => (int)$ube->ube_planet_info[PLANET_ID],
117
-        'ube_report_planet_name'        => (string)$ube->ube_planet_info[PLANET_NAME],
118
-        'ube_report_planet_size'        => (int)$ube->ube_planet_info[PLANET_SIZE],
119
-        'ube_report_planet_galaxy'      => (int)$ube->ube_planet_info[PLANET_GALAXY],
120
-        'ube_report_planet_system'      => (int)$ube->ube_planet_info[PLANET_SYSTEM],
121
-        'ube_report_planet_planet'      => (int)$ube->ube_planet_info[PLANET_PLANET],
122
-        'ube_report_planet_planet_type' => (int)$ube->ube_planet_info[PLANET_TYPE],
123
-        'ube_report_capture_result'     => (int)$ube->capture_result,
109
+        'ube_report_cypher'             => (string) $ube->report_cypher,
110
+        'ube_report_time_combat'        => (string) date(FMT_DATE_TIME_SQL, $ube->combat_timestamp),
111
+        'ube_report_time_spent'         => (float) $ube->time_spent,
112
+        'ube_report_combat_admin'       => (int) $ube->is_admin_in_combat,
113
+        'ube_report_mission_type'       => (int) $ube->mission_type_id,
114
+        'ube_report_combat_result'      => (int) $ube->combat_result,
115
+        'ube_report_combat_sfr'         => (int) $ube->is_small_fleet_recce,
116
+        'ube_report_planet_id'          => (int) $ube->ube_planet_info[PLANET_ID],
117
+        'ube_report_planet_name'        => (string) $ube->ube_planet_info[PLANET_NAME],
118
+        'ube_report_planet_size'        => (int) $ube->ube_planet_info[PLANET_SIZE],
119
+        'ube_report_planet_galaxy'      => (int) $ube->ube_planet_info[PLANET_GALAXY],
120
+        'ube_report_planet_system'      => (int) $ube->ube_planet_info[PLANET_SYSTEM],
121
+        'ube_report_planet_planet'      => (int) $ube->ube_planet_info[PLANET_PLANET],
122
+        'ube_report_planet_planet_type' => (int) $ube->ube_planet_info[PLANET_TYPE],
123
+        'ube_report_capture_result'     => (int) $ube->capture_result,
124 124
       )
125 125
       + $ube->debris->report_generate_array()
126 126
       + $ube->moon_calculator->report_generate_array()
@@ -129,22 +129,22 @@  discard block
 block discarded – undo
129 129
 
130 130
     // Сохраняем общую информацию по игрокам
131 131
     $player_sides = $ube->players->get_player_sides();
132
-    foreach($player_sides as $player_id => $player_side) {
132
+    foreach ($player_sides as $player_id => $player_side) {
133 133
       $sql_perform['ube_report_player'][] = array(
134 134
         $ube_report_id,
135 135
         $player_id,
136 136
 
137
-        "'" . db_escape($ube->players[$player_id]->name) . "'",
137
+        "'".db_escape($ube->players[$player_id]->name)."'",
138 138
         $ube->players[$player_id]->getSide() == UBE_PLAYER_IS_ATTACKER ? 1 : 0,
139 139
 
140
-        (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK),
141
-        (float)$ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD),
142
-        (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR),
140
+        (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK),
141
+        (float) $ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD),
142
+        (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR),
143 143
       );
144 144
     }
145 145
 
146 146
     // Всякая информация по флотам
147
-    foreach($ube->fleet_list->_container as $fleet_id => $UBEFleet) {
147
+    foreach ($ube->fleet_list->_container as $fleet_id => $UBEFleet) {
148 148
       // Сохраняем общую информацию по флотам
149 149
       $sql_perform['ube_report_fleet'][] = $UBEFleet->sql_generate_array($ube_report_id);
150 150
 
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
     $ube->rounds->sql_generate_unit_array($sql_perform['ube_report_unit'], $ube_report_id, $ube->fleet_list);
160 160
 
161 161
     // Пакетная вставка данных
162
-    foreach($sql_perform as $table_name => $table_data) {
163
-      if(count($table_data) < 2) {
162
+    foreach ($sql_perform as $table_name => $table_data) {
163
+      if (count($table_data) < 2) {
164 164
         continue;
165 165
       }
166
-      foreach($table_data as &$record_data) {
167
-        $record_data = '(' . implode(',', $record_data) . ')';
166
+      foreach ($table_data as &$record_data) {
167
+        $record_data = '('.implode(',', $record_data).')';
168 168
       }
169 169
       $fields = $table_data[0];
170 170
       unset($table_data[0]);
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
     $report_cypher = db_escape($report_cypher);
187 187
 
188 188
     $report_row = classSupernova::$db->doSelectFetch("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1");
189
-    if(!$report_row) {
189
+    if (!$report_row) {
190 190
       return UBE_REPORT_NOT_FOUND;
191 191
     }
192 192
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
    * @param     $template_result
203 203
    */
204 204
   public function sn_ube_report_generate(UBE $ube, &$template_result) {
205
-    if(!is_object($ube)) {
205
+    if (!is_object($ube)) {
206 206
       return;
207 207
     }
208 208
 
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
217 217
 
218 218
     // Координаты, тип и название планеты - если есть
219 219
 //R  $planet_owner_id = $combat_data[UBE_FLEETS][0][UBE_OWNER];
220
-    if(isset($ube->ube_planet_info)) {
220
+    if (isset($ube->ube_planet_info)) {
221 221
       $template_result += $ube->ube_planet_info;
222 222
       $template_result[PLANET_NAME] = str_replace(' ', '&nbsp;', htmlentities($template_result[PLANET_NAME], ENT_COMPAT, 'UTF-8'));
223 223
     }
224 224
 
225 225
     // Обломки
226 226
     $debris = array();
227
-    foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) {
228
-      if($resource_amount = $ube->debris->debris_get_resource($resource_id)) {
227
+    foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) {
228
+      if ($resource_amount = $ube->debris->debris_get_resource($resource_id)) {
229 229
         $debris[] = array(
230 230
           'NAME'   => classLocale::$lang['tech'][$resource_id],
231 231
           'AMOUNT' => pretty_number($resource_amount),
Please login to merge, or discard this patch.
includes/classes/DBStaticFleetACS.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
    */
52 52
   public static function db_acs_insert($fleetid, $userId, $objFleet) {
53 53
     classSupernova::$db->doInsertSet(TABLE_AKS, array(
54
-      'name'           => classLocale::$lang['flt_acs_prefix'] . $fleetid,
54
+      'name'           => classLocale::$lang['flt_acs_prefix'].$fleetid,
55 55
       'teilnehmer'     => $userId,
56 56
       'flotten'        => $fleetid,
57 57
       'ankunft'        => $objFleet->time_arrive_to_target,
Please login to merge, or discard this patch.
includes/functions/uni_functions.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
 
10 10
   $possible_cores = array();
11 11
   $probability = 0;
12
-  foreach($density_list as $possible_core_id => $core_data) {
13
-    if(!$core_data[UNIT_PLANET_DENSITY_RARITY]) {
12
+  foreach ($density_list as $possible_core_id => $core_data) {
13
+    if (!$core_data[UNIT_PLANET_DENSITY_RARITY]) {
14 14
       continue;
15 15
     }
16 16
 
17
-    if(
17
+    if (
18 18
       // Core type exists
19 19
       in_array($possible_core_id, $position_data['core_types'])
20 20
       // Limit core type with planet sector count
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 
36 36
   $random = mt_rand(1, $probability);
37 37
   $selected_core = null;
38
-  foreach($possible_cores as $core_type => $core_info) {
39
-    if($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) {
38
+  foreach ($possible_cores as $core_type => $core_info) {
39
+    if ($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) {
40 40
       $selected_core = $core_info;
41 41
       break;
42 42
     }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 function uni_create_planet($Galaxy, $System, $Position, $PlanetOwnerID, $planet_name_unsafe = '', $HomeWorld = false, $options = array()) {
60 60
   $Position = intval($Position);
61 61
 
62
-  if(!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) {
62
+  if (!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) {
63 63
     return false;
64 64
   }
65 65
 
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 
69 69
   $planet_generator = sn_get_groups('planet_generator');
70 70
 
71
-  if($HomeWorld) {
71
+  if ($HomeWorld) {
72 72
     $position_data = $planet_generator[0];
73 73
   } else {
74 74
     $position_data = $planet_generator[$Position >= UNIVERSE_RANDOM_PLANET_START || $Position < 1 ? UNIVERSE_RANDOM_PLANET_START : $Position];
75
-    if($Position >= UNIVERSE_RANDOM_PLANET_START) {
75
+    if ($Position >= UNIVERSE_RANDOM_PLANET_START) {
76 76
       // Корректируем температуру для планеты-странника
77 77
       $position_data['t_max_max'] -= UNIVERSE_RANDOM_PLANET_TEMPERATURE_DECREASE * ($Position - UNIVERSE_RANDOM_PLANET_START);
78 78
     }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
   $planet_images = sn_get_groups('planet_images');
82 82
   $planet_image = $position_data['planet_images'][mt_rand(0, count($position_data['planet_images']) - 1)];
83
-  $planet_image .= 'planet' . $planet_images[$planet_image][mt_rand(0, count($planet_images[$planet_image]) - 1)];
83
+  $planet_image .= 'planet'.$planet_images[$planet_image][mt_rand(0, count($planet_images[$planet_image]) - 1)];
84 84
 
85 85
   $t_max = sn_rand_gauss_range($position_data['t_max_min'], $position_data['t_max_max'], true, 1.3, true);
86 86
   $t_min = $t_max - sn_rand_gauss_range($position_data['t_delta_min'], $position_data['t_delta_max'], true, 1.3, true);
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
   $core_info = uni_create_planet_get_density($position_data, $user_row, $planet_sectors);
93 93
 
94
-  $planet_name_unsafe = $user_row['username'] . ' ' . ($planet_name_unsafe ? $planet_name_unsafe : classLocale::$lang['sys_colo_defaultname']);
94
+  $planet_name_unsafe = $user_row['username'].' '.($planet_name_unsafe ? $planet_name_unsafe : classLocale::$lang['sys_colo_defaultname']);
95 95
 
96 96
   $planet['name'] = trim(strip_tags($planet_name_unsafe));
97 97
   $planet['id_owner'] = $PlanetOwnerID;
@@ -163,15 +163,15 @@  discard block
 block discarded – undo
163 163
   $moon_name = '';
164 164
   $moon_row = array();
165 165
   $moon = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_MOON, false, 'id');
166
-  if(!$moon['id']) {
166
+  if (!$moon['id']) {
167 167
     $moon_planet = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_PLANET, true, '`id`, `temp_min`, `temp_max`, `name`, `debris_metal`, `debris_crystal`');
168 168
 
169
-    if($moon_planet['id']) {
169
+    if ($moon_planet['id']) {
170 170
       $base_storage_size = BASE_STORAGE_SIZE;
171 171
 
172
-      if(!$moon_chance) {
172
+      if (!$moon_chance) {
173 173
         $size = mt_rand(1100, 8999);
174
-      } elseif($moon_chance <= 100) {
174
+      } elseif ($moon_chance <= 100) {
175 175
         $size = mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999);
176 176
       } else {
177 177
         $size = $moon_chance;
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 
187 187
       $field_max = ceil($size / 1000);
188 188
 
189
-      if(isset($options['image']) && $options['image']) {
189
+      if (isset($options['image']) && $options['image']) {
190 190
         $moon_image = $options['image'];
191 191
       } else {
192 192
         $moon_image = 'mond';
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         'deuterium_max'     => $base_storage_size,
220 220
       ));
221 221
 
222
-      if($update_debris) {
222
+      if ($update_debris) {
223 223
         $debris_spent = $moon_chance * 1000000;
224 224
         $metal_spent = round(min($moon_planet['debris_metal'], $debris_spent * mt_rand(50, 75) / 100));
225 225
         $crystal_spent = min($moon_planet['debris_crystal'], $debris_spent - $metal_spent);
@@ -254,28 +254,28 @@  discard block
 block discarded – undo
254 254
   $planet_row['id'] = $user['current_planet'];
255 255
 
256 256
   // Пытаемся переключить на новую планету
257
-  if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) {
257
+  if (($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) {
258 258
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id');
259 259
   } else {
260 260
     $planet_row = DBStaticPlanet::db_planet_by_id($planet_row['id']);
261 261
   }
262 262
 
263 263
   // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету
264
-  if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet']
264
+  if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet']
265 265
   {
266 266
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id');
267 267
     // Если текущей планеты не существует - выставляем Столицу
268
-    if(!isset($planet_row['id'])) {
268
+    if (!isset($planet_row['id'])) {
269 269
       $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id');
270 270
       // Если и столицы не существует - значит что-то очень не так с записью пользователя
271
-      if(!isset($planet_row['id'])) {
271
+      if (!isset($planet_row['id'])) {
272 272
         classSupernova::$debug->error("User ID {$user['id']} has Capital planet {$user['id_planet']} but this planet does not exists", 'User record error', 502);
273 273
       }
274 274
     }
275 275
   }
276 276
 
277 277
   // Если производилось переключение планеты - делаем запись в юзере
278
-  if($user['current_planet'] != $planet_row['id']) {
278
+  if ($user['current_planet'] != $planet_row['id']) {
279 279
     DBStaticUser::db_user_set_by_id($user['id'], "`current_planet` = '{$planet_row['id']}'");
280 280
     $user['current_planet'] = $planet_row['id'];
281 281
   }
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 
293 293
 // ----------------------------------------------------------------------------------------------------------------
294 294
 function uni_render_coordinates($from, $prefix = '') {
295
-  return "[{$from[$prefix . 'galaxy']}:{$from[$prefix . 'system']}:{$from[$prefix . 'planet']}]";
295
+  return "[{$from[$prefix.'galaxy']}:{$from[$prefix.'system']}:{$from[$prefix.'planet']}]";
296 296
 }
297 297
 
298 298
 function uni_render_planet($from) {
@@ -300,17 +300,17 @@  discard block
 block discarded – undo
300 300
 }
301 301
 
302 302
 function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false) {
303
-  if(!$from['id']) {
303
+  if (!$from['id']) {
304 304
     $result = classLocale::$lang['sys_planet_expedition'];
305 305
   } else {
306 306
     $from_planet_id = $include_id ? (
307
-      'ID {' . ($from['id'] ? $from['id'] : ($from[$prefix . 'planet_id'] ? $from[$prefix . 'planet_id'] : 0)) . '} '
307
+      'ID {'.($from['id'] ? $from['id'] : ($from[$prefix.'planet_id'] ? $from[$prefix.'planet_id'] : 0)).'} '
308 308
     ) : '';
309 309
 
310
-    $from_planet_type = $from['planet_type'] ? $from['planet_type'] : ($from[$prefix . 'type'] ? $from[$prefix . 'type'] : 0);
311
-    $from_planet_type = ($from_planet_type ? ' ' . classLocale::$lang['sys_planet_type_sh'][$from_planet_type] : '');
310
+    $from_planet_type = $from['planet_type'] ? $from['planet_type'] : ($from[$prefix.'type'] ? $from[$prefix.'type'] : 0);
311
+    $from_planet_type = ($from_planet_type ? ' '.classLocale::$lang['sys_planet_type_sh'][$from_planet_type] : '');
312 312
 
313
-    $result = $from_planet_id . uni_render_coordinates($from, $prefix) . $from_planet_type . ($from['name'] ? ' ' . $from['name'] : '');
313
+    $result = $from_planet_id.uni_render_coordinates($from, $prefix).$from_planet_type.($from['name'] ? ' '.$from['name'] : '');
314 314
     $result = $html_safe ? str_replace(' ', '&nbsp;', htmlentities($result, ENT_COMPAT, 'UTF-8')) : $result;
315 315
   }
316 316
 
@@ -318,11 +318,11 @@  discard block
 block discarded – undo
318 318
 }
319 319
 
320 320
 function uni_render_coordinates_url($from, $prefix = '', $page = 'galaxy.php') {
321
-  return $page . (strpos($page, '?') === false ? '?' : '&') . "galaxy={$from[$prefix . 'galaxy']}&system={$from[$prefix . 'system']}&planet={$from[$prefix . 'planet']}";
321
+  return $page.(strpos($page, '?') === false ? '?' : '&')."galaxy={$from[$prefix.'galaxy']}&system={$from[$prefix.'system']}&planet={$from[$prefix.'planet']}";
322 322
 }
323 323
 
324 324
 function uni_render_coordinates_href($from, $prefix = '', $mode = 0, $fleet_type = '') {
325
-  return '<a href="' . uni_render_coordinates_url($from, $prefix, "galaxy.php?mode={$mode}") . '"' . ($fleet_type ? " {$fleet_type}" : '') . '>' . uni_render_coordinates($from, $prefix) . '</a>';
325
+  return '<a href="'.uni_render_coordinates_url($from, $prefix, "galaxy.php?mode={$mode}").'"'.($fleet_type ? " {$fleet_type}" : '').'>'.uni_render_coordinates($from, $prefix).'</a>';
326 326
 }
327 327
 
328 328
 function uni_get_time_to_jump($moon_row) {
@@ -350,30 +350,30 @@  discard block
 block discarded – undo
350 350
   $coordinates["{$prefix}planet"] = intval($coordinates["{$prefix}planet"]);
351 351
 
352 352
   return
353
-    isset($coordinates["{$prefix}galaxy"]) && $coordinates["{$prefix}galaxy"] > 0 && $coordinates["{$prefix}galaxy"] <= Vector::$knownGalaxies&&
354
-    isset($coordinates["{$prefix}system"]) && $coordinates["{$prefix}system"] > 0 && $coordinates["{$prefix}system"] <= Vector::$knownSystems&&
353
+    isset($coordinates["{$prefix}galaxy"]) && $coordinates["{$prefix}galaxy"] > 0 && $coordinates["{$prefix}galaxy"] <= Vector::$knownGalaxies &&
354
+    isset($coordinates["{$prefix}system"]) && $coordinates["{$prefix}system"] > 0 && $coordinates["{$prefix}system"] <= Vector::$knownSystems &&
355 355
     isset($coordinates["{$prefix}planet"]) && $coordinates["{$prefix}planet"] > 0 && $coordinates["{$prefix}planet"] <= Vector::$knownPlanets;
356 356
 }
357 357
 
358 358
 function uni_planet_teleport_check($user, $planetrow, $new_coordinates = null) {
359 359
   try {
360
-    if($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) {
360
+    if ($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) {
361 361
       throw new exception(classLocale::$lang['ov_teleport_err_cooldown'], ERR_ERROR);
362 362
     }
363 363
 
364
-    if(mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->planet_teleport_cost) {
364
+    if (mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->planet_teleport_cost) {
365 365
       throw new exception(classLocale::$lang['ov_teleport_err_no_dark_matter'], ERR_ERROR);
366 366
     }
367 367
 
368 368
     // TODO: Replace quick-check with using gathered flying fleet data
369
-    if(FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) {
369
+    if (FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) {
370 370
       throw new exception(classLocale::$lang['ov_teleport_err_fleet'], ERR_ERROR);
371 371
     }
372 372
 
373
-    if(is_array($new_coordinates)) {
373
+    if (is_array($new_coordinates)) {
374 374
       $new_coordinates['planet_type'] = PT_PLANET;
375 375
       $incoming = DBStaticPlanet::db_planet_by_vector($new_coordinates, '', true, 'id');
376
-      if($incoming['id']) {
376
+      if ($incoming['id']) {
377 377
         throw new exception(classLocale::$lang['ov_teleport_err_destination_busy'], ERR_ERROR);
378 378
       }
379 379
     }
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
       'result'  => ERR_NONE,
383 383
       'message' => '',
384 384
     );
385
-  } catch(exception $e) {
385
+  } catch (exception $e) {
386 386
     $response = array(
387 387
       'result'  => $e->getCode(),
388 388
       'message' => $e->getMessage(),
Please login to merge, or discard this patch.
announce.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 $allow_anonymous = true;
12
-include('common.' . substr(strrchr(__FILE__, '.'), 1));
12
+include('common.'.substr(strrchr(__FILE__, '.'), 1));
13 13
 
14 14
 nws_mark_read($user);
15 15
 $template = gettemplate('announce', true);
@@ -23,42 +23,42 @@  discard block
 block discarded – undo
23 23
 $mode = sys_get_param_str('mode');
24 24
 
25 25
 $announce = array();
26
-if($user['authlevel'] >= 3) {
27
-  if(!empty($text)) {
26
+if ($user['authlevel'] >= 3) {
27
+  if (!empty($text)) {
28 28
     $announce_time = strtotime($announce_time, SN_TIME_NOW);
29 29
     $announce_time = $announce_time ? $announce_time : SN_TIME_NOW;
30 30
 
31
-    if($mode == 'edit') {
31
+    if ($mode == 'edit') {
32 32
       DBStaticNews::db_news_update_set($announce_time, $text, $detail_url, $announce_id);
33 33
       DBStaticSurvey::db_survey_delete_by_id($announce_id);
34 34
     } else {
35 35
       DBStaticNews::db_news_insert_set($announce_time, $text_unsafe, $detail_url_unsafe, $user['id'], $user['username']);
36 36
       $announce_id = classSupernova::$db->db_insert_id();
37 37
     }
38
-    if(($survey_question = sys_get_param_str('survey_question')) && ($survey_answers = sys_get_param('survey_answers'))) {
38
+    if (($survey_question = sys_get_param_str('survey_question')) && ($survey_answers = sys_get_param('survey_answers'))) {
39 39
       $survey_answers = explode("\r\n", $survey_answers);
40 40
       $survey_until = strtotime($survey_until = sys_get_param_str('survey_until'), SN_TIME_NOW);
41 41
       $survey_until = date(FMT_DATE_TIME_SQL, $survey_until ? $survey_until : SN_TIME_NOW + PERIOD_DAY * 1);
42 42
       $survey_question_unsafe = sys_get_param_str_unsafe('survey_question');
43 43
       DBStaticSurvey::db_survey_insert($announce_id, $survey_question_unsafe, $survey_until);
44 44
       $survey_id = classSupernova::$db->db_insert_id();
45
-      foreach($survey_answers as $survey_answer) {
45
+      foreach ($survey_answers as $survey_answer) {
46 46
         $survey_answer_unsafe = trim($survey_answer);
47
-        if(empty($survey_answer_unsafe)) {
47
+        if (empty($survey_answer_unsafe)) {
48 48
           continue;
49 49
         }
50 50
         DBStaticSurveyAnswer::db_survey_answer_insert($survey_id, $survey_answer_unsafe);
51 51
       }
52 52
     }
53 53
 
54
-    if($announce_time <= SN_TIME_NOW) {
55
-      if($announce_time > classSupernova::$config->var_news_last && $announce_time == SN_TIME_NOW) {
54
+    if ($announce_time <= SN_TIME_NOW) {
55
+      if ($announce_time > classSupernova::$config->var_news_last && $announce_time == SN_TIME_NOW) {
56 56
         classSupernova::$config->db_saveItem('var_news_last', $announce_time);
57 57
       }
58 58
 
59
-      if(sys_get_param_int('news_mass_mail')) {
59
+      if (sys_get_param_int('news_mass_mail')) {
60 60
         $lang_news_more = classLocale::$lang['news_more'];
61
-        $text = sys_get_param('text') . ($detail_url ? " <a href=\"{$detail_url}\"><span class=\"positive\">{$lang_news_more}</span></a>" : '');
61
+        $text = sys_get_param('text').($detail_url ? " <a href=\"{$detail_url}\"><span class=\"positive\">{$lang_news_more}</span></a>" : '');
62 62
         DBStaticMessages::msgSendFromAdmin('*', classLocale::$lang['news_title'], $text);
63 63
       }
64 64
     }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
   }
69 69
 
70 70
   $survey_answers = '';
71
-  switch($mode) {
71
+  switch ($mode) {
72 72
     case 'del':
73 73
       DBStaticNews::db_news_delete_by_id($announce_id);
74 74
       $mode = '';
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
       $template->assign_var('ID', $announce_id);
80 80
     case 'copy':
81 81
       $announce = DBStaticNews::db_news_with_survey_select_by_id($announce_id);
82
-      if($announce['survey_id']) {
82
+      if ($announce['survey_id']) {
83 83
         $query = DBStaticSurveyAnswer::db_survey_answer_text_select_by_news($announce);
84
-        while($row = db_fetch($query)) {
84
+        while ($row = db_fetch($query)) {
85 85
           $survey_answers[] = $row['survey_answer_text'];
86 86
         }
87 87
         $survey_answers = implode("\r\n", $survey_answers);
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     break;
90 90
   }
91 91
 } else {
92
-  $annQuery = 'WHERE UNIX_TIMESTAMP(`tsTimeStamp`) <= ' . SN_TIME_NOW;
92
+  $annQuery = 'WHERE UNIX_TIMESTAMP(`tsTimeStamp`) <= '.SN_TIME_NOW;
93 93
 }
94 94
 
95 95
 nws_render($template, $annQuery, 20);
Please login to merge, or discard this patch.