Completed
Push — trunk ( 91a948...0e7a2e )
by SuperNova.WS
05:44
created
classes/oldArrayAccessNd.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
     !is_array($offset) ? $offset = array($offset) : false;
39 39
 
40 40
     $current_leaf = $this->__get(reset($offset));
41
-    while(($leaf_index = next($offset)) !== false) {
42
-      if(!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) {
41
+    while (($leaf_index = next($offset)) !== false) {
42
+      if (!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) {
43 43
         unset($current_leaf);
44 44
         break;
45 45
       }
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 
65 65
     !is_array($offset) ? $offset = array($offset) : false;
66 66
 
67
-    if($this->offsetExists($offset)) {
67
+    if ($this->offsetExists($offset)) {
68 68
       $result = $this->__get(reset($offset));
69
-      while(($leaf_index = next($offset)) !== false) {
69
+      while (($leaf_index = next($offset)) !== false) {
70 70
         $result = $result[$leaf_index];
71 71
       }
72 72
     }
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
    */
92 92
   public function offsetSet($offset, $value = null) {
93 93
     // Если нет никакого индекса - значит нечего записывать
94
-    if(!isset($offset) || (is_array($offset) && empty($offset))) {
94
+    if (!isset($offset) || (is_array($offset) && empty($offset))) {
95 95
       return;
96 96
     }
97 97
 
98 98
     // Если в массиве индекса только один элемент - значит это просто индекс
99
-    if(is_array($offset) && count($offset) == 1) {
99
+    if (is_array($offset) && count($offset) == 1) {
100 100
       // Разворачиваем его в индекс
101 101
       $offset = array(reset($offset) => $value);
102 102
       unset($value);
@@ -104,16 +104,16 @@  discard block
 block discarded – undo
104 104
     }
105 105
 
106 106
     // Адресация многомерного массива через массив индексов в $option
107
-    if(is_array($offset) && isset($value)) {
107
+    if (is_array($offset) && isset($value)) {
108 108
       // TODO - а не переделать ли это всё на __isset() ??
109 109
       // Вытаскиваем корневой элемент
110 110
       $root = $this->__get(reset($offset));
111 111
       $current_leaf = &$root;
112
-      while(($leaf_index = next($offset)) !== false) {
112
+      while (($leaf_index = next($offset)) !== false) {
113 113
         !is_array($current_leaf[$leaf_index]) ? $current_leaf[$leaf_index] = array() : false;
114 114
         $current_leaf = &$current_leaf[$leaf_index];
115 115
       }
116
-      if($current_leaf != $value) {
116
+      if ($current_leaf != $value) {
117 117
         $current_leaf = $value;
118 118
         // Сохраняем данные с корня
119 119
         $this->__set(reset($offset), $root);
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
       // Пакетная запись из массива ключ -> значение
123 123
       !is_array($offset) ? $offset = array($offset => $value) : false;
124 124
 
125
-      foreach($offset as $key => $value) {
125
+      foreach ($offset as $key => $value) {
126 126
         $this->__get($key) !== $value ? $this->__set($key, $value) : false;
127 127
       }
128 128
     }
@@ -143,18 +143,18 @@  discard block
 block discarded – undo
143 143
    */
144 144
   public function offsetUnset($offset) {
145 145
     // Если нет никакого индекса - значит нечего записывать
146
-    if(!isset($offset) || (is_array($offset) && empty($offset))) {
146
+    if (!isset($offset) || (is_array($offset) && empty($offset))) {
147 147
       return;
148 148
     }
149 149
 
150 150
     !is_array($offset) ? $offset = array($offset) : false;
151 151
 
152
-    if($this->offsetExists($offset)) {
152
+    if ($this->offsetExists($offset)) {
153 153
       // Перематываем массив в конец
154 154
       $key_to_delete = end($offset);
155 155
       $parent_offset = $offset;
156 156
       array_pop($parent_offset);
157
-      if(!count($parent_offset)) {
157
+      if (!count($parent_offset)) {
158 158
         // В массиве был один элемент - мы удаляем в корне. Просто удаляем элемент
159 159
         $this->__unset($key_to_delete);
160 160
       } else {
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.
includes/db/db_queries.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
 function db_unit_records_sum($unit_id, $user_skip_list_unit)
105 105
 {
106
-  return doquery (
106
+  return doquery(
107 107
     "SELECT unit_player_id, username, sum(unit_level) as unit_level
108 108
           FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id
109 109
           WHERE unit_player_id != 0 AND unit_snid = {$unit_id} {$user_skip_list_unit}
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 
116 116
 function db_unit_records_plain($unit_id, $user_skip_list_unit)
117 117
 {
118
-  return doquery (
118
+  return doquery(
119 119
     "SELECT unit_player_id, username, unit_level
120 120
           FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id
121 121
           WHERE unit_player_id != 0 AND unit_snid = {$unit_id} {$user_skip_list_unit}
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 }
126 126
 
127 127
 function db_stat_list_statistic($who, $is_common_stat, $Rank, $start, $source = false) {
128
-  if(!$source) {
128
+  if (!$source) {
129 129
     $source = array(
130 130
       'statpoints' => 'statpoints',
131 131
       'users' => 'users',
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
     );
147 147
   }
148 148
 
149
-  if($who == 1) {
150
-    if($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday`
149
+  if ($who == 1) {
150
+    if ($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday`
151 151
       $query_str =
152 152
         "SELECT
153 153
       @rownum:=@rownum+1 rownum, subject.{$source['id']} as `id`, sp.{$Rank}_rank as rank, sp.{$Rank}_old_rank as rank_old, sp.{$Rank}_points as points, subject.{$source['username']} as `name`, subject.*
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
     ORDER BY
162 162
       sp.`{$Rank}_rank`, subject.{$source['id']}
163 163
     LIMIT
164
-      ". $start .",100;";
164
+      " . $start . ",100;";
165 165
     } else { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday`
166 166
       $query_str =
167 167
         "SELECT
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
     ORDER BY
175 175
       subject.{$Rank} DESC, subject.{$source['id']}
176 176
     LIMIT
177
-      ". $start .",100;";
177
+      " . $start . ",100;";
178 178
     }
179 179
   } else {
180 180
     // TODO
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
   ORDER BY
192 192
     sp.`{$Rank}_rank`, subject.id
193 193
   LIMIT
194
-    ". $start .",100;";
194
+    " . $start . ",100;";
195 195
   }
196 196
 
197 197
   return doquery($query_str);
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) {
278 278
   $current_value_safe = db_escape($current_value_unsafe);
279 279
   $value_id = doquery("SELECT `{$db_id_field_name}` AS id_field FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE", true);
280
-  if(!isset($value_id['id_field']) || !$value_id['id_field']) {
280
+  if (!isset($value_id['id_field']) || !$value_id['id_field']) {
281 281
     doquery("INSERT INTO {{{$db_table_name}}} (`{$db_value_field_name}`) VALUES ('{$current_value_safe}');");
282 282
     $variable_id = db_insert_id();
283 283
   } else {
Please login to merge, or discard this patch.
Braces   +11 added lines, -22 removed lines patch added patch discarded remove patch
@@ -6,8 +6,7 @@  discard block
 block discarded – undo
6 6
 require_once('db_queries_fleet.php');
7 7
 
8 8
 
9
-function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type)
10
-{
9
+function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type) {
11 10
   return doquery(
12 11
     "SELECT p.*, u.username" . ($table_parent_columns ? ', p1.name AS parent_name' : '') .
13 12
     " FROM {{planets}} AS p
@@ -16,8 +15,7 @@  discard block
 block discarded – undo
16 15
     " WHERE " . ($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}"));
17 16
 }
18 17
 
19
-function db_planet_list_search($searchtext)
20
-{
18
+function db_planet_list_search($searchtext) {
21 19
   return doquery(
22 20
     "SELECT
23 21
       p.galaxy, p.system, p.planet, p.planet_type, p.name as planet_name,
@@ -37,8 +35,7 @@  discard block
 block discarded – undo
37 35
 
38 36
 
39 37
 
40
-function db_user_list_search($searchtext)
41
-{
38
+function db_user_list_search($searchtext) {
42 39
   return doquery(
43 40
     "SELECT
44 41
       pn.player_name, u.id as uid, u.username, u.ally_id, u.id_planet, u.total_points, u.total_rank,
@@ -56,8 +53,7 @@  discard block
 block discarded – undo
56 53
   );
57 54
 }
58 55
 
59
-function db_buddy_list_by_user($user_id)
60
-{
56
+function db_buddy_list_by_user($user_id) {
61 57
 //  return ($user_id = intval($user_id)) ? doquery(
62 58
   return ($user_id = idval($user_id)) ? doquery(
63 59
     "SELECT
@@ -87,8 +83,7 @@  discard block
 block discarded – undo
87 83
 
88 84
 
89 85
 
90
-function db_unit_records_sum($unit_id, $user_skip_list_unit)
91
-{
86
+function db_unit_records_sum($unit_id, $user_skip_list_unit) {
92 87
   return doquery (
93 88
     "SELECT unit_player_id, username, sum(unit_level) as unit_level
94 89
           FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id
@@ -99,8 +94,7 @@  discard block
 block discarded – undo
99 94
     , true);
100 95
 }
101 96
 
102
-function db_unit_records_plain($unit_id, $user_skip_list_unit)
103
-{
97
+function db_unit_records_plain($unit_id, $user_skip_list_unit) {
104 98
   return doquery (
105 99
     "SELECT unit_player_id, username, unit_level
106 100
           FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id
@@ -184,15 +178,13 @@  discard block
 block discarded – undo
184 178
 }
185 179
 
186 180
 
187
-function db_stat_list_delete_ally_player()
188
-{
181
+function db_stat_list_delete_ally_player() {
189 182
   return doquery('DELETE s FROM `{{statpoints}}` AS s JOIN `{{users}}` AS u ON u.id = s.id_owner WHERE s.id_ally IS NULL AND u.user_as_ally IS NOT NULL');
190 183
 }
191 184
 
192 185
 
193 186
 
194
-function db_chat_player_list_online($chat_refresh_rate, $ally_add)
195
-{
187
+function db_chat_player_list_online($chat_refresh_rate, $ally_add) {
196 188
   $sql_date = SN_TIME_NOW - $chat_refresh_rate * 2;
197 189
 
198 190
   return doquery(
@@ -206,13 +198,11 @@  discard block
 block discarded – undo
206 198
     ORDER BY authlevel DESC, `username`");
207 199
 }
208 200
 
209
-function db_referrals_list_by_id($user_id)
210
-{
201
+function db_referrals_list_by_id($user_id) {
211 202
   return doquery("SELECT r.*, u.username, u.register_time FROM {{referrals}} AS r LEFT JOIN {{users}} AS u ON u.id = r.id WHERE id_partner = {$user_id}");
212 203
 }
213 204
 
214
-function db_message_list_admin_by_type($int_type_selected, $StartRec)
215
-{
205
+function db_message_list_admin_by_type($int_type_selected, $StartRec) {
216 206
   return doquery("SELECT
217 207
   message_id as `ID`,
218 208
   message_from as `FROM`,
@@ -231,8 +221,7 @@  discard block
 block discarded – undo
231 221
 }
232 222
 
233 223
 
234
-function db_message_insert_all($message_type, $from, $subject, $text)
235
-{
224
+function db_message_insert_all($message_type, $from, $subject, $text) {
236 225
   return doquery($QryInsertMessage = 'INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' .
237 226
     "SELECT `id`, 0, unix_timestamp(now()), {$message_type}, '{$from}', '{$subject}', '{$text}' FROM {{users}}");
238 227
 }
Please login to merge, or discard this patch.
includes/db/db_helpers.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,19 +27,19 @@  discard block
 block discarded – undo
27 27
  */
28 28
 function db_set_make_safe_string($set, $delta = false) {
29 29
   $set_safe = array();
30
-  foreach($set as $field => $value) {
31
-    if(empty($field)) {
30
+  foreach ($set as $field => $value) {
31
+    if (empty($field)) {
32 32
       continue;
33 33
     }
34 34
 
35 35
     $field = '`' . db_escape($field) . '`';
36 36
     $new_value = $value;
37
-    if($value === null) {
37
+    if ($value === null) {
38 38
       $new_value = 'NULL';
39
-    } elseif(is_string($value) && (string)($new_value = floatval($value)) != (string)$value) {
39
+    } elseif (is_string($value) && (string) ($new_value = floatval($value)) != (string) $value) {
40 40
       // non-float
41 41
       $new_value = '"' . db_escape($value) . '"';
42
-    } elseif($delta) {
42
+    } elseif ($delta) {
43 43
       // float and DELTA-set
44 44
       $new_value = "{$field} + ({$new_value})";
45 45
     }
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
  */
60 60
 function missile_list_convert_to_fleet(&$missile_db_list, &$fleet_db_list) {
61 61
   // Missile attack
62
-  foreach($missile_db_list as $irak) {
63
-    if($irak['fleet_end_time'] >= SN_TIME_NOW) {
62
+  foreach ($missile_db_list as $irak) {
63
+    if ($irak['fleet_end_time'] >= SN_TIME_NOW) {
64 64
       $irak['fleet_start_type'] = PT_PLANET;
65 65
       $planet_start = DBStaticPlanet::db_planet_by_vector($irak, 'fleet_start_', false, 'name');
66 66
       $irak['fleet_id'] = -$irak['id'];
Please login to merge, or discard this patch.
includes/general_pname.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,12 +2,10 @@
 block discarded – undo
2 2
 
3 3
 // Эти функции будут переписаны по добавлению инфы в БД
4 4
 
5
-function pname_factory_production_field_name($factory_unit_id)
6
-{
5
+function pname_factory_production_field_name($factory_unit_id) {
7 6
   return get_unit_param($factory_unit_id, P_NAME) . '_porcent';
8 7
 }
9 8
 
10
-function pname_resource_name($resource_id)
11
-{
9
+function pname_resource_name($resource_id) {
12 10
   return get_unit_param($resource_id, P_NAME);
13 11
 }
14 12
\ No newline at end of file
Please login to merge, or discard this patch.
includes/functions/int_fleet_events.php 3 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -8,23 +8,23 @@  discard block
 block discarded – undo
8 8
   $fleet_events = array();
9 9
   $fleet_number = 0;
10 10
 
11
-  if(empty($fleet_list))
11
+  if (empty($fleet_list))
12 12
   {
13 13
     return;
14 14
   }
15 15
 
16
-  foreach($fleet_list as $fleet)
16
+  foreach ($fleet_list as $fleet)
17 17
   {
18 18
     $planet_start_type = $fleet['fleet_start_type'] == PT_MOON ? PT_MOON : PT_PLANET;
19 19
     $planet_start = DBStaticPlanet::db_planet_by_gspt($fleet['fleet_start_galaxy'], $fleet['fleet_start_system'], $fleet['fleet_start_planet'], $planet_start_type, false, 'name');
20 20
     $fleet['fleet_start_name'] = $planet_start['name'];
21 21
 
22 22
     $planet_end_type = $fleet['fleet_end_type'] == PT_MOON ? PT_MOON : PT_PLANET;
23
-    if($fleet['fleet_end_planet'] > $config->game_maxPlanet)
23
+    if ($fleet['fleet_end_planet'] > $config->game_maxPlanet)
24 24
     {
25 25
       $fleet['fleet_end_name'] = $lang['ov_fleet_exploration'];
26 26
     }
27
-    elseif($fleet['fleet_mission'] == MT_COLONIZE)
27
+    elseif ($fleet['fleet_mission'] == MT_COLONIZE)
28 28
     {
29 29
       $fleet['fleet_end_name'] = $lang['ov_fleet_colonization'];
30 30
     }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
       $fleet['fleet_end_name'] = $planet_end['name'];
35 35
     }
36 36
 
37
-    if($fleet['fleet_start_time'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] != MT_MISSILE &&
37
+    if ($fleet['fleet_start_time'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] != MT_MISSILE &&
38 38
       ($planet_scanned === false
39 39
         ||
40 40
         (
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
       $fleet_events[] = flt_register_fleet_event($fleet, 0, $planet_end_type);
50 50
     }
51 51
 
52
-    if($fleet['fleet_end_stay'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $planet_scanned === false && $fleet['fleet_mission'] != MT_MISSILE)
52
+    if ($fleet['fleet_end_stay'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $planet_scanned === false && $fleet['fleet_mission'] != MT_MISSILE)
53 53
     {
54 54
       $fleet_events[] = flt_register_fleet_event($fleet, 1, $planet_end_type);
55 55
     }
56 56
 
57
-    if(
57
+    if (
58 58
       $fleet['fleet_end_time'] > SN_TIME_NOW && $fleet['fleet_mission'] != MT_MISSILE && ($fleet['fleet_mess'] == 1 || ($fleet['fleet_mission'] != MT_RELOCATE && $fleet['fleet_mission'] != MT_COLONIZE)) &&
59 59
       (
60 60
         ($planet_scanned === false && $fleet['fleet_owner'] == $user['id'])
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
       $fleet_events[] = flt_register_fleet_event($fleet, 2, $planet_end_type);
72 72
     }
73 73
     
74
-    if($fleet['fleet_mission'] == MT_MISSILE)
74
+    if ($fleet['fleet_mission'] == MT_MISSILE)
75 75
     {
76 76
       $fleet_events[] = flt_register_fleet_event($fleet, 3, $planet_end_type);
77 77
     }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 {
85 85
   global $user, $planetrow, $fleet_number;
86 86
 
87
-  switch($fleet['ov_label'] = $ov_label)
87
+  switch ($fleet['ov_label'] = $ov_label)
88 88
   {
89 89
     case 0:
90 90
       $fleet['event_time'] = $fleet['fleet_start_time'];
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 
117 117
   }
118 118
 
119
-  $fleet['ov_this_planet'] = $is_this_planet;// || $planet_scanned != false;
119
+  $fleet['ov_this_planet'] = $is_this_planet; // || $planet_scanned != false;
120 120
 
121
-  if($fleet['fleet_owner'] == $user['id'])
121
+  if ($fleet['fleet_owner'] == $user['id'])
122 122
   {
123 123
     $user_data = $user;
124 124
   }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -89,18 +89,18 @@  discard block
 block discarded – undo
89 89
     case 0:
90 90
       $fleet['event_time'] = $fleet['fleet_start_time'];
91 91
       $is_this_planet = (
92
-        ($planetrow['galaxy'] == $fleet['fleet_end_galaxy']) AND
93
-        ($planetrow['system'] == $fleet['fleet_end_system']) AND
94
-        ($planetrow['planet'] == $fleet['fleet_end_planet']) AND
92
+        ($planetrow['galaxy'] == $fleet['fleet_end_galaxy']) and
93
+        ($planetrow['system'] == $fleet['fleet_end_system']) and
94
+        ($planetrow['planet'] == $fleet['fleet_end_planet']) and
95 95
         ($planetrow['planet_type'] == $planet_end_type));
96 96
     break;
97 97
 
98 98
     case 1:
99 99
       $fleet['event_time'] = $fleet['fleet_end_stay'];
100 100
       $is_this_planet = (
101
-        ($planetrow['galaxy'] == $fleet['fleet_end_galaxy']) AND
102
-        ($planetrow['system'] == $fleet['fleet_end_system']) AND
103
-        ($planetrow['planet'] == $fleet['fleet_end_planet']) AND
101
+        ($planetrow['galaxy'] == $fleet['fleet_end_galaxy']) and
102
+        ($planetrow['system'] == $fleet['fleet_end_system']) and
103
+        ($planetrow['planet'] == $fleet['fleet_end_planet']) and
104 104
         ($planetrow['planet_type'] == $planet_end_type));
105 105
     break;
106 106
 
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
     case 3:
109 109
       $fleet['event_time'] = $fleet['fleet_end_time'];
110 110
       $is_this_planet = (
111
-        ($planetrow['galaxy'] == $fleet['fleet_start_galaxy']) AND
112
-        ($planetrow['system'] == $fleet['fleet_start_system']) AND
113
-        ($planetrow['planet'] == $fleet['fleet_start_planet']) AND
111
+        ($planetrow['galaxy'] == $fleet['fleet_start_galaxy']) and
112
+        ($planetrow['system'] == $fleet['fleet_start_system']) and
113
+        ($planetrow['planet'] == $fleet['fleet_start_planet']) and
114 114
         ($planetrow['planet_type'] == $fleet['fleet_start_type']));
115 115
     break;
116 116
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -3,8 +3,7 @@  discard block
 block discarded – undo
3 3
 
4 4
 use Planet\DBStaticPlanet;
5 5
 
6
-function flt_parse_fleets_to_events($fleet_list, $planet_scanned = false)
7
-{
6
+function flt_parse_fleets_to_events($fleet_list, $planet_scanned = false) {
8 7
   global $config, $user, $fleet_number, $lang;
9 8
 
10 9
   $fleet_events = array();
@@ -25,12 +24,10 @@  discard block
 block discarded – undo
25 24
     if($fleet['fleet_end_planet'] > $config->game_maxPlanet)
26 25
     {
27 26
       $fleet['fleet_end_name'] = $lang['ov_fleet_exploration'];
28
-    }
29
-    elseif($fleet['fleet_mission'] == MT_COLONIZE)
27
+    } elseif($fleet['fleet_mission'] == MT_COLONIZE)
30 28
     {
31 29
       $fleet['fleet_end_name'] = $lang['ov_fleet_colonization'];
32
-    }
33
-    else
30
+    } else
34 31
     {
35 32
       $planet_end = DBStaticPlanet::db_planet_by_gspt($fleet['fleet_end_galaxy'], $fleet['fleet_end_system'], $fleet['fleet_end_planet'], $planet_end_type, false, 'name');
36 33
       $fleet['fleet_end_name'] = $planet_end['name'];
@@ -82,8 +79,7 @@  discard block
 block discarded – undo
82 79
   return $fleet_events;
83 80
 }
84 81
 
85
-function flt_register_fleet_event($fleet, $ov_label, $planet_end_type)
86
-{
82
+function flt_register_fleet_event($fleet, $ov_label, $planet_end_type) {
87 83
   global $user, $planetrow, $fleet_number;
88 84
 
89 85
   switch($fleet['ov_label'] = $ov_label)
@@ -123,8 +119,7 @@  discard block
 block discarded – undo
123 119
   if($fleet['fleet_owner'] == $user['id'])
124 120
   {
125 121
     $user_data = $user;
126
-  }
127
-  else
122
+  } else
128 123
   {
129 124
     $user_data = db_user_by_id($fleet['fleet_owner']);
130 125
   }
@@ -136,8 +131,7 @@  discard block
 block discarded – undo
136 131
  * @param array    $planetrow
137 132
  * @param template $template
138 133
  */
139
-function int_planet_pretemplate($planetrow, &$template)
140
-{
134
+function int_planet_pretemplate($planetrow, &$template) {
141 135
   global $lang, $user;
142 136
 
143 137
   $governor_id = $planetrow['PLANET_GOVERNOR_ID'];
Please login to merge, or discard this patch.
includes/functions/rpg_points.php 2 patches
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -161,8 +161,7 @@  discard block
 block discarded – undo
161 161
   return $rows_affected;
162 162
 }
163 163
 
164
-function rpg_level_up(&$user, $type, $xp_to_add = 0)
165
-{
164
+function rpg_level_up(&$user, $type, $xp_to_add = 0) {
166 165
   $q = 1.03;
167 166
 
168 167
   switch($type)
@@ -223,27 +222,22 @@  discard block
 block discarded – undo
223 222
   }
224 223
 }
225 224
 
226
-function rpg_xp_for_level($level, $b1, $q)
227
-{
225
+function rpg_xp_for_level($level, $b1, $q) {
228 226
   return floor($b1 * (pow($q, $level) - 1)/($q - 1));
229 227
 }
230 228
 
231
-function rpg_get_miner_xp($level)
232
-{
229
+function rpg_get_miner_xp($level) {
233 230
   return rpg_xp_for_level($level, 50, 1.03);
234 231
 }
235 232
 
236
-function RPG_get_raider_xp($level)
237
-{
233
+function RPG_get_raider_xp($level) {
238 234
   return rpg_xp_for_level($level, 10, 1.03);
239 235
 }
240 236
 
241
-function rpg_get_tech_xp($level)
242
-{
237
+function rpg_get_tech_xp($level) {
243 238
   return rpg_xp_for_level($level, 50, 1.03);
244 239
 }
245 240
 
246
-function rpg_get_explore_xp($level)
247
-{
241
+function rpg_get_explore_xp($level) {
248 242
   return rpg_xp_for_level($level, 10, 1.05);
249 243
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -22,28 +22,28 @@  discard block
 block discarded – undo
22 22
 function rpg_points_change($user_id, $change_type, $dark_matter, $comment = false, $already_changed = false) {
23 23
   global $debug, $config, $dm_change_legit, $user;
24 24
 
25
-  if(!$user_id) {
25
+  if (!$user_id) {
26 26
     return false;
27 27
   }
28 28
 
29 29
   $dm_change_legit = true;
30 30
   $sn_data_dark_matter_db_name = pname_resource_name(RES_DARK_MATTER);
31 31
 
32
-  if($already_changed) {
32
+  if ($already_changed) {
33 33
     $rows_affected = 1;
34 34
   } else {
35 35
     $changeset = array();
36 36
     $a_user = db_user_by_id($user_id, true);
37
-    if($dark_matter < 0) {
37
+    if ($dark_matter < 0) {
38 38
       $dark_matter_exists = mrc_get_level($a_user, null, RES_DARK_MATTER, false, true);
39 39
       $dark_matter_exists < 0 ? $dark_matter_exists = 0 : false;
40 40
       $metamatter_to_reduce = -$dark_matter - $dark_matter_exists;
41
-      if($metamatter_to_reduce > 0) {
41
+      if ($metamatter_to_reduce > 0) {
42 42
         $metamatter_exists = mrc_get_level($a_user, null, RES_METAMATTER);
43
-        if($metamatter_exists < $metamatter_to_reduce) {
43
+        if ($metamatter_exists < $metamatter_to_reduce) {
44 44
           $debug->error('Ошибка снятия ТМ - ММ+ТМ меньше, чем сумма для снятия!', 'Ошибка снятия ТМ', LOG_ERR_INT_NOT_ENOUGH_DARK_MATTER);
45 45
         }
46
-        if(is_array($comment)) {
46
+        if (is_array($comment)) {
47 47
           $comment = call_user_func_array('sprintf', $comment);
48 48
         }
49 49
 //        mm_points_change($user_id, $change_type, -$metamatter_to_reduce, 'ММ в ТМ: ' . (-$dark_matter) . ' ТМ = ' . $dark_matter_exists . ' ТМ + ' . $metamatter_to_reduce . ' ММ. ' . $comment);
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
     $rows_affected = SN::$db->db_affected_rows();
59 59
   }
60 60
 
61
-  if($rows_affected || !$dark_matter) {
61
+  if ($rows_affected || !$dark_matter) {
62 62
     $page_url = db_escape($_SERVER['SCRIPT_NAME']);
63
-    if(is_array($comment)) {
63
+    if (is_array($comment)) {
64 64
       $comment = call_user_func_array('sprintf', $comment);
65 65
     }
66 66
     $comment = db_escape($comment);
@@ -74,18 +74,18 @@  discard block
 block discarded – undo
74 74
         {$dark_matter}, '{$comment}', '{$page_url}', {$user_id}
75 75
       );");
76 76
 
77
-    if($user['id'] == $user_id) {
77
+    if ($user['id'] == $user_id) {
78 78
       $user['dark_matter'] += $dark_matter;
79 79
     }
80 80
 
81
-    if($dark_matter > 0) {
81
+    if ($dark_matter > 0) {
82 82
       $old_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id} LIMIT 1 FOR UPDATE;", '', true);
83
-      if($old_referral['id']) {
83
+      if ($old_referral['id']) {
84 84
         doquery("UPDATE {{referrals}} SET dark_matter = dark_matter + '{$dark_matter}' WHERE `id` = {$user_id} LIMIT 1;");
85 85
         $new_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id} LIMIT 1;", '', true);
86 86
 
87 87
         $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);
88
-        if($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) {
88
+        if ($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) {
89 89
           rpg_points_change($new_referral['id_partner'], RPG_REFERRAL, $partner_bonus, "Incoming From Referral ID {$user_id}");
90 90
         }
91 91
       }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 {
103 103
   $q = 1.03;
104 104
 
105
-  switch($type)
105
+  switch ($type)
106 106
   {
107 107
     case RPG_STRUCTURE:
108 108
       $field_level = 'lvl_minier';
@@ -140,19 +140,19 @@  discard block
 block discarded – undo
140 140
 
141 141
   $xp = &$user[$field_xp];
142 142
 
143
-  if($xp_to_add)
143
+  if ($xp_to_add)
144 144
   {
145 145
     $xp += $xp_to_add;
146 146
     db_user_set_by_id($user['id'], "`{$field_xp}` = `{$field_xp}` + '{$xp_to_add}'");
147 147
   }
148 148
 
149 149
   $level = $user[$field_level];
150
-  while($xp > rpg_xp_for_level($level + 1, $b1, $q))
150
+  while ($xp > rpg_xp_for_level($level + 1, $b1, $q))
151 151
   {
152 152
     $level++;
153 153
   }
154 154
   $level -= $user[$field_level];
155
-  if($level > 0)
155
+  if ($level > 0)
156 156
   {
157 157
     db_user_set_by_id($user['id'], "`{$field_level}` = `{$field_level}` + '{$level}'");
158 158
     rpg_points_change($user['id'], $type, $level * 1000, $comment);
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 
163 163
 function rpg_xp_for_level($level, $b1, $q)
164 164
 {
165
-  return floor($b1 * (pow($q, $level) - 1)/($q - 1));
165
+  return floor($b1 * (pow($q, $level) - 1) / ($q - 1));
166 166
 }
167 167
 
168 168
 function rpg_get_miner_xp($level)
Please login to merge, or discard this patch.
includes/functions/eco_queue.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -458,8 +458,7 @@
 block discarded – undo
458 458
 
459 459
     if(is_numeric($planet['id'])) {
460 460
       DBStaticPlanet::db_planet_set_by_id($planet['id'], "`que_processed` = UNIX_TIMESTAMP(NOW())");
461
-    }
462
-    elseif(is_numeric($user['id'])) {
461
+    } elseif(is_numeric($user['id'])) {
463 462
       db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())');
464 463
     }
465 464
 
Please login to merge, or discard this patch.
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 function que_get_unit_que($unit_id) {
4 4
   $que_type = false;
5
-  foreach(sn_get_groups('ques') as $que_id => $que_data) {
6
-    if(in_array($unit_id, $que_data['unit_list'])) {
5
+  foreach (sn_get_groups('ques') as $que_id => $que_data) {
6
+    if (in_array($unit_id, $que_data['unit_list'])) {
7 7
       $que_type = $que_id;
8 8
       break;
9 9
     }
@@ -16,14 +16,14 @@  discard block
 block discarded – undo
16 16
 function que_get_max_que_length($user, $planet, $que_id, $que_data = null) {
17 17
   global $config;
18 18
 
19
-  if(empty($que_data)) {
19
+  if (empty($que_data)) {
20 20
     $que_data = sn_get_groups('ques');
21 21
     $que_data = $que_data[$que_id];
22 22
   }
23 23
 
24 24
 
25 25
   $que_length = 1;
26
-  switch($que_id) {
26
+  switch ($que_id) {
27 27
     case QUE_RESEARCH:
28 28
       $que_length = $config->server_que_length_research + mrc_get_level($user, '', UNIT_PREMIUM); // TODO - вынести в модуль
29 29
     break;
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 
38 38
 function eco_que_str2arr($que_str) {
39 39
   $que_arr = explode(';', $que_str);
40
-  foreach($que_arr as $que_index => &$que_item) {
41
-    if($que_item) {
40
+  foreach ($que_arr as $que_index => &$que_item) {
41
+    if ($que_item) {
42 42
       $que_item = explode(',', $que_item);
43 43
     } else {
44 44
       unset($que_arr[$que_index]);
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 }
49 49
 
50 50
 function eco_que_arr2str($que_arr) {
51
-  foreach($que_arr as &$que_item) {
51
+  foreach ($que_arr as &$que_item) {
52 52
     $que_item = implode(',', $que_item);
53 53
   }
54 54
   return implode(';', $que_arr);
@@ -59,14 +59,14 @@  discard block
 block discarded – undo
59 59
   global $lang, $config;
60 60
 
61 61
   $is_autoconvert = false;
62
-  if($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) {
62
+  if ($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) {
63 63
     $build_mode = BUILD_CREATE;
64 64
     $is_autoconvert = true;
65 65
   }
66 66
 
67 67
   $unit_amount_qued = 0;
68 68
   try {
69
-    if(!$user['id']) {
69
+    if (!$user['id']) {
70 70
       throw new exception('{Нет идентификатора пользователя - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION
71 71
     }
72 72
 
@@ -77,16 +77,16 @@  discard block
 block discarded – undo
77 77
       foreach($unit_list as $unit_id => $unit_amount) if($unit_amount) break;
78 78
     }
79 79
     */
80
-    if(!$unit_id) {
80
+    if (!$unit_id) {
81 81
       throw new exception('{Нет идентификатора юнита - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION
82 82
     }
83 83
 
84 84
     $que_id = que_get_unit_que($unit_id);
85
-    if(!$que_id) {
85
+    if (!$que_id) {
86 86
       throw new exception('{Неправильный тип очереди - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION
87 87
     }
88 88
 
89
-    if($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) {
89
+    if ($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) {
90 90
       throw new exception('{Уничтожать можно только здания на планете}', ERR_ERROR); // TODO EXCEPTION
91 91
     }
92 92
 
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
     $que_data = $que_data[$que_id];
95 95
 
96 96
     // TODO Переделать под подочереди
97
-    if($que_id == QUE_STRUCTURES) {
97
+    if ($que_id == QUE_STRUCTURES) {
98 98
       $sn_groups_build_allow = sn_get_groups('build_allow');
99 99
       $que_data['unit_list'] = $sn_groups_build_allow[$planet['planet_type']];
100 100
 
101
-      if(!isset($que_data['unit_list'][$unit_id])) {
101
+      if (!isset($que_data['unit_list'][$unit_id])) {
102 102
         throw new exception('{Это здание нельзя строить на ' . ($planet['planet_type'] == PT_PLANET ? 'планете' : 'луне'), ERR_ERROR); // TODO EXCEPTION
103 103
       }
104 104
     }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     // Это нужно, что бы заблокировать пользователя и работу с очередями
120 120
     $user = db_user_by_id($user['id']);
121 121
     // Это нужно, что бы заблокировать планету от списания ресурсов
122
-    if(isset($planet['id']) && $planet['id']) {
122
+    if (isset($planet['id']) && $planet['id']) {
123 123
       $planet = DBStaticPlanet::db_planet_by_id($planet['id'], true);
124 124
     } else {
125 125
       $planet['id'] = 0;
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
     $in_que = &$que['in_que'][$que_id][$user['id']][$planet_id];
132 132
     $que_max_length = que_get_max_que_length($user, $planet, $que_id, $que_data);
133 133
     // TODO Добавить вызовы функций проверок текущей и максимальной длин очередей
134
-    if(count($in_que) >= $que_max_length) {
134
+    if (count($in_que) >= $que_max_length) {
135 135
       throw new exception('{Все слоты очереди заняты}', ERR_ERROR); // TODO EXCEPTION
136 136
     }
137 137
 
138 138
     // TODO Отдельно посмотреть на уничтожение зданий - что бы можно было уничтожать их без планов
139
-    switch(eco_can_build_unit($user, $planet, $unit_id)) {
139
+    switch (eco_can_build_unit($user, $planet, $unit_id)) {
140 140
       case BUILD_ALLOWED: break;
141 141
       case BUILD_UNIT_BUSY: throw new exception('{Строение занято}', ERR_ERROR); break; // TODO EXCEPTION eco_bld_msg_err_laboratory_upgrading
142 142
       // case BUILD_REQUIRE_NOT_MEET:
143 143
       default:
144
-        if($build_mode == BUILD_CREATE) {
144
+        if ($build_mode == BUILD_CREATE) {
145 145
           throw new exception('{Требования не удовлетворены}', ERR_ERROR);
146 146
         }
147 147
         break; // TODO EXCEPTION eco_bld_msg_err_requirements_not_meet
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
     $unit_amount_qued = $unit_amount;
152 152
     $units_qued = isset($in_que[$unit_id]) ? $in_que[$unit_id] : 0;
153 153
     $unit_level = mrc_get_level($user, $planet, $unit_id, true, true) + $units_qued;
154
-    if($unit_max = get_unit_param($unit_id, P_MAX_STACK)) {
155
-      if($unit_level >= $unit_max) {
154
+    if ($unit_max = get_unit_param($unit_id, P_MAX_STACK)) {
155
+      if ($unit_level >= $unit_max) {
156 156
         throw new exception('{Максимальное количество юнитов данного типа уже достигнуто или будет достигнуто по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION
157 157
       }
158 158
       $unit_amount = max(0, min($unit_amount, $unit_max - $unit_level));
159 159
     }
160 160
 
161
-    if($unit_amount < 1) {
161
+    if ($unit_amount < 1) {
162 162
       throw new exception('{Неправильное количество юнитов - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION
163 163
     }
164 164
 
@@ -174,21 +174,21 @@  discard block
 block discarded – undo
174 174
     //  {
175 175
     //    die('Unit busy'); // TODO EXCEPTION
176 176
     //  }
177
-    if(get_unit_param($unit_id, P_STACKABLE)) {
177
+    if (get_unit_param($unit_id, P_STACKABLE)) {
178 178
       // TODO Поле 'max_Lot_size' для ограничения размера стэка в очереди - то ли в юниты, то ли в очередь
179
-      if(in_array($unit_id, $group_missile = sn_get_groups('missile'))) {
179
+      if (in_array($unit_id, $group_missile = sn_get_groups('missile'))) {
180 180
         // TODO Поле 'container' - указывает на родительску структуру, в которой хранится данный юнит и по вместительности которой нужно применять размер юнита
181 181
         $used_silo = 0;
182
-        foreach($group_missile as $missile_id) {
182
+        foreach ($group_missile as $missile_id) {
183 183
           $missile_qued = isset($in_que[$missile_id]) ? $in_que[$missile_id] : 0;
184 184
           $used_silo += (mrc_get_level($user, $planet, $missile_id, true, true) + $missile_qued) * get_unit_param($missile_id, P_UNIT_SIZE);
185 185
         }
186 186
         $free_silo = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY) - $used_silo;
187
-        if($free_silo <= 0) {
187
+        if ($free_silo <= 0) {
188 188
           throw new exception('{Ракетная шахта уже заполнена или будет заполнена по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION
189 189
         }
190 190
         $unit_size = get_unit_param($unit_id, P_UNIT_SIZE);
191
-        if($free_silo < $unit_size) {
191
+        if ($free_silo < $unit_size) {
192 192
           throw new exception("{В ракетной шахте нет места для {$lang['tech'][$unit_id]}}", ERR_ERROR); // TODO EXCEPTION
193 193
         }
194 194
         $unit_amount = max(0, min($unit_amount, floor($free_silo / $unit_size)));
@@ -196,10 +196,10 @@  discard block
 block discarded – undo
196 196
       $unit_level = $new_unit_level = 0;
197 197
     } else {
198 198
       $unit_amount = 1;
199
-      if($que_id == QUE_STRUCTURES) {
199
+      if ($que_id == QUE_STRUCTURES) {
200 200
         // if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $que['sectors'][$planet['id']] <= 0)
201 201
         $sectors_qued = is_array($in_que) ? array_sum($in_que) : 0;
202
-        if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0)
202
+        if ($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0)
203 203
         {
204 204
           throw new exception('{Не хватает секторов на планете}', ERR_ERROR); // TODO EXCEPTION
205 205
         }
@@ -217,9 +217,9 @@  discard block
 block discarded – undo
217 217
 
218 218
     $exchange = array();
219 219
     $market_get_autoconvert_cost = market_get_autoconvert_cost();
220
-    if($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) {
220
+    if ($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) {
221 221
       $dark_matter = mrc_get_level($user, null, RES_DARK_MATTER);
222
-      if(mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) {
222
+      if (mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) {
223 223
         throw new exception("{Нет хватает " . ($market_get_autoconvert_cost - $dark_matter) . "ТМ на постройки с автоконвертацией ресурсов}", ERR_ERROR); // TODO EXCEPTION
224 224
       }
225 225
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
       $resource_exchange_rates = array();
230 230
       $resource_diff = array();
231 231
       $all_positive = true;
232
-      foreach($resources_loot as $resource_id) {
232
+      foreach ($resources_loot as $resource_id) {
233 233
         $resource_db_name = pname_resource_name($resource_id);
234 234
         $resource_got[$resource_id] = floor(mrc_get_level($user, $planet, $resource_id));
235 235
         $resource_exchange_rates[$resource_id] = $config->__get("rpg_exchange_{$resource_db_name}");
@@ -237,15 +237,15 @@  discard block
 block discarded – undo
237 237
         $all_positive = $all_positive && ($resource_diff[$resource_id] > 0);
238 238
       }
239 239
       // Нужна автоконвертация
240
-      if($all_positive) {
240
+      if ($all_positive) {
241 241
         $is_autoconvert = false;
242 242
       } else {
243
-        foreach($resource_diff as $resource_diff_id => &$resource_diff_amount) {
244
-          if($resource_diff_amount >= 0) {
243
+        foreach ($resource_diff as $resource_diff_id => &$resource_diff_amount) {
244
+          if ($resource_diff_amount >= 0) {
245 245
             continue;
246 246
           }
247
-          foreach($resource_diff as $resource_got_id => &$resource_got_amount) {
248
-            if($resource_got_amount <= 0) {
247
+          foreach ($resource_diff as $resource_got_id => &$resource_got_amount) {
248
+            if ($resource_got_amount <= 0) {
249 249
               continue;
250 250
             }
251 251
             $current_exchange = $resource_exchange_rates[$resource_got_id] / $resource_exchange_rates[$resource_diff_id];
@@ -261,14 +261,14 @@  discard block
 block discarded – undo
261 261
         }
262 262
 
263 263
         $is_autoconvert_ok = true;
264
-        foreach($resource_diff as $resource_diff_amount2) {
265
-          if($resource_diff_amount2 < 0) {
264
+        foreach ($resource_diff as $resource_diff_amount2) {
265
+          if ($resource_diff_amount2 < 0) {
266 266
             $is_autoconvert_ok = false;
267 267
             break;
268 268
           }
269 269
         }
270 270
 
271
-        if($is_autoconvert_ok) {
271
+        if ($is_autoconvert_ok) {
272 272
           $build_data['RESULT'][$build_mode] = BUILD_ALLOWED;
273 273
           $build_data['CAN'][$build_mode] = $unit_amount;
274 274
         } else {
@@ -277,19 +277,19 @@  discard block
 block discarded – undo
277 277
       }
278 278
     }
279 279
     $unit_amount = min($build_data['CAN'][$build_mode], $unit_amount);
280
-    if($unit_amount <= 0) {
280
+    if ($unit_amount <= 0) {
281 281
       throw new exception('{Не хватает ресурсов}', ERR_ERROR); // TODO EXCEPTION
282 282
     }
283 283
 
284
-    if($new_unit_level < 0) {
284
+    if ($new_unit_level < 0) {
285 285
       throw new exception('{Нельзя уничтожить больше юнитов, чем есть}', ERR_ERROR); // TODO EXCEPTION
286 286
     }
287 287
 
288
-    if($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) {
288
+    if ($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) {
289 289
       throw new exception('{Строительство блокировано}', ERR_ERROR); // TODO EXCEPTION
290 290
     }
291 291
 
292
-    if($is_autoconvert) {
292
+    if ($is_autoconvert) {
293 293
       ksort($exchange);
294 294
       ksort($resource_got);
295 295
       db_change_units($user, $planet, array(
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
     }
305 305
 
306 306
     $unit_amount_qued = 0;
307
-    while($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) {
307
+    while ($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) {
308 308
       $place = min($unit_amount, MAX_FLEET_OR_DEFS_PER_ROW);
309 309
       que_add_unit($unit_id, $user, $planet, $build_data, $new_unit_level, $place, $build_mode);
310 310
       $unit_amount -= $place;
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 
315 315
     sn_db_transaction_commit();
316 316
 
317
-    if($redirect) {
317
+    if ($redirect) {
318 318
       sys_redirect("{$_SERVER['PHP_SELF']}?mode=" . sys_get_param_str('mode') . "&ally_id=" . sys_get_param_id('ally_id'));
319 319
     }
320 320
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
       'STATUS'  => ERR_NONE,
323 323
       'MESSAGE' => '{Строительство начато}',
324 324
     );
325
-  } catch(exception $e) {
325
+  } catch (exception $e) {
326 326
     sn_db_transaction_rollback();
327 327
     $operation_result = array(
328 328
       'STATUS'  => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR,
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
     );
331 331
   }
332 332
 
333
-  if(!empty($operation_result['MESSAGE'])) {
333
+  if (!empty($operation_result['MESSAGE'])) {
334 334
     $operation_result['MESSAGE'] .= ' ' . ($unit_amount_qued ? $unit_amount_qued : $unit_amount) . 'x[' . $lang['tech'][$unit_id] . ']';
335 335
   }
336 336
 
@@ -344,11 +344,11 @@  discard block
 block discarded – undo
344 344
 function que_recalculate($old_que) {
345 345
   $new_que = array();
346 346
 
347
-  if(!is_array($old_que['items'])) {
347
+  if (!is_array($old_que['items'])) {
348 348
     return $new_que;
349 349
   }
350
-  foreach($old_que['items'] as $row) {
351
-    if(!isset($row) || !$row || $row['que_unit_amount'] <= 0) {
350
+  foreach ($old_que['items'] as $row) {
351
+    if (!isset($row) || !$row || $row['que_unit_amount'] <= 0) {
352 352
       continue;
353 353
     }
354 354
 
@@ -359,9 +359,9 @@  discard block
 block discarded – undo
359 359
 
360 360
     $last_id = count($new_que['items']) - 1;
361 361
 
362
-    if($row['que_planet_id']) {
362
+    if ($row['que_planet_id']) {
363 363
       $new_que['planets'][$row['que_planet_id']][$row['que_type']][] = &$new_que['items'][$last_id];
364
-    } elseif($row['que_type'] == QUE_RESEARCH) {
364
+    } elseif ($row['que_type'] == QUE_RESEARCH) {
365 365
       $new_que['players'][$row['que_player_id']][$row['que_type']][] = &$new_que['items'][$last_id];
366 366
     }
367 367
     $new_que['ques'][$row['que_type']][$row['que_player_id']][intval($row['que_planet_id'])][] = &$new_que['items'][$last_id];
@@ -396,9 +396,9 @@  discard block
 block discarded – undo
396 396
   $que_type = que_get_unit_que($unit_id);
397 397
   $planet_id_origin = $planet['id'] ? $planet['id'] : 'NULL';
398 398
   $planet_id = $que_type == QUE_RESEARCH ? 'NULL' : $planet_id_origin;
399
-  if(is_numeric($planet_id)) {
399
+  if (is_numeric($planet_id)) {
400 400
     DBStaticPlanet::db_planet_set_by_id($planet_id, "`que_processed` = UNIX_TIMESTAMP(NOW())");
401
-  } elseif(is_numeric($user['id'])) {
401
+  } elseif (is_numeric($user['id'])) {
402 402
     db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())');
403 403
   }
404 404
 
@@ -428,17 +428,17 @@  discard block
 block discarded – undo
428 428
   $planet['id'] = $planet['id'] && $que_type !== QUE_RESEARCH ? $planet['id'] : 0;
429 429
   $global_que = que_get($user['id'], $planet['id'], $que_type, true);
430 430
 
431
-  if(!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) {
431
+  if (!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) {
432 432
     $que = array_reverse($global_que['ques'][$que_type][$user['id']][$planet['id']]);
433 433
 
434
-    foreach($que as $que_item) {
434
+    foreach ($que as $que_item) {
435 435
       DBStaticQue::db_que_delete_by_id($que_item['que_id']);
436 436
 
437
-      if($que_item['que_planet_id_origin']) {
437
+      if ($que_item['que_planet_id_origin']) {
438 438
         $planet['id'] = $que_item['que_planet_id_origin'];
439 439
       }
440 440
 
441
-      if(!isset($planets_locked[$planet['id']])) {
441
+      if (!isset($planets_locked[$planet['id']])) {
442 442
         $planets_locked[$planet['id']] = $planet['id'] ? DBStaticPlanet::db_planet_by_id($planet['id'], true) : $planet;
443 443
       }
444 444
 
@@ -450,15 +450,15 @@  discard block
 block discarded – undo
450 450
         RES_DEUTERIUM => $build_data[RES_DEUTERIUM] * $que_item['que_unit_amount'],
451 451
       ));
452 452
 
453
-      if(!$clear) {
453
+      if (!$clear) {
454 454
         break;
455 455
       }
456 456
     }
457 457
 
458
-    if(is_numeric($planet['id'])) {
458
+    if (is_numeric($planet['id'])) {
459 459
       DBStaticPlanet::db_planet_set_by_id($planet['id'], "`que_processed` = UNIX_TIMESTAMP(NOW())");
460 460
     }
461
-    elseif(is_numeric($user['id'])) {
461
+    elseif (is_numeric($user['id'])) {
462 462
       db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())');
463 463
     }
464 464
 
@@ -503,21 +503,21 @@  discard block
 block discarded – undo
503 503
   // TODO: Переделать для $que_type === false
504 504
   $planet['id'] = $planet['id'] ? $planet['id'] : 0;
505 505
 
506
-  if(!is_array($que)) {
506
+  if (!is_array($que)) {
507 507
     $que = que_get($user['id'], $planet['id'], $que_type);
508 508
   }
509 509
 
510
-  if(is_array($que) && isset($que['items'])) {
510
+  if (is_array($que) && isset($que['items'])) {
511 511
     $que = $que['ques'][$que_type][$user['id']][$planet['id']];
512 512
   }
513 513
 
514
-  if($que) {
515
-    foreach($que as $que_element) {
514
+  if ($que) {
515
+    foreach ($que as $que_element) {
516 516
       $template->assign_block_vars('que', que_tpl_parse_element($que_element, $short_names));
517 517
     }
518 518
   }
519 519
 
520
-  if($que_type == QUE_RESEARCH) {
520
+  if ($que_type == QUE_RESEARCH) {
521 521
     // TODO Исправить
522 522
 //    $template->assign_var('RESEARCH_ONGOING', count($global_que[QUE_RESEARCH][0]) >= $config->server_que_length_research);
523 523
   }
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
   $user = db_user_by_id($user['id'], true);
546 546
 
547 547
   $time_left[$user['id']][0] = max(0, $on_time - $user['que_processed']);
548
-  if($planet === null && !$time_left[$user['id']][0]) {
548
+  if ($planet === null && !$time_left[$user['id']][0]) {
549 549
     // TODO
550 550
     return $que;
551 551
   }
@@ -554,12 +554,12 @@  discard block
 block discarded – undo
554 554
   $que_type_id = $planet === null ? QUE_RESEARCH : false;
555 555
   $planet = intval(is_array($planet) ? $planet['id'] : $planet); // В $planet у нас теперь только её ID или шаблон null/0/false
556 556
   $que = que_get($user['id'], $planet, $que_type_id, true);
557
-  if(empty($que['items'])) {
557
+  if (empty($que['items'])) {
558 558
     return $que;
559 559
   }
560 560
 
561 561
   $planet_list = array();
562
-  if($planet !== null) {
562
+  if ($planet !== null) {
563 563
     // Если нужно изменять данные на планетах - блокируем планеты и получаем данные о них
564 564
     // TODO - от них не надо ничего, кроме ID и que_processed
565 565
     $planet_row = DBStaticPlanet::db_planet_list_by_user_or_planet($user['id'], $planet);
@@ -568,21 +568,21 @@  discard block
 block discarded – undo
568 568
   }
569 569
 
570 570
   // Теперь в $time_left лежит время обсчета всех очередей по каждой из планеты
571
-  if(array_sum($time_left[$user['id']]) == 0) {
571
+  if (array_sum($time_left[$user['id']]) == 0) {
572 572
     return $que;
573 573
   }
574 574
 
575 575
   $db_changeset = array();
576 576
   $unit_changes = array();
577
-  foreach($que['items'] as &$que_item) {
577
+  foreach ($que['items'] as &$que_item) {
578 578
     $que_player_id = &$que_item['que_player_id'];
579 579
     $que_planet_id = intval($que_item['que_planet_id']);
580 580
 
581 581
     $que_time_left = &$que['time_left'][$que_player_id][$que_planet_id][$que_item['que_type']];
582
-    if(!isset($que_time_left)) {
582
+    if (!isset($que_time_left)) {
583 583
       $que_time_left = $time_left[$que_player_id][$que_planet_id];
584 584
     }
585
-    if($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) {
585
+    if ($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) {
586 586
       continue;
587 587
     }
588 588
     // Дальше мы идем, если только осталось время в очереди И юниты к постройке
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
     // Теперь работаем с остатком времени на юните. Оно не может быть равно или меньше нуля
596 596
 
597 597
     // Если времени в очереди осталось не меньше, чем время текущего юнита - значит мы достроили юнит
598
-    if($que_time_left >= $que_item['que_time_left']) {
598
+    if ($que_time_left >= $que_item['que_time_left']) {
599 599
       // Увеличиваем количество отстроенных юнитов
600 600
       $unit_processed++;
601 601
       // Вычитаем из времени очереди потраченное на постройку время
@@ -608,12 +608,12 @@  discard block
 block discarded – undo
608 608
     $que_item['que_unit_amount'] -= $unit_processed;
609 609
 
610 610
     // Если еще остались юниты - значит ВСЁ оставшееся время приходится на достройку следующего юнита
611
-    if($que_item['que_unit_amount'] > 0) {
611
+    if ($que_item['que_unit_amount'] > 0) {
612 612
       $que_item['que_time_left'] = $que_item['que_time_left'] - $que_time_left;
613 613
       $que_time_left = 0;
614 614
     }
615 615
 
616
-    if($que_item['que_unit_amount'] <= 0) {
616
+    if ($que_item['que_unit_amount'] <= 0) {
617 617
       $db_changeset['que'][] = array(
618 618
         'action' => SQL_OP_DELETE,
619 619
         P_VERSION => 1,
@@ -639,14 +639,14 @@  discard block
 block discarded – undo
639 639
       );
640 640
     }
641 641
 
642
-    if($unit_processed) {
642
+    if ($unit_processed) {
643 643
       $unit_processed_delta = $unit_processed * ($que_item['que_unit_mode'] == BUILD_CREATE ? 1 : -1);
644 644
       $unit_changes[$que_player_id][$que_planet_id][$que_item['que_unit_id']] += $unit_processed_delta;
645 645
     }
646 646
   }
647 647
 
648
-  foreach($time_left as $player_id => $planet_data) {
649
-    foreach($planet_data as $planet_id => $time_on_planet) {
648
+  foreach ($time_left as $player_id => $planet_data) {
649
+    foreach ($planet_data as $planet_id => $time_on_planet) {
650 650
       $table = $planet_id ? 'planets' : 'users';
651 651
       $id = $planet_id ? $planet_id : $player_id;
652 652
       $db_changeset[$table][] = array(
@@ -662,8 +662,8 @@  discard block
 block discarded – undo
662 662
         ),
663 663
       );
664 664
 
665
-      if(is_array($unit_changes[$player_id][$planet_id])) {
666
-        foreach($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) {
665
+      if (is_array($unit_changes[$player_id][$planet_id])) {
666
+        foreach ($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) {
667 667
           $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, $unit_amount, $user, $planet_id ? $planet_id : null);
668 668
         }
669 669
       }
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
   $que = que_recalculate($que);
674 674
 
675 675
   // TODO: Re-enable quests for Alliances
676
-  if(!empty($unit_changes) && !$user['user_as_ally']) {
676
+  if (!empty($unit_changes) && !$user['user_as_ally']) {
677 677
     $quest_list = qst_get_quests($user['id'], QUEST_STATUS_ALL);
678 678
     $quest_triggers = qst_active_triggers($quest_list);
679 679
     $quest_rewards = array();
@@ -681,26 +681,26 @@  discard block
 block discarded – undo
681 681
 
682 682
 
683 683
     $xp_incoming = array();
684
-    foreach($unit_changes as $user_id => $planet_changes) {
685
-      foreach($planet_changes as $planet_id => $changes) {
684
+    foreach ($unit_changes as $user_id => $planet_changes) {
685
+      foreach ($planet_changes as $planet_id => $changes) {
686 686
         $planet_this = $planet_id ? SN::db_get_record_by_id(LOC_PLANET, $planet_id) : array();
687
-        foreach($changes as $unit_id => $unit_value) {
687
+        foreach ($changes as $unit_id => $unit_value) {
688 688
           $que_id = que_get_unit_que($unit_id);
689 689
           $unit_level_new = mrc_get_level($user, $planet_this, $unit_id, false, true) + $unit_value;
690
-          if($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) {
690
+          if ($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) {
691 691
             $build_data = eco_get_build_data($user, $planet_this, $unit_id, $unit_level_new - 1);
692 692
             $build_data = $build_data[BUILD_CREATE];
693
-            foreach(sn_get_groups('resources_loot') as $resource_id) {
693
+            foreach (sn_get_groups('resources_loot') as $resource_id) {
694 694
               $xp_incoming[$que_id] += $build_data[$resource_id]; // TODO - добавить конверсию рейтов обмена
695 695
             }
696 696
           }
697 697
 
698
-          if(is_array($quest_triggers)) {
698
+          if (is_array($quest_triggers)) {
699 699
             // TODO: Check mutiply condition quests
700 700
             $quest_trigger_list = array_keys($quest_triggers, $unit_id);
701 701
 
702
-            if(is_array($quest_trigger_list)) {
703
-              foreach($quest_trigger_list as $quest_id) {
702
+            if (is_array($quest_trigger_list)) {
703
+              foreach ($quest_trigger_list as $quest_id) {
704 704
                 if ($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE) {
705 705
                   if ($quest_list[$quest_id]['quest_unit_amount'] <= $unit_level_new) {
706 706
                     $quest_rewards[$quest_id][$user_id][$planet_id] = $quest_list[$quest_id]['quest_rewards_list'];
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
     // TODO: Изменить начисление награды за квесты на ту планету, на которой происходил ресеч
719 719
     qst_reward($user, $quest_rewards, $quest_list, $quest_statuses);
720 720
 
721
-    foreach($xp_incoming as $que_id => $xp) {
721
+    foreach ($xp_incoming as $que_id => $xp) {
722 722
       rpg_level_up($user, $que_id == QUE_RESEARCH ? RPG_TECH : RPG_STRUCTURE, $xp / 1000);
723 723
     }
724 724
   }
Please login to merge, or discard this patch.
includes/functions/sys_maintenance.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-function sys_maintenance()
4
-{
3
+function sys_maintenance() {
5 4
   global $config;
6 5
 
7 6
   $bashing_time_limit = SN_TIME_NOW - $config->fleet_bashing_scope;
@@ -42,8 +41,7 @@  discard block
 block discarded – undo
42 41
  * TODO: 2. [<m|w|d|h|m|s>@]<time>
43 42
  */
44 43
 
45
-function sys_schedule_get_prev_run($scheduleList, $recorded_run = SN_TIME_NOW, $return_next_run = false)
46
-{
44
+function sys_schedule_get_prev_run($scheduleList, $recorded_run = SN_TIME_NOW, $return_next_run = false) {
47 45
   static $date_part_names_reverse = array('seconds', 'minutes', 'hours', 'days', 'months', 'years',);
48 46
 
49 47
   $possible_schedules = array();
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
     array('query' => "DELETE FROM `{{planets}}` WHERE `id_owner` = 0 AND `destruyed` < UNIX_TIMESTAMP();", 'result' => false, 'error' => '', 'affected_rows' => 0),
18 18
   );
19 19
 
20
-  foreach($queries as &$query)
20
+  foreach ($queries as &$query)
21 21
   {
22 22
     $query['result'] = doquery($query['query']);
23 23
     $query['error']  = SN::$db->db_error();
24
-    $query['affected_rows']  = SN::$db->db_affected_rows();
24
+    $query['affected_rows'] = SN::$db->db_affected_rows();
25 25
   }
26 26
 
27 27
   return $queries;
@@ -53,30 +53,30 @@  discard block
 block discarded – undo
53 53
   $recorded_run = strtotime($recorded_run);
54 54
 
55 55
   $prev_run_array = getdate($recorded_run);
56
-  $prev_run_array = array($prev_run_array['seconds'],$prev_run_array['minutes'],$prev_run_array['hours'],$prev_run_array['mday'],$prev_run_array['mon'],$prev_run_array['year']);
56
+  $prev_run_array = array($prev_run_array['seconds'], $prev_run_array['minutes'], $prev_run_array['hours'], $prev_run_array['mday'], $prev_run_array['mon'], $prev_run_array['year']);
57 57
   $today_array = getdate(SN_TIME_NOW);
58
-  $today_array = array($today_array['seconds'],$today_array['minutes'],$today_array['hours'],$today_array['mday'],$today_array['mon'],$today_array['year']);
58
+  $today_array = array($today_array['seconds'], $today_array['minutes'], $today_array['hours'], $today_array['mday'], $today_array['mon'], $today_array['year']);
59 59
   $scheduleList = explode(',', $scheduleList);
60 60
   array_walk($scheduleList, function(&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) {
61 61
     $schedule = array('schedule_array' => array_reverse(explode(':', trim($schedule))));
62 62
 
63 63
     $interval = $date_part_names_reverse[count($schedule['schedule_array'])];
64 64
 
65
-    foreach($prev_run_array as $index => $date_part) {
65
+    foreach ($prev_run_array as $index => $date_part) {
66 66
       $schedule['array']['recorded'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $date_part;
67 67
       $schedule['array']['now'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $today_array[$index];
68 68
     }
69
-    if($schedule['array']['recorded'] == $schedule['array']['now']) {
69
+    if ($schedule['array']['recorded'] == $schedule['array']['now']) {
70 70
       unset($schedule['array']['now']);
71 71
     }
72 72
 
73
-    foreach($schedule['array'] as $name => $array) {
73
+    foreach ($schedule['array'] as $name => $array) {
74 74
       $schedule['string'][$name] = "{$array[5]}-{$array[4]}-{$array[3]} {$array[2]}:{$array[1]}:{$array[0]}";
75 75
       $schedule['string'][$name . '_next'] = $schedule['string'][$name] . ' +1 ' . $interval;
76 76
       $schedule['string'][$name . '_prev'] = $schedule['string'][$name] . ' -1 ' . $interval;
77 77
     }
78 78
 
79
-    foreach($schedule['string'] as $string) {
79
+    foreach ($schedule['string'] as $string) {
80 80
       $timestamp = strtotime($string);
81 81
       $schedule['timestamp'][$timestamp] = $possible_schedules[$timestamp] = date(FMT_DATE_TIME_SQL, strtotime($string));
82 82
     }
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
   $prev_run = 0;
88 88
   $next_run = 0;
89
-  foreach($possible_schedules as $timestamp => $string_date) {
89
+  foreach ($possible_schedules as $timestamp => $string_date) {
90 90
     $prev_run = SN_TIME_NOW >= $timestamp ? $timestamp : $prev_run;
91 91
     $next_run = SN_TIME_NOW < $timestamp && !$next_run ? $timestamp : $next_run;
92 92
   }
Please login to merge, or discard this patch.