Completed
Push — work-fleets ( 74a0d7...680ce4 )
by SuperNova.WS
05:04
created
includes/init/init_functions.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -2,25 +2,25 @@  discard block
 block discarded – undo
2 2
 
3 3
 // ------------------------------------------------------------------------------------------------------------------------------
4 4
 function sn_sys_load_php_files($dir_name, $load_extension = 'php', $modules = false) {
5
-  if(file_exists($dir_name)) {
5
+  if (file_exists($dir_name)) {
6 6
     $dir = opendir($dir_name);
7
-    while(($file = readdir($dir)) !== false) {
8
-      if($file == '..' || $file == '.') {
7
+    while (($file = readdir($dir)) !== false) {
8
+      if ($file == '..' || $file == '.') {
9 9
         continue;
10 10
       }
11 11
 
12 12
       $full_filename = $dir_name . $file;
13
-      if($modules && is_dir($full_filename)) {
14
-        if(file_exists($full_filename = "{$full_filename}/{$file}.{$load_extension}")) {
13
+      if ($modules && is_dir($full_filename)) {
14
+        if (file_exists($full_filename = "{$full_filename}/{$file}.{$load_extension}")) {
15 15
           require_once($full_filename);
16 16
           // Registering module
17
-          if(class_exists($file)) {
17
+          if (class_exists($file)) {
18 18
             new $file($full_filename);
19 19
           }
20 20
         }
21 21
       } else {
22 22
         $extension = substr($full_filename, -strlen($load_extension));
23
-        if($extension == $load_extension) {
23
+        if ($extension == $load_extension) {
24 24
           require_once($full_filename);
25 25
         }
26 26
       }
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
  */
40 40
 function init_update(&$config) {
41 41
   $update_file = SN_ROOT_PHYSICAL . "includes/update" . DOT_PHP_EX;
42
-  if(file_exists($update_file)) {
43
-    if(filemtime($update_file) > $config->db_loadItem('var_db_update') || $config->db_loadItem('db_version') < DB_VERSION) {
44
-      if(defined('IN_ADMIN')) {
42
+  if (file_exists($update_file)) {
43
+    if (filemtime($update_file) > $config->db_loadItem('var_db_update') || $config->db_loadItem('db_version') < DB_VERSION) {
44
+      if (defined('IN_ADMIN')) {
45 45
         sn_db_transaction_start(); // Для защиты от двойного запуска апдейта - начинаем транзакцию. Так запись в базе будет блокирована
46
-        if(SN_TIME_NOW >= $config->db_loadItem('var_db_update_end')) {
46
+        if (SN_TIME_NOW >= $config->db_loadItem('var_db_update_end')) {
47 47
           $config->db_saveItem('var_db_update_end', SN_TIME_NOW + ($config->upd_lock_time ? $config->upd_lock_time : 300));
48 48
           sn_db_transaction_commit();
49 49
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
           $current_time = time();
54 54
           $config->db_saveItem('var_db_update', $current_time);
55 55
           $config->db_saveItem('var_db_update_end', $current_time);
56
-        } elseif(filemtime($update_file) > $config->var_db_update) {
56
+        } elseif (filemtime($update_file) > $config->var_db_update) {
57 57
           $timeout = $config->var_db_update_end - SN_TIME_NOW;
58 58
           die(
59 59
             "Обновляется база данных. Рассчетное время окончания - {$timeout} секунд (время обновления может увеличиваться). Пожалуйста, подождите...<br />
Please login to merge, or discard this patch.
includes/functions/eco_planet_update.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
 
15 15
   $no_data = array('user' => false, 'planet' => false, 'que' => false);
16 16
 
17
-  if(!$planet) {
17
+  if (!$planet) {
18 18
     return $no_data;
19 19
   }
20 20
 
21
-  if(!$no_user_update) {
21
+  if (!$no_user_update) {
22 22
     $user = intval(is_array($user) && $user['id'] ? $user['id'] : $user);
23
-    if(!$user) {
23
+    if (!$user) {
24 24
       // TODO - Убрать позже
25 25
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sys_o_get_updated() - USER пустой!</h1>');
26 26
       $backtrace = debug_backtrace();
@@ -32,17 +32,17 @@  discard block
 block discarded – undo
32 32
     $user = db_user_by_id($user, !$simulation, '*', true);
33 33
   }
34 34
 
35
-  if(empty($user['id'])) {
35
+  if (empty($user['id'])) {
36 36
     return $no_data;
37 37
   }
38 38
 
39
-  if(is_array($planet) && isset($planet['galaxy']) && $planet['galaxy']) {
39
+  if (is_array($planet) && isset($planet['galaxy']) && $planet['galaxy']) {
40 40
     $planet = db_planet_by_vector($planet, '', !$simulation);
41 41
   } else {
42 42
     $planet = intval(is_array($planet) && isset($planet['id']) ? $planet['id'] : $planet);
43 43
     $planet = db_planet_by_id($planet, !$simulation);
44 44
   }
45
-  if(!is_array($planet) || !isset($planet['id'])) {
45
+  if (!is_array($planet) || !isset($planet['id'])) {
46 46
     return $no_data;
47 47
   }
48 48
 
@@ -65,15 +65,15 @@  discard block
 block discarded – undo
65 65
     RES_DEUTERIUM => 0,
66 66
   );
67 67
 
68
-  switch($planet['planet_type']) {
68
+  switch ($planet['planet_type']) {
69 69
     case PT_PLANET:
70
-      foreach($resources_increase as $resource_id => &$increment) {
70
+      foreach ($resources_increase as $resource_id => &$increment) {
71 71
         $resource_name = pname_resource_name($resource_id);
72 72
         $increment = $caps_real['total'][$resource_id] * $ProductionTime / 3600;
73 73
         $store_free = $caps_real['total_storage'][$resource_id] - $planet[$resource_name];
74 74
         $increment = min($increment, max(0, $store_free));
75 75
 
76
-        if($planet[$resource_name] + $increment < 0 && !$simulation) {
76
+        if ($planet[$resource_name] + $increment < 0 && !$simulation) {
77 77
           global $debug;
78 78
           $debug->warning("Player ID {$user['id']} have negative resources on ID {$planet['id']}.{$planet['planet_type']} [{$planet['galaxy']}:{$planet['system']}:{$planet['planet']}]. Difference {$planet[$resource_name]} of {$resource_name}", 'Negative Resources', 501);
79 79
         }
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
   // TODO пересчитывать размер планеты только при постройке чего-нибудь и при покупке сектора
96 96
   $planet['field_current'] = 0;
97 97
   $sn_group_build_allow = sn_get_groups('build_allow');
98
-  if(is_array($sn_group_build_allow[$planet['planet_type']])) {
99
-    foreach($sn_group_build_allow[$planet['planet_type']] as $building_id) {
98
+  if (is_array($sn_group_build_allow[$planet['planet_type']])) {
99
+    foreach ($sn_group_build_allow[$planet['planet_type']] as $building_id) {
100 100
       $planet['field_current'] += mrc_get_level($user, $planet, $building_id, !$simulation, true);
101 101
     }
102 102
   }
103 103
 
104
-  if($simulation) {
104
+  if ($simulation) {
105 105
     return array('user' => $user, 'planet' => $planet, 'que' => $que);
106 106
   }
107 107
 
Please login to merge, or discard this patch.
includes/functions/qst_quest.php 2 patches
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -12,34 +12,34 @@  discard block
 block discarded – undo
12 12
 
13 13
   $in_admin = defined('IN_ADMIN') && IN_ADMIN === true;
14 14
 
15
-  if($in_admin)
15
+  if ($in_admin)
16 16
   {
17 17
     $quest_id = sys_get_param_id('id');
18 18
     $quest_name = sys_get_param_str_unsafe('QUEST_NAME');
19
-    if(!empty($quest_name))
19
+    if (!empty($quest_name))
20 20
     {
21 21
       $quest_description = sys_get_param_str_unsafe('QUEST_DESCRIPTION');
22 22
       try
23 23
       {
24 24
         $quest_rewards_list = sys_get_param('QUEST_REWARDS_LIST');
25 25
         $quest_rewards = array();
26
-        foreach($quest_rewards_list as $quest_rewards_id => $quest_rewards_amount)
26
+        foreach ($quest_rewards_list as $quest_rewards_id => $quest_rewards_amount)
27 27
         {
28
-          if(!in_array($quest_rewards_id, $quest_reward_allowed))
28
+          if (!in_array($quest_rewards_id, $quest_reward_allowed))
29 29
           {
30 30
             throw new Exception($lang['qst_adm_err_reward_type']);
31 31
           }
32 32
 
33
-          if($quest_rewards_amount < 0)
33
+          if ($quest_rewards_amount < 0)
34 34
           {
35 35
             throw new Exception($lang['qst_adm_err_reward_amount']);
36 36
           }
37
-          elseif($quest_rewards_amount > 0)
37
+          elseif ($quest_rewards_amount > 0)
38 38
           {
39 39
             $quest_rewards[] = "{$quest_rewards_id},{$quest_rewards_amount}";
40 40
           }
41 41
         }
42
-        if(empty($quest_rewards))
42
+        if (empty($quest_rewards))
43 43
         {
44 44
           throw new Exception($lang['qst_adm_err_reward_empty']);
45 45
         }
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 47
         $quest_rewards = implode(';', $quest_rewards);
48 48
 
49 49
         $quest_unit_id = sys_get_param_int('QUEST_UNIT_ID');
50
-        if(!in_array($quest_unit_id, $quest_units_allowed))
50
+        if (!in_array($quest_unit_id, $quest_units_allowed))
51 51
         {
52 52
           throw new Exception($lang['qst_adm_err_unit_id']);
53 53
         }
54 54
 
55 55
         $quest_unit_amount = sys_get_param_float('QUEST_UNIT_AMOUNT');
56
-        if($quest_unit_amount <= 0)
56
+        if ($quest_unit_amount <= 0)
57 57
         {
58 58
           throw new Exception($lang['qst_adm_err_unit_amount']);
59 59
         }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         // TODO: Change quest type
63 63
         $quest_type = 0;
64 64
 
65
-        if($mode == 'edit')
65
+        if ($mode == 'edit')
66 66
         {
67 67
           $quest_name        = db_escape($quest_name);
68 68
           $quest_description = db_escape($quest_description);
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
       $mode = '';
104 104
     };
105 105
 
106
-    switch($mode)
106
+    switch ($mode)
107 107
     {
108 108
       case 'del':
109 109
         doquery("DELETE FROM {{quest}} WHERE `quest_id` = {$quest_id} LIMIT 1;");
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     $query = doquery("SELECT count(*) AS count FROM {{quest}};", '', true);
121 121
     $config->db_saveItem('quest_total', $query['count']);
122 122
   }
123
-  elseif(!$user_id)
123
+  elseif (!$user_id)
124 124
   {
125 125
     $user_id = $user['id'];
126 126
   }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     'IN_ADMIN'  => $in_admin,
135 135
   ));
136 136
 
137
-  if($quest)
137
+  if ($quest)
138 138
   {
139 139
     $quest_templatized = qst_templatize(qst_quest_parse($quest, false));
140 140
   }
@@ -143,19 +143,19 @@  discard block
 block discarded – undo
143 143
     $quest_templatized['quest_rewards_list'] = array();
144 144
   }
145 145
 
146
-  foreach($quest_reward_allowed as $unit_id)
146
+  foreach ($quest_reward_allowed as $unit_id)
147 147
   {
148 148
     $found = false;
149
-    foreach($quest_templatized['quest_rewards_list'] as $quest_templatized_reward)
149
+    foreach ($quest_templatized['quest_rewards_list'] as $quest_templatized_reward)
150 150
     {
151
-      if($quest_templatized_reward['ID'] == $unit_id)
151
+      if ($quest_templatized_reward['ID'] == $unit_id)
152 152
       {
153 153
         $found = true;
154 154
         break;
155 155
       }
156 156
     }
157 157
 
158
-    if(!$found)
158
+    if (!$found)
159 159
     {
160 160
       $quest_templatized['quest_rewards_list'][$unit_id] = array(
161 161
         'ID'     => $unit_id,
@@ -167,12 +167,12 @@  discard block
 block discarded – undo
167 167
 
168 168
   qst_assign_to_template($template, $quest_templatized);
169 169
 
170
-  foreach($quest_list as $quest_data)
170
+  foreach ($quest_list as $quest_data)
171 171
   {
172 172
     qst_assign_to_template($template, qst_templatize($quest_data, true), 'quest');
173 173
   }
174 174
 
175
-  foreach($quest_units_allowed as $unit_id)
175
+  foreach ($quest_units_allowed as $unit_id)
176 176
   {
177 177
     $template->assign_block_vars('allowed_unit', array(
178 178
       'ID'   => $unit_id,
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
 {
186 186
   $quest_list = array();
187 187
 
188
-  if($user_id)
188
+  if ($user_id)
189 189
   {
190
-    if($status !== false)
190
+    if ($status !== false)
191 191
     {
192 192
       $query_add_where = "AND qs.quest_status_status ";
193
-      if($status == null)
193
+      if ($status == null)
194 194
       {
195 195
         $query_add_where .= "IS NULL";
196 196
       }
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
     ;"
211 211
   );
212 212
 
213
-  while($quest = db_fetch($query))
213
+  while ($quest = db_fetch($query))
214 214
   {
215 215
     $quest_list[$quest['quest_id']] = qst_quest_parse($quest);
216 216
   }
@@ -220,16 +220,16 @@  discard block
 block discarded – undo
220 220
 
221 221
 function qst_assign_to_template(&$template, $quest_templatized, $block_name = false)
222 222
 {
223
-  if($block_name)
223
+  if ($block_name)
224 224
   {
225 225
     $template->assign_block_vars($block_name, $quest_templatized);
226 226
   }
227 227
   else
228 228
   {
229 229
     $template->assign_vars($quest_templatized);
230
-    if(!empty($quest_templatized['quest_rewards_list']))
230
+    if (!empty($quest_templatized['quest_rewards_list']))
231 231
     {
232
-      foreach($quest_templatized['quest_rewards_list'] as $quest_reward)
232
+      foreach ($quest_templatized['quest_rewards_list'] as $quest_reward)
233 233
       {
234 234
         $template->assign_block_vars(($block_name ? $block_name . '.' : '') . 'quest_rewards_list', $quest_reward);
235 235
       }
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
   global $lang;
252 252
 
253 253
   $tmp = array();
254
-  foreach($quest['quest_rewards_list'] as $quest_reward_id => $quest_reward_amount)
254
+  foreach ($quest['quest_rewards_list'] as $quest_reward_id => $quest_reward_amount)
255 255
   {
256 256
     $tmp[] = array(
257 257
       'ID'     => $quest_reward_id,
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
 function qst_active_triggers($quest_list)
279 279
 {
280 280
   $quest_triggers = array();
281
-  foreach($quest_list as $quest_id => $quest)
281
+  foreach ($quest_list as $quest_id => $quest)
282 282
   {
283
-    if($quest['quest_status_status'] != QUEST_STATUS_COMPLETE)
283
+    if ($quest['quest_status_status'] != QUEST_STATUS_COMPLETE)
284 284
     {
285 285
       list($quest_unit_id, $quest_unit_amount) = explode(',', $quest['quest_conditions']);
286 286
       $quest_triggers[$quest_id] = $quest_unit_id;
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 
293 293
 function qst_reward(&$user, &$rewards, &$quest_list)
294 294
 {
295
-  if(empty($rewards)) return;
295
+  if (empty($rewards)) return;
296 296
 
297 297
   global $lang;
298 298
 
@@ -300,15 +300,15 @@  discard block
 block discarded – undo
300 300
   $total_rewards = array();
301 301
   $comment_dm = '';
302 302
 
303
-  foreach($rewards as $quest_id => $user_data)
304
-    foreach($user_data as $user_id => $planet_data)
305
-      foreach($planet_data as $planet_id => $reward_list)
303
+  foreach ($rewards as $quest_id => $user_data)
304
+    foreach ($user_data as $user_id => $planet_data)
305
+      foreach ($planet_data as $planet_id => $reward_list)
306 306
       {
307 307
         $comment = sprintf($lang['qst_msg_complete_body'], $quest_list[$quest_id]['quest_name']);
308 308
         $comment_dm .= isset($reward_list[RES_DARK_MATTER]) ? $comment : '';
309 309
 
310 310
         $comment_reward = array();
311
-        foreach($reward_list as $unit_id => $unit_amount)
311
+        foreach ($reward_list as $unit_id => $unit_amount)
312 312
         {
313 313
           $comment_reward[] = $unit_amount . ' ' . $lang['tech'][$unit_id];
314 314
           $total_rewards[$user_id][$planet_id][$unit_id] += $unit_amount;
@@ -326,23 +326,23 @@  discard block
 block discarded – undo
326 326
 
327 327
   $group_resources = sn_get_groups('resources_loot');
328 328
   $quest_rewards_allowed = sn_get_groups('quest_rewards');
329
-  if(!empty($total_rewards))
329
+  if (!empty($total_rewards))
330 330
   {
331
-    foreach($total_rewards as $user_id => $planet_data)
331
+    foreach ($total_rewards as $user_id => $planet_data)
332 332
     {
333 333
       $user_row = classSupernova::db_get_record_by_id(LOC_USER, $user_id);
334
-      foreach($planet_data as $planet_id => $unit_data)
334
+      foreach ($planet_data as $planet_id => $unit_data)
335 335
       {
336 336
         $local_changeset = array();
337
-        foreach($unit_data as $unit_id => $unit_amount)
337
+        foreach ($unit_data as $unit_id => $unit_amount)
338 338
         {
339
-          if(!isset($quest_rewards_allowed[$unit_id])) continue;
339
+          if (!isset($quest_rewards_allowed[$unit_id])) continue;
340 340
 
341
-          if($unit_id == RES_DARK_MATTER)
341
+          if ($unit_id == RES_DARK_MATTER)
342 342
           {
343 343
             rpg_points_change($user['id'], RPG_QUEST, $unit_amount, $comment_dm);
344 344
           }
345
-          elseif(isset($group_resources[$unit_id]))
345
+          elseif (isset($group_resources[$unit_id]))
346 346
           {
347 347
             $local_changeset[pname_resource_name($unit_id)] = array('delta' => $unit_amount);
348 348
           }
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
           // unit
354 354
         }
355 355
 
356
-        if(!empty($local_changeset))
356
+        if (!empty($local_changeset))
357 357
         {
358 358
           $planet_id = $planet_id == 0 && isset($user_row['id_planet']) ? $user_row['id_planet'] : $planet_id;
359 359
           $db_changeset[$planet_id ? 'planets' : 'users'][] = array(
Please login to merge, or discard this patch.
Braces   +18 added lines, -22 removed lines patch added patch discarded remove patch
@@ -33,8 +33,7 @@  discard block
 block discarded – undo
33 33
           if($quest_rewards_amount < 0)
34 34
           {
35 35
             throw new Exception($lang['qst_adm_err_reward_amount']);
36
-          }
37
-          elseif($quest_rewards_amount > 0)
36
+          } elseif($quest_rewards_amount > 0)
38 37
           {
39 38
             $quest_rewards[] = "{$quest_rewards_id},{$quest_rewards_amount}";
40 39
           }
@@ -75,8 +74,7 @@  discard block
 block discarded – undo
75 74
               `quest_rewards` = '{$quest_rewards}'
76 75
             WHERE `quest_id` = {$quest_id} LIMIT 1;"
77 76
           );
78
-        }
79
-        else
77
+        } else
80 78
         {
81 79
           sn_db_perform('{{quest}}', array(
82 80
             'quest_name' => $quest_name,
@@ -94,8 +92,7 @@  discard block
 block discarded – undo
94 92
           msg_send_simple_message('*', 0, 0, MSG_TYPE_PLAYER, $lang['sys_administration'], $lang['news_title'], $text);
95 93
         }
96 94
         */
97
-      }
98
-      catch (Exception $e)
95
+      } catch (Exception $e)
99 96
       {
100 97
         message($e->getMessage(), $lang['sys_error']);
101 98
       }
@@ -119,8 +116,7 @@  discard block
 block discarded – undo
119 116
     }
120 117
     $query = doquery("SELECT count(*) AS count FROM {{quest}};", '', true);
121 118
     $config->db_saveItem('quest_total', $query['count']);
122
-  }
123
-  elseif(!$user_id)
119
+  } elseif(!$user_id)
124 120
   {
125 121
     $user_id = $user['id'];
126 122
   }
@@ -137,8 +133,7 @@  discard block
 block discarded – undo
137 133
   if($quest)
138 134
   {
139 135
     $quest_templatized = qst_templatize(qst_quest_parse($quest, false));
140
-  }
141
-  else
136
+  } else
142 137
   {
143 138
     $quest_templatized['quest_rewards_list'] = array();
144 139
   }
@@ -193,8 +188,7 @@  discard block
 block discarded – undo
193 188
       if($status == null)
194 189
       {
195 190
         $query_add_where .= "IS NULL";
196
-      }
197
-      else
191
+      } else
198 192
       {
199 193
         $query_add_where .= "= {$status}";
200 194
       }
@@ -223,8 +217,7 @@  discard block
 block discarded – undo
223 217
   if($block_name)
224 218
   {
225 219
     $template->assign_block_vars($block_name, $quest_templatized);
226
-  }
227
-  else
220
+  } else
228 221
   {
229 222
     $template->assign_vars($quest_templatized);
230 223
     if(!empty($quest_templatized['quest_rewards_list']))
@@ -292,7 +285,9 @@  discard block
 block discarded – undo
292 285
 
293 286
 function qst_reward(&$user, &$rewards, &$quest_list)
294 287
 {
295
-  if(empty($rewards)) return;
288
+  if(empty($rewards)) {
289
+    return;
290
+  }
296 291
 
297 292
   global $lang;
298 293
 
@@ -300,11 +295,12 @@  discard block
 block discarded – undo
300 295
   $total_rewards = array();
301 296
   $comment_dm = '';
302 297
 
303
-  foreach($rewards as $quest_id => $user_data)
304
-    foreach($user_data as $user_id => $planet_data)
298
+  foreach($rewards as $quest_id => $user_data) {
299
+      foreach($user_data as $user_id => $planet_data)
305 300
       foreach($planet_data as $planet_id => $reward_list)
306 301
       {
307 302
         $comment = sprintf($lang['qst_msg_complete_body'], $quest_list[$quest_id]['quest_name']);
303
+  }
308 304
         $comment_dm .= isset($reward_list[RES_DARK_MATTER]) ? $comment : '';
309 305
 
310 306
         $comment_reward = array();
@@ -336,17 +332,17 @@  discard block
 block discarded – undo
336 332
         $local_changeset = array();
337 333
         foreach($unit_data as $unit_id => $unit_amount)
338 334
         {
339
-          if(!isset($quest_rewards_allowed[$unit_id])) continue;
335
+          if(!isset($quest_rewards_allowed[$unit_id])) {
336
+            continue;
337
+          }
340 338
 
341 339
           if($unit_id == RES_DARK_MATTER)
342 340
           {
343 341
             rpg_points_change($user['id'], RPG_QUEST, $unit_amount, $comment_dm);
344
-          }
345
-          elseif(isset($group_resources[$unit_id]))
342
+          } elseif(isset($group_resources[$unit_id]))
346 343
           {
347 344
             $local_changeset[pname_resource_name($unit_id)] = array('delta' => $unit_amount);
348
-          }
349
-          else // Проверим на юниты
345
+          } else // Проверим на юниты
350 346
           {
351 347
             $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, $unit_amount, $user_row, $planet_id);
352 348
           }
Please login to merge, or discard this patch.
includes/functions/eco_get_planet_caps.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 function eco_get_planet_caps_modify_production(&$item, $key, $data) {
4 4
   static $modifiers;
5 5
 
6
-  if(!$modifiers) {
6
+  if (!$modifiers) {
7 7
     $modifiers = sn_get_groups('modifiers');
8 8
   }
9 9
   $item = floor(mrc_modify_value($data['user'], $data['planet'], $modifiers[MODIFIER_RESOURCE_PRODUCTION], $item));
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
   static $sn_group_modifiers, $config_resource_multiplier, $config_resource_multiplier_plain, $config_eco_scale_storage;
17 17
 
18
-  if(!$sn_group_modifiers) {
18
+  if (!$sn_group_modifiers) {
19 19
     $sn_group_modifiers = sn_get_groups('modifiers');
20 20
     $config_resource_multiplier = game_resource_multiplier();
21 21
     $config_resource_multiplier_plain = game_resource_multiplier(true);
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
   $caps['storage'][RES_METAL][0] = $config->eco_planet_storage_metal;
27 27
   $caps['storage'][RES_CRYSTAL][0] = $config->eco_planet_storage_crystal;
28 28
   $caps['storage'][RES_DEUTERIUM][0] = $config->eco_planet_storage_deuterium;
29
-  foreach(sn_get_groups('storages') as $unit_id) {
30
-    foreach(get_unit_param($unit_id, P_STORAGE) as $resource_id => $function) {
29
+  foreach (sn_get_groups('storages') as $unit_id) {
30
+    foreach (get_unit_param($unit_id, P_STORAGE) as $resource_id => $function) {
31 31
       $caps['storage'][$resource_id][$unit_id] = floor($config_eco_scale_storage *
32 32
         mrc_modify_value($user, $planet_row, $sn_group_modifiers[MODIFIER_RESOURCE_CAPACITY], $function(mrc_get_level($user, $planet_row, $unit_id)))
33 33
       );
34 34
     }
35 35
   }
36 36
 
37
-  if($planet_row['planet_type'] == PT_MOON) {
37
+  if ($planet_row['planet_type'] == PT_MOON) {
38 38
     return $caps;
39 39
   }
40 40
 
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
   $caps['production_full'][RES_DEUTERIUM][0] = floor($config->deuterium_basic_income * $config_resource_multiplier * (isset($planet_density[RES_DEUTERIUM]) ? $planet_density[RES_DEUTERIUM] : 1));
47 47
   $caps['production_full'][RES_ENERGY][0] = floor($config->energy_basic_income * $config_resource_multiplier_plain * (isset($planet_density[RES_ENERGY]) ? $planet_density[RES_ENERGY] : 1));
48 48
 
49
-  foreach(sn_get_groups('factories') as $unit_id) {
49
+  foreach (sn_get_groups('factories') as $unit_id) {
50 50
     $unit_data = get_unit_param($unit_id);
51 51
     $unit_level = mrc_get_level($user, $planet_row, $unit_id);
52 52
     $unit_load = $planet_row[pname_factory_production_field_name($unit_id)];
53 53
 
54
-    foreach($unit_data[P_UNIT_PRODUCTION] as $resource_id => $function) {
54
+    foreach ($unit_data[P_UNIT_PRODUCTION] as $resource_id => $function) {
55 55
       $caps['production_full'][$resource_id][$unit_id] = $function($unit_level, $unit_load, $user, $planet_row)
56 56
         * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier)
57 57
         * (isset($planet_density[$resource_id]) ? $planet_density[$resource_id] : 1);
@@ -60,21 +60,21 @@  discard block
 block discarded – undo
60 60
 
61 61
   array_walk_recursive($caps['production_full'], 'eco_get_planet_caps_modify_production', array('user' => $user, 'planet' => $planet_row));
62 62
 
63
-  foreach($caps['production_full'] as $resource_id => $resource_data) {
63
+  foreach ($caps['production_full'] as $resource_id => $resource_data) {
64 64
     $caps['total_production_full'][$resource_id] = array_sum($resource_data);
65 65
   }
66 66
 
67 67
   $caps['production'] = $caps['production_full'];
68 68
 
69
-  if($caps['production'][RES_ENERGY][STRUC_MINE_FUSION]) {
69
+  if ($caps['production'][RES_ENERGY][STRUC_MINE_FUSION]) {
70 70
     $deuterium_balance = array_sum($caps['production'][RES_DEUTERIUM]);
71 71
     $energy_balance = array_sum($caps['production'][RES_ENERGY]);
72
-    if($deuterium_balance < 0 || $energy_balance < 0) {
72
+    if ($deuterium_balance < 0 || $energy_balance < 0) {
73 73
       $caps['production'][RES_DEUTERIUM][STRUC_MINE_FUSION] = $caps['production'][RES_ENERGY][STRUC_MINE_FUSION] = 0;
74 74
     }
75 75
   }
76 76
 
77
-  foreach($caps['production'][RES_ENERGY] as $energy) {
77
+  foreach ($caps['production'][RES_ENERGY] as $energy) {
78 78
     $caps[RES_ENERGY][$energy >= 0 ? BUILD_CREATE : BUILD_DESTROY] += $energy;
79 79
   }
80 80
 
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
     ? $caps[RES_ENERGY][BUILD_CREATE] / $caps[RES_ENERGY][BUILD_DESTROY]
85 85
     : 1;
86 86
 
87
-  foreach($caps['production'] as $resource_id => &$resource_data) {
88
-    if($caps['efficiency'] != 1) {
89
-      foreach($resource_data as $unit_id => &$resource_production) {
90
-        if(!($unit_id == STRUC_MINE_FUSION && $resource_id == RES_DEUTERIUM) && $unit_id != 0 && !($resource_id == RES_ENERGY && $resource_production >= 0)) {
87
+  foreach ($caps['production'] as $resource_id => &$resource_data) {
88
+    if ($caps['efficiency'] != 1) {
89
+      foreach ($resource_data as $unit_id => &$resource_production) {
90
+        if (!($unit_id == STRUC_MINE_FUSION && $resource_id == RES_DEUTERIUM) && $unit_id != 0 && !($resource_id == RES_ENERGY && $resource_production >= 0)) {
91 91
           $resource_production = $resource_production * $caps['efficiency'];
92 92
         }
93 93
       }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     $caps['total'][$resource_id] = $caps['total'][$resource_id] >= 0 ? floor($caps['total'][$resource_id]) : ceil($caps['total'][$resource_id]);
97 97
   }
98 98
 
99
-  foreach($caps['storage'] as $resource_id => &$resource_data) {
99
+  foreach ($caps['storage'] as $resource_id => &$resource_data) {
100 100
     $caps['total_storage'][$resource_id] = array_sum($resource_data);
101 101
   }
102 102
 
Please login to merge, or discard this patch.
includes/functions/scheduler_process.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,19 +8,19 @@  discard block
 block discarded – undo
8 8
   $ts_var_stat_update = strtotime($config->db_loadItem('var_stat_update'));
9 9
   $ts_scheduled_update = sys_schedule_get_prev_run($config->db_loadItem('stats_schedule'), $config->var_stat_update);
10 10
 
11
-  if(sys_get_param_int('admin_update')) {
11
+  if (sys_get_param_int('admin_update')) {
12 12
     define('USER_LEVEL', isset($user['authlevel']) ? $user['authlevel'] : -1);
13
-    if(USER_LEVEL > 0) {
13
+    if (USER_LEVEL > 0) {
14 14
       $is_admin_request = true;
15 15
       $ts_scheduled_update = SN_TIME_NOW;
16 16
     }
17 17
   }
18 18
 
19
-  if($ts_scheduled_update > $ts_var_stat_update) {
19
+  if ($ts_scheduled_update > $ts_var_stat_update) {
20 20
     lng_include('admin');
21 21
     sn_db_transaction_start();
22 22
     $ts_var_stat_update_end = strtotime($config->db_loadItem('var_stat_update_end'));
23
-    if(SN_TIME_NOW > $ts_var_stat_update_end) {
23
+    if (SN_TIME_NOW > $ts_var_stat_update_end) {
24 24
       $old_server_status = $config->db_loadItem('game_disable');
25 25
       $config->db_saveItem('game_disable', GAME_DISABLE_STAT);
26 26
 
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
       $config->db_saveItem('var_stat_update_end', SN_TIME_SQL);
57 57
 
58 58
       $config->db_saveItem('game_disable', $old_server_status);
59
-    } elseif($ts_scheduled_update > $ts_var_stat_update) {
59
+    } elseif ($ts_scheduled_update > $ts_var_stat_update) {
60 60
       $timeout = strtotime($config->db_loadItem('var_stat_update_end')) - SN_TIME_NOW;
61 61
       $msg = $config->db_loadItem('var_stat_update_msg');
62 62
       $msg = "{$msg} ETA {$timeout} seconds. Please wait...";
63 63
     }
64 64
     sn_db_transaction_rollback();
65
-  } elseif($is_admin_request) {
65
+  } elseif ($is_admin_request) {
66 66
     $msg = 'Stat is up to date';
67 67
   }
68 68
 
Please login to merge, or discard this patch.
includes/functions/sys_bbcode.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -107,23 +107,23 @@
 block discarded – undo
107 107
 
108 108
   !empty($config->url_faq) ? $msg = str_replace('faq://', $config->url_faq, $msg) : false;
109 109
 
110
-  foreach($supernova->design['bbcodes'] as $auth_level => $replaces) {
111
-    if($auth_level > $author_auth) {
110
+  foreach ($supernova->design['bbcodes'] as $auth_level => $replaces) {
111
+    if ($auth_level > $author_auth) {
112 112
       continue;
113 113
     }
114 114
 
115
-    foreach($replaces as $key => $html) {
116
-      $msg = preg_replace(''.$key.'', $html, $msg);
115
+    foreach ($replaces as $key => $html) {
116
+      $msg = preg_replace('' . $key . '', $html, $msg);
117 117
     }
118 118
   }
119 119
 
120
-  foreach($supernova->design['smiles'] as $auth_level => $replaces) {
121
-    if($auth_level > $author_auth) {
120
+  foreach ($supernova->design['smiles'] as $auth_level => $replaces) {
121
+    if ($auth_level > $author_auth) {
122 122
       continue;
123 123
     }
124 124
 
125
-    foreach($replaces as $key => $imgName) {
126
-      $msg = preg_replace("#" . addcslashes($key, '()[]{}') . "#isU","<img src=\"design/images/smileys/".$imgName.".gif\" align=\"absmiddle\" title=\"".$key."\" alt=\"".$key."\">",$msg);
125
+    foreach ($replaces as $key => $imgName) {
126
+      $msg = preg_replace("#" . addcslashes($key, '()[]{}') . "#isU", "<img src=\"design/images/smileys/" . $imgName . ".gif\" align=\"absmiddle\" title=\"" . $key . "\" alt=\"" . $key . "\">", $msg);
127 127
     }
128 128
   }
129 129
 
Please login to merge, or discard this patch.
captcha.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -2,16 +2,16 @@
 block discarded – undo
2 2
 // Captcha code for registration - really didn't work alot :(
3 3
 
4 4
 session_start();
5
-$en=100;
6
-$boy=25;
7
-$sayi = mt_rand(0,9999999);
5
+$en = 100;
6
+$boy = 25;
7
+$sayi = mt_rand(0, 9999999);
8 8
 $_SESSION['captcha'] = $sayi;
9
-$tuval = imagecreatetruecolor($en,$boy);
10
-$b = imagecolorallocate($tuval,175,238,238);
11
-$s = imagecolorallocate($tuval,0,0,0);
12
-imagefill($tuval,0,0,$s);
13
-imageline($tuval,20,50,$en,$boy,$b);
14
-imagestring($tuval,3,27,7,$sayi,$b);
9
+$tuval = imagecreatetruecolor($en, $boy);
10
+$b = imagecolorallocate($tuval, 175, 238, 238);
11
+$s = imagecolorallocate($tuval, 0, 0, 0);
12
+imagefill($tuval, 0, 0, $s);
13
+imageline($tuval, 20, 50, $en, $boy, $b);
14
+imagestring($tuval, 3, 27, 7, $sayi, $b);
15 15
 Header("content-type:image/gif");
16 16
 imagegif($tuval);
17 17
 imagedestroy($tuval);
Please login to merge, or discard this patch.
quest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-define('INSIDE'  , true);
11
-define('INSTALL' , false);
10
+define('INSIDE', true);
11
+define('INSTALL', false);
12 12
 
13 13
 require('common.' . substr(strrchr(__FILE__, '.'), 1));
14 14
 
Please login to merge, or discard this patch.
ajax_version_check.php 3 patches
Switch Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -22,19 +22,19 @@
 block discarded – undo
22 22
 */
23 23
 switch($mode)
24 24
 {
25
-  case SNC_MODE_REGISTER:
26
-    if($config->server_updater_key || $config->server_updater_id)
27
-    {
28
-      if($ajax)
25
+    case SNC_MODE_REGISTER:
26
+      if($config->server_updater_key || $config->server_updater_id)
29 27
       {
30
-        print(SNC_VER_REGISTER_ERROR_REGISTERED);
28
+        if($ajax)
29
+        {
30
+          print(SNC_VER_REGISTER_ERROR_REGISTERED);
31
+        }
32
+        die();
31 33
       }
32
-      die();
33
-    }
34
-    $url .= "&name=" . urlencode($config->game_name) . "&url=" . urlencode(SN_ROOT_VIRTUAL);
35
-//TODO REMOVE DEBUG!!!
36
-//$url .= "&name=" . urlencode($config->game_name) . "&url=" . urlencode('http://supernova.ws/');
37
-  break;
34
+      $url .= "&name=" . urlencode($config->game_name) . "&url=" . urlencode(SN_ROOT_VIRTUAL);
35
+  //TODO REMOVE DEBUG!!!
36
+  //$url .= "&name=" . urlencode($config->game_name) . "&url=" . urlencode('http://supernova.ws/');
37
+    break;
38 38
 }
39 39
 
40 40
 $check_result = sn_get_url_contents($url);
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
 . '&key=' . urlencode($config->server_updater_key)
21 21
 . '&id=' . urlencode($config->server_updater_id);
22 22
 */
23
-switch($mode)
23
+switch ($mode)
24 24
 {
25 25
   case SNC_MODE_REGISTER:
26
-    if($config->server_updater_key || $config->server_updater_id)
26
+    if ($config->server_updater_key || $config->server_updater_id)
27 27
     {
28
-      if($ajax)
28
+      if ($ajax)
29 29
       {
30 30
         print(SNC_VER_REGISTER_ERROR_REGISTERED);
31 31
       }
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
 }
39 39
 
40 40
 $check_result = sn_get_url_contents($url);
41
-if(!$check_result)
41
+if (!$check_result)
42 42
 {
43 43
   $version_check = SNC_VER_ERROR_CONNECT;
44 44
 }
45
-elseif(($version_check = intval($check_result)) && $version_check == $check_result)
45
+elseif (($version_check = intval($check_result)) && $version_check == $check_result)
46 46
 {
47 47
   $version_check = $check_result;
48 48
 }
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
   $check_result = json_decode($check_result, true);
53 53
   $version_check = $check_result === null ? SNC_VER_UNKNOWN_RESPONSE : $check_result['version_check'];
54 54
 
55
-  switch($mode)
55
+  switch ($mode)
56 56
   {
57 57
     case SNC_MODE_REGISTER:
58
-      if($check_result['site']['site_key'] && $check_result['site']['site_id'] && $check_result['site']['result'] == SNC_VER_REGISTER_REGISTERED)
58
+      if ($check_result['site']['site_key'] && $check_result['site']['site_id'] && $check_result['site']['result'] == SNC_VER_REGISTER_REGISTERED)
59 59
       {
60 60
         $config->db_saveItem('server_updater_key', $check_result['site']['site_key']);
61 61
         $config->db_saveItem('server_updater_id', $check_result['site']['site_id']);
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 $config->db_saveItem('server_updater_check_last', SN_TIME_NOW);
70 70
 $config->db_saveItem('server_updater_check_result', $version_check);
71 71
 
72
-if($ajax)
72
+if ($ajax)
73 73
 {
74 74
   define('IN_AJAX', true);
75 75
   print($version_check);
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,12 +41,10 @@
 block discarded – undo
41 41
 if(!$check_result)
42 42
 {
43 43
   $version_check = SNC_VER_ERROR_CONNECT;
44
-}
45
-elseif(($version_check = intval($check_result)) && $version_check == $check_result)
44
+} elseif(($version_check = intval($check_result)) && $version_check == $check_result)
46 45
 {
47 46
   $version_check = $check_result;
48
-}
49
-else
47
+} else
50 48
 {
51 49
   // JSON decode if string
52 50
   $check_result = json_decode($check_result, true);
Please login to merge, or discard this patch.