Passed
Branch work-fleets (5a7baa)
by SuperNova.WS
06:08
created
admin/tools.php 2 patches
Switch Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -34,69 +34,69 @@
 block discarded – undo
34 34
 }
35 35
 
36 36
 switch($mode) {
37
-  case ADM_TOOL_CONFIG_RELOAD:
38
-    classSupernova::$config->db_loadAll();
39
-    sys_refresh_tablelist();
40
-
41
-    classSupernova::$config->db_loadItem('game_watchlist');
42
-    if(classSupernova::$config->game_watchlist) {
43
-      classSupernova::$config->game_watchlist_array = explode(';', classSupernova::$config->game_watchlist);
44
-    } else {
45
-      unset(classSupernova::$config->game_watchlist_array);
46
-    }
47
-  break;
48
-
49
-  case ADM_TOOL_MD5:
50
-    $template = gettemplate("admin/md5enc", true);
51
-    $password_seed = sys_get_param_str_unsafe('seed', SN_SYS_SEC_CHARS_ALLOWED);
52
-    $password_length = sys_get_param_int('length', 16);
53
-    $string = ($string = sys_get_param_str_unsafe('string')) ? $string : sys_random_string($password_length, $password_seed);
54
-
55
-    $template->assign_vars(array(
56
-      'SEED'   => $password_seed,
57
-      'LENGTH' => $password_length,
58
-      'STRING' => htmlentities($string),
59
-      'MD5'    => md5($string),
60
-    ));
61
-    display($template, classLocale::$lang['adm_tools_md5_header'], false, '', true);
62
-  break;
63
-
64
-  case ADM_TOOL_FORCE_ALL:
65
-    classSupernova::$config->db_saveItem('db_version', 0);
66
-    require_once('../includes/update.php');
67
-  break;
68
-
69
-  case ADM_TOOL_FORCE_LAST:
70
-    classSupernova::$config->db_saveItem('db_version', floor(classSupernova::$config->db_version - 1));
71
-    require_once('../includes/update.php');
72
-  break;
73
-
74
-  case ADM_TOOL_INFO_PHP:
75
-    phpinfo();
76
-  break;
77
-
78
-  case ADM_TOOL_INFO_SQL:
79
-    $template = gettemplate("simple_table", true);
80
-
81
-    $status = array(
82
-      classLocale::$lang['adm_tool_sql_server_version'] => classSupernova::$db->db_get_server_info(),
83
-      classLocale::$lang['adm_tool_sql_client_version'] => classSupernova::$db->db_get_client_info(),
84
-      classLocale::$lang['adm_tool_sql_host_info']      => classSupernova::$db->db_get_host_info(),
85
-    );
86
-    templateAssignTable($template, 'server', $status);
87
-
88
-    templateAssignTable($template, 'status', classSupernova::$db->db_get_server_stat());
89
-    templateAssignTable($template, 'params', classSupernova::$db->db_core_show_status());
90
-
91
-    $template->assign_vars(array(
92
-      'PAGE_HEADER'   => classLocale::$lang['adm_tool_sql_page_header'],
93
-      'COLUMN_NAME_1' => classLocale::$lang['adm_tool_sql_param_name'],
94
-      'COLUMN_NAME_2' => classLocale::$lang['adm_tool_sql_param_value'],
95
-      'TABLE_FOOTER'  => 'test',
96
-    ));
97
-
98
-    display($template, classLocale::$lang['adm_bn_ttle'], false, '', true);
99
-  break;
37
+    case ADM_TOOL_CONFIG_RELOAD:
38
+      classSupernova::$config->db_loadAll();
39
+      sys_refresh_tablelist();
40
+
41
+      classSupernova::$config->db_loadItem('game_watchlist');
42
+      if(classSupernova::$config->game_watchlist) {
43
+        classSupernova::$config->game_watchlist_array = explode(';', classSupernova::$config->game_watchlist);
44
+      } else {
45
+        unset(classSupernova::$config->game_watchlist_array);
46
+      }
47
+    break;
48
+
49
+    case ADM_TOOL_MD5:
50
+      $template = gettemplate("admin/md5enc", true);
51
+      $password_seed = sys_get_param_str_unsafe('seed', SN_SYS_SEC_CHARS_ALLOWED);
52
+      $password_length = sys_get_param_int('length', 16);
53
+      $string = ($string = sys_get_param_str_unsafe('string')) ? $string : sys_random_string($password_length, $password_seed);
54
+
55
+      $template->assign_vars(array(
56
+        'SEED'   => $password_seed,
57
+        'LENGTH' => $password_length,
58
+        'STRING' => htmlentities($string),
59
+        'MD5'    => md5($string),
60
+      ));
61
+      display($template, classLocale::$lang['adm_tools_md5_header'], false, '', true);
62
+    break;
63
+
64
+    case ADM_TOOL_FORCE_ALL:
65
+      classSupernova::$config->db_saveItem('db_version', 0);
66
+      require_once('../includes/update.php');
67
+    break;
68
+
69
+    case ADM_TOOL_FORCE_LAST:
70
+      classSupernova::$config->db_saveItem('db_version', floor(classSupernova::$config->db_version - 1));
71
+      require_once('../includes/update.php');
72
+    break;
73
+
74
+    case ADM_TOOL_INFO_PHP:
75
+      phpinfo();
76
+    break;
77
+
78
+    case ADM_TOOL_INFO_SQL:
79
+      $template = gettemplate("simple_table", true);
80
+
81
+      $status = array(
82
+        classLocale::$lang['adm_tool_sql_server_version'] => classSupernova::$db->db_get_server_info(),
83
+        classLocale::$lang['adm_tool_sql_client_version'] => classSupernova::$db->db_get_client_info(),
84
+        classLocale::$lang['adm_tool_sql_host_info']      => classSupernova::$db->db_get_host_info(),
85
+      );
86
+      templateAssignTable($template, 'server', $status);
87
+
88
+      templateAssignTable($template, 'status', classSupernova::$db->db_get_server_stat());
89
+      templateAssignTable($template, 'params', classSupernova::$db->db_core_show_status());
90
+
91
+      $template->assign_vars(array(
92
+        'PAGE_HEADER'   => classLocale::$lang['adm_tool_sql_page_header'],
93
+        'COLUMN_NAME_1' => classLocale::$lang['adm_tool_sql_param_name'],
94
+        'COLUMN_NAME_2' => classLocale::$lang['adm_tool_sql_param_value'],
95
+        'TABLE_FOOTER'  => 'test',
96
+      ));
97
+
98
+      display($template, classLocale::$lang['adm_bn_ttle'], false, '', true);
99
+    break;
100 100
 
101 101
 }
102 102
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
 define('INSIDE', true);
10 10
 define('INSTALL', false);
11 11
 define('IN_ADMIN', true);
12
-require('../common.' . substr(strrchr(__FILE__, '.'), 1));
12
+require('../common.'.substr(strrchr(__FILE__, '.'), 1));
13 13
 
14 14
 // if($user['authlevel'] < 1)
15
-if($user['authlevel'] < 3) {
15
+if ($user['authlevel'] < 3) {
16 16
   AdminMessage(classLocale::$lang['adm_err_denied']);
17 17
 }
18 18
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function templateAssignTable($template, $str, $status) {
27 27
   $template->assign_block_vars('table', classLocale::$lang['adm_tool_sql_table'][$str]);
28
-  foreach($status as $key => $value) {
28
+  foreach ($status as $key => $value) {
29 29
     $template->assign_block_vars('table.row', array(
30 30
       'VALUE_1' => $key,
31 31
       'VALUE_2' => $value,
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
   }
34 34
 }
35 35
 
36
-switch($mode) {
36
+switch ($mode) {
37 37
   case ADM_TOOL_CONFIG_RELOAD:
38 38
     classSupernova::$config->db_loadAll();
39 39
     sys_refresh_tablelist();
40 40
 
41 41
     classSupernova::$config->db_loadItem('game_watchlist');
42
-    if(classSupernova::$config->game_watchlist) {
42
+    if (classSupernova::$config->game_watchlist) {
43 43
       classSupernova::$config->game_watchlist_array = explode(';', classSupernova::$config->game_watchlist);
44 44
     } else {
45 45
       unset(classSupernova::$config->game_watchlist_array);
Please login to merge, or discard this patch.
includes/classes/Player.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
    * @return int|mixed
229 229
    */
230 230
   public function calcColonyMaxCount($astrotech = -1) {
231
-    if($astrotech == -1) {
232
-      if(!isset($this->_dbRow[UNIT_PLAYER_COLONIES_MAX])) {
231
+    if ($astrotech == -1) {
232
+      if (!isset($this->_dbRow[UNIT_PLAYER_COLONIES_MAX])) {
233 233
 
234 234
         $expeditions = get_player_max_expeditons($this->_dbRow);
235 235
         $astrotech = mrc_get_level($this->_dbRow, null, TECH_ASTROTECH);
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 
303 303
 
304 304
   public function expeditionsMax() {
305
-    if($this->expeditionsMax === null) {
305
+    if ($this->expeditionsMax === null) {
306 306
       $this->expeditionsMax = get_player_max_expeditons($this->_dbRow);
307 307
     }
308 308
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
   }
311 311
 
312 312
   public function expeditionsFlying() {
313
-    if($this->expeditionsFlying === null) {
313
+    if ($this->expeditionsFlying === null) {
314 314
       $this->expeditionsFlying = FleetList::fleet_count_flying($this->_dbId, MT_EXPLORE);
315 315
     }
316 316
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 
320 320
 
321 321
   public function fleetsMax() {
322
-    if($this->fleetMax === null) {
322
+    if ($this->fleetMax === null) {
323 323
       $this->fleetMax = GetMaxFleets($this->_dbRow);
324 324
     }
325 325
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
   }
328 328
 
329 329
   public function fleetsFlying() {
330
-    if($this->fleetFlying === null) {
330
+    if ($this->fleetFlying === null) {
331 331
       $this->fleetFlying = FleetList::fleet_count_flying($this->_dbId);
332 332
     }
333 333
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 
337 337
 
338 338
   public function coloniesMax() {
339
-    if($this->coloniesMax === null) {
339
+    if ($this->coloniesMax === null) {
340 340
       $this->coloniesMax = get_player_max_colonies($this->_dbRow);
341 341
     }
342 342
 
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
   }
345 345
 
346 346
   public function coloniesCurrent() {
347
-    if($this->coloniesCurrent === null) {
347
+    if ($this->coloniesCurrent === null) {
348 348
       $this->coloniesCurrent = get_player_current_colonies($this->_dbRow);
349 349
     }
350 350
 
Please login to merge, or discard this patch.
includes/includes/flt_page5.inc 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 *
13 13
 **/
14 14
 
15
-if(SN_IN_FLEET !== true) {
15
+if (SN_IN_FLEET !== true) {
16 16
   $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
17 17
 }
18 18
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
   $planet_list = array();
27 27
 
28
-  if(is_array($resources_taken))
28
+  if (is_array($resources_taken))
29 29
   {
30 30
     $query = implode(',', array_keys($resources_taken));
31 31
     $query = " AND `destruyed` = 0 AND `id` IN ({$query})";
@@ -33,16 +33,16 @@  discard block
 block discarded – undo
33 33
     $query = '';
34 34
   }
35 35
 
36
-  foreach(sn_get_groups('flt_transports') as $transport_id) {
36
+  foreach (sn_get_groups('flt_transports') as $transport_id) {
37 37
     $transports[$transport_id] = get_unit_param($transport_id, P_CAPACITY);
38 38
   }
39 39
   arsort($transports);
40 40
 
41 41
   $planets_db_list = db_planet_list_sorted($user, $planetrow['id'], '*', $query);
42 42
   !is_array($planets_db_list) ? $planets_db_list = array() : false;
43
-  foreach($planets_db_list as $planet_db_data) {
43
+  foreach ($planets_db_list as $planet_db_data) {
44 44
   // begin planet loop
45
-    if(!$query) {
45
+    if (!$query) {
46 46
       $resources_taken[$planet_db_data['id']] = 1;
47 47
     }
48 48
     sn_db_transaction_start();
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
     $planet_id = $planet_db_data['id'];
55 55
 
56 56
     $planet_resources = 0;
57
-    foreach(sn_get_groups('resources_loot') as $resource_id) {
58
-      if($resources_taken[$planet_id] == 1 || $resources_taken[$planet_id][$resource_id]) {
57
+    foreach (sn_get_groups('resources_loot') as $resource_id) {
58
+      if ($resources_taken[$planet_id] == 1 || $resources_taken[$planet_id][$resource_id]) {
59 59
         $planet_resources += floor(mrc_get_level($user, $planet_db_data, $resource_id, true, true)); // $planet_db_data[get_unit_param($resource_id, P_NAME)]);
60 60
       }
61 61
     }
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
     $fleet_capacity = 0;
87 87
     $ship_loadout = array();
88 88
     $fleet = array();
89
-    foreach($transports as $ship_id => $ship_capacity) {
90
-      if($ship_count = mrc_get_level($user, $planet_db_data, $ship_id, true, true)) {
89
+    foreach ($transports as $ship_id => $ship_capacity) {
90
+      if ($ship_count = mrc_get_level($user, $planet_db_data, $ship_id, true, true)) {
91 91
         $ship_loadout[$ship_id]['capacity'] = $ship_count * $ship_capacity;
92 92
         $ship_loadout[$ship_id]['taken'] = 0;
93 93
         $fleet_capacity += $ship_loadout[$ship_id]['capacity'];
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 
99 99
     $will_take = min($planet_resources, $fleet_capacity);
100 100
 
101
-    foreach($ship_loadout as $ship_id => &$planet_ship) {
101
+    foreach ($ship_loadout as $ship_id => &$planet_ship) {
102 102
       $can_take = min($will_take, $planet_ship['capacity']);
103
-      if($can_take <= 0) {
103
+      if ($can_take <= 0) {
104 104
         continue;
105 105
       }
106 106
       $planet_ship['capacity'] -= $can_take;
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
       $fleet[$ship_id] = ceil($planet_ship['taken'] / $transports[$ship_id]);
109 109
 
110 110
       $will_take -= $can_take;
111
-      if($will_take <= 0) {
111
+      if ($will_take <= 0) {
112 112
         break;
113 113
       }
114 114
     }
115 115
 
116
-    if(!empty($fleet)) {
116
+    if (!empty($fleet)) {
117 117
       $travel_data = flt_travel_data($user, $planetrow, $planet_db_data, $fleet, 10);
118 118
       $planet_data['FLEET_SPEED'] = $travel_data['fleet_speed'];
119 119
       $planet_data['DISTANCE']    = $travel_data['distance'];
120 120
       $planet_data['DURATION']    = $travel_data['duration'];
121 121
       $planet_data['CONSUMPTION'] = $travel_data['consumption'];
122 122
 
123
-      if(floor(mrc_get_level($user, $planet_db_data, RES_DEUTERIUM, true)) >= $planet_data['CONSUMPTION']) {
123
+      if (floor(mrc_get_level($user, $planet_db_data, RES_DEUTERIUM, true)) >= $planet_data['CONSUMPTION']) {
124 124
         $will_take = min($planet_resources, $fleet_capacity) - $planet_data['CONSUMPTION'];
125 125
 
126
-        foreach(sn_get_groups('resources_loot') as $resource_id) {
127
-          if($resources_taken[$planet_id] != 1 && !$resources_taken[$planet_id][$resource_id]) {
126
+        foreach (sn_get_groups('resources_loot') as $resource_id) {
127
+          if ($resources_taken[$planet_id] != 1 && !$resources_taken[$planet_id][$resource_id]) {
128 128
             continue;
129 129
           }
130 130
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
           $fleet[$resource_id] = min($will_take, $resource_amount);
134 134
           $will_take -= $resource_amount;
135 135
 
136
-          if($will_take <= 0) {
136
+          if ($will_take <= 0) {
137 137
             break;
138 138
           }
139 139
         }
@@ -157,19 +157,19 @@  discard block
 block discarded – undo
157 157
 
158 158
 $resources_taken = sys_get_param('resources');
159 159
 
160
-if(!empty($resources_taken))  { // begin processing parameters
160
+if (!empty($resources_taken)) { // begin processing parameters
161 161
   $planet_list = flt_build_gathering($resources_taken);
162 162
 
163
-  foreach($planet_list as $planet_id => $planet_data) {
164
-    if($planet_data['RESULT'] == FLIGHT_ALLOWED) {
163
+  foreach ($planet_list as $planet_id => $planet_data) {
164
+    if ($planet_data['RESULT'] == FLIGHT_ALLOWED) {
165 165
       $planet_data['RESULT'] = flt_t_send_fleet($user, $planet_data['PLANET_DB_DATA'], $planetrow, $planet_data['FLEET'], MT_TRANSPORT);
166 166
     }
167 167
 
168 168
     $planet_data['MESSAGE'] = classLocale::$lang['fl_attack_error'][$planet_data['RESULT']];
169 169
 
170 170
     $template->assign_block_vars('results', $planet_data);
171
-    if(!empty($planet_data['FLEET']) && $planet_data['RESULT'] == FLIGHT_ALLOWED) {
172
-      foreach($planet_data['FLEET'] as $unit_id => $amount) {
171
+    if (!empty($planet_data['FLEET']) && $planet_data['RESULT'] == FLIGHT_ALLOWED) {
172
+      foreach ($planet_data['FLEET'] as $unit_id => $amount) {
173 173
         $template->assign_block_vars('results.units', array(
174 174
           'ID'     => $unit_id,
175 175
           'NAME'   => classLocale::$lang['tech'][$unit_id],
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
 // Building list of own planets & moons
184 184
 $planet_list = flt_build_gathering();
185
-foreach($planet_list as $planet_data) {
185
+foreach ($planet_list as $planet_data) {
186 186
   $planet_data['DURATION'] = $planet_data['DURATION'] ? pretty_time($planet_data['DURATION']) : classLocale::$lang['flt_no_fuel'];
187 187
   $template->assign_block_vars('colonies', $planet_data);
188 188
 }
Please login to merge, or discard this patch.
includes/classes/Fleet.php 2 patches
Doc Comments   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
   /**
973 973
    * Set current resource list from array of units
974 974
    *
975
-   * @param array $resource_list
975
+   * @param integer[] $resource_list
976 976
    */
977 977
   public function resourcesSet($resource_list) {
978 978
     if (!empty($this->propertiesAdjusted['resource_list'])) {
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
   }
1021 1021
 
1022 1022
   /**
1023
-   * @param array $rate
1023
+   * @param integer[] $rate
1024 1024
    *
1025 1025
    * @return float
1026 1026
    */
@@ -1051,7 +1051,6 @@  discard block
 block discarded – undo
1051 1051
    * Restores fleet or resources to planet
1052 1052
    *
1053 1053
    * @param bool $start
1054
-   * @param bool $only_resources
1055 1054
    * @param int  $result
1056 1055
    *
1057 1056
    * @return int
@@ -1205,6 +1204,9 @@  discard block
 block discarded – undo
1205 1204
   }
1206 1205
 
1207 1206
 
1207
+  /**
1208
+   * @param integer $missionStartTimeStamp
1209
+   */
1208 1210
   protected function renderFleetCoordinates($missionStartTimeStamp = SN_TIME_NOW, $timeMissionJob = 0) {
1209 1211
     $timeToReturn = $this->travelData['duration'] * 2 + $timeMissionJob;
1210 1212
 
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
     parent::__construct();
325 325
     $this->exists_missions = sn_get_groups('missions');
326 326
     $this->allowed_missions = $this->exists_missions;
327
-    if(empty(static::$snGroupFleet)) {
327
+    if (empty(static::$snGroupFleet)) {
328 328
       static::$snGroupFleet = sn_get_groups('fleet');
329 329
       static::$snGroupFleetAndMissiles = sn_get_groups(array('fleet', 'missile'));
330 330
       static::$snGroupRecyclers = sn_get_groups('flt_recyclers');
@@ -407,31 +407,31 @@  discard block
 block discarded – undo
407 407
 
408 408
     return doquery(
409 409
     // Блокировка самого флота
410
-      "SELECT 1 FROM {{fleets}} AS f " .
410
+      "SELECT 1 FROM {{fleets}} AS f ".
411 411
 
412 412
       // Блокировка всех юнитов, принадлежащих этому флоту
413
-      "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = " . static::$locationType . " AND unit.unit_location_id = f.fleet_id " .
413
+      "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = ".static::$locationType." AND unit.unit_location_id = f.fleet_id ".
414 414
 
415 415
       // Блокировка всех прилетающих и улетающих флотов, если нужно
416 416
       // TODO - lock fleets by COORDINATES
417
-      ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : '') .
417
+      ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : '').
418 418
       // Блокировка всех юнитов, принадлежащих прилетающим и улетающим флотам - ufd = unit_fleet_destination
419
-      ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = " . static::$locationType . " AND ufd.unit_location_id = fd.fleet_id " : '') .
419
+      ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = ".static::$locationType." AND ufd.unit_location_id = fd.fleet_id " : '').
420 420
 
421
-      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '') .
421
+      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '').
422 422
       // Блокировка всех юнитов, принадлежащих владельцу планеты-цели
423
-      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '') .
423
+      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '').
424 424
       // Блокировка планеты-цели
425
-      ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '') .
425
+      ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '').
426 426
       // Блокировка всех юнитов, принадлежащих планете-цели - НЕ НУЖНО. Уже залочили ранее, как принадлежащие игроку-цели
427 427
 //      ($mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS upd ON upd.unit_location_type = " . LOC_PLANET . " AND upd.unit_location_id = pd.id " : '') .
428 428
 
429 429
 
430
-      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '') .
430
+      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '').
431 431
       // Блокировка всех юнитов, принадлежащих владельцу флота
432
-      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '') .
432
+      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '').
433 433
       // Блокировка планеты отправления
434
-      ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '') .
434
+      ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '').
435 435
       // Блокировка всех юнитов, принадлежащих планете с которой юниты были отправлены - НЕ НУЖНО. Уже залочили ранее, как принадлежащие владельцу флота
436 436
 //      ($mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS ups ON ups.unit_location_type = " . LOC_PLANET . " AND ups.unit_location_id = ps.id " : '') .
437 437
 
@@ -448,11 +448,11 @@  discard block
 block discarded – undo
448 448
   public function dbGetLockById($dbId) {
449 449
     doquery(
450 450
     // Блокировка самого флота
451
-      "SELECT 1 FROM {{fleets}} AS FLEET0 " .
451
+      "SELECT 1 FROM {{fleets}} AS FLEET0 ".
452 452
       // Lock fleet owner
453
-      "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner " .
453
+      "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner ".
454 454
       // Блокировка всех юнитов, принадлежащих этому флоту
455
-      "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = " . LOC_FLEET . " AND UNIT0.unit_location_id = FLEET0.fleet_id " .
455
+      "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = ".LOC_FLEET." AND UNIT0.unit_location_id = FLEET0.fleet_id ".
456 456
 
457 457
       // Без предварительной выборки неизвестно - куда летит этот флот.
458 458
       // Поэтому надо выбирать флоты, чьи координаты прибытия ИЛИ отбытия совпадают с координатами прибытия ИЛИ отбытия текущего флота.
@@ -468,9 +468,9 @@  discard block
 block discarded – undo
468 468
         FLEET1.fleet_end_planet = FLEET0.fleet_end_planet
469 469
       " .
470 470
       // Блокировка всех юнитов, принадлежащих этим флотам
471
-      "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = " . LOC_FLEET . " AND UNIT1.unit_location_id = FLEET1.fleet_id " .
471
+      "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = ".LOC_FLEET." AND UNIT1.unit_location_id = FLEET1.fleet_id ".
472 472
       // Lock fleet owner
473
-      "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner " .
473
+      "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner ".
474 474
 
475 475
       "LEFT JOIN {{fleets}} AS FLEET2 ON
476 476
         FLEET2.fleet_mess = 1   AND FLEET0.fleet_mess = 0 AND
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
       " .
481 481
       // Блокировка всех юнитов, принадлежащих этим флотам
482 482
       "LEFT JOIN {{unit}} as UNIT2 ON
483
-        UNIT2.unit_location_type = " . LOC_FLEET . " AND
483
+        UNIT2.unit_location_type = " . LOC_FLEET." AND
484 484
         UNIT2.unit_location_id = FLEET2.fleet_id
485 485
       " .
486 486
       // Lock fleet owner
@@ -497,11 +497,11 @@  discard block
 block discarded – undo
497 497
       " .
498 498
       // Блокировка всех юнитов, принадлежащих этим флотам
499 499
       "LEFT JOIN {{unit}} as UNIT3 ON
500
-        UNIT3.unit_location_type = " . LOC_FLEET . " AND
500
+        UNIT3.unit_location_type = " . LOC_FLEET." AND
501 501
         UNIT3.unit_location_id = FLEET3.fleet_id
502 502
       " .
503 503
       // Lock fleet owner
504
-      "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner " .
504
+      "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner ".
505 505
 
506 506
       "LEFT JOIN {{fleets}} AS FLEET4 ON
507 507
         FLEET4.fleet_mess = 1   AND FLEET0.fleet_mess = 1 AND
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
       " .
512 512
       // Блокировка всех юнитов, принадлежащих этим флотам
513 513
       "LEFT JOIN {{unit}} as UNIT4 ON
514
-        UNIT4.unit_location_type = " . LOC_FLEET . " AND
514
+        UNIT4.unit_location_type = " . LOC_FLEET." AND
515 515
         UNIT4.unit_location_id = FLEET4.fleet_id
516 516
       " .
517 517
       // Lock fleet owner
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
       " .
534 534
       // Блокировка всех юнитов, принадлежащих этой планете
535 535
       "LEFT JOIN {{unit}} as UNIT5 ON
536
-        UNIT5.unit_location_type = " . LOC_PLANET . " AND
536
+        UNIT5.unit_location_type = " . LOC_PLANET." AND
537 537
         UNIT5.unit_location_id = PLANETS5.id
538 538
       " .
539 539
 
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
       " .
552 552
       // Блокировка всех юнитов, принадлежащих этой планете
553 553
       "LEFT JOIN {{unit}} as UNIT6 ON
554
-        UNIT6.unit_location_type = " . LOC_PLANET . " AND
554
+        UNIT6.unit_location_type = " . LOC_PLANET." AND
555 555
         UNIT6.unit_location_id = PLANETS6.id
556 556
       " .
557 557
       "WHERE FLEET0.fleet_id = {$dbId} GROUP BY 1 FOR UPDATE"
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
       } elseif ($this->isResource($unit_id)) {
671 671
         $this->resource_list[$unit_id] = $unit_count;
672 672
       } else {
673
-        throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), ERR_ERROR);
673
+        throw new Exception('Trying to pass to fleet non-resource and non-ship '.var_export($unit_array, true), ERR_ERROR);
674 674
       }
675 675
     }
676 676
   }
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
    * @param int $unit_count
801 801
    */
802 802
   public function shipSetCount($unit_id, $unit_count = 0) {
803
-pdump(__CLASS__ . '->' . __FUNCTION__);
803
+pdump(__CLASS__.'->'.__FUNCTION__);
804 804
     $this->shipAdjustCount($unit_id, $unit_count, true);
805 805
   }
806 806
 
@@ -876,8 +876,8 @@  discard block
 block discarded – undo
876 876
    */
877 877
   public function shipsGetCapacityRecyclers($recycler_info) {
878 878
     $recyclers_incoming_capacity = 0;
879
-    foreach($this->shipsIterator() as $unitId => $unit) {
880
-      if(!empty(static::$snGroupRecyclers[$unitId]) && $unit->count >= 1) {
879
+    foreach ($this->shipsIterator() as $unitId => $unit) {
880
+      if (!empty(static::$snGroupRecyclers[$unitId]) && $unit->count >= 1) {
881 881
         $recyclers_incoming_capacity += $unit->count * $recycler_info[$unitId]['capacity'];
882 882
       }
883 883
     }
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
    */
1009 1009
   public function resourcesSet($resource_list) {
1010 1010
     if (!empty($this->propertiesAdjusted['resource_list'])) {
1011
-      throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR);
1011
+      throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in '.get_called_class().'::unitSetResourceList', ERR_ERROR);
1012 1012
     }
1013 1013
     $this->resourcesAdjust($resource_list, true);
1014 1014
   }
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
       // Check for negative unit value
1043 1043
       if ($this->resource_list[$resource_id] < 0) {
1044 1044
         // TODO
1045
-        throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR);
1045
+        throw new Exception('Resource '.$resource_id.' will become negative in '.get_called_class().'::unitAdjustResourceList', ERR_ERROR);
1046 1046
       }
1047 1047
     }
1048 1048
   }
@@ -1215,7 +1215,7 @@  discard block
 block discarded – undo
1215 1215
 
1216 1216
   protected function printErrorIfNoShips() {
1217 1217
     if ($this->unitList->unitsCount() <= 0) {
1218
-      message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 5);
1218
+      message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet'.DOT_PHP_EX, 5);
1219 1219
     }
1220 1220
   }
1221 1221
 
@@ -1550,8 +1550,8 @@  discard block
 block discarded – undo
1550 1550
 
1551 1551
   public function fleetSpeed() {
1552 1552
     $maxSpeed = PHP_INT_MAX;
1553
-    foreach($this->shipsIterator() as $ship_id => $unit) {
1554
-      if($unit->count > 0 && empty(static::$snGroupFleetAndMissiles[$ship_id])) {
1553
+    foreach ($this->shipsIterator() as $ship_id => $unit) {
1554
+      if ($unit->count > 0 && empty(static::$snGroupFleetAndMissiles[$ship_id])) {
1555 1555
         $single_ship_data = get_ship_data($ship_id, $this->dbOwnerRow);
1556 1556
         $maxSpeed = min($maxSpeed, $single_ship_data['speed']);
1557 1557
       }
@@ -1574,7 +1574,7 @@  discard block
 block discarded – undo
1574 1574
     } catch (Exception $e) {
1575 1575
 
1576 1576
       // TODO - MESSAGE BOX
1577
-      if($e instanceof ExceptionFleetInvalid) {
1577
+      if ($e instanceof ExceptionFleetInvalid) {
1578 1578
         sn_db_transaction_rollback();
1579 1579
         pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]);
1580 1580
       } else {
@@ -1663,7 +1663,7 @@  discard block
 block discarded – undo
1663 1663
       $validator->validate();
1664 1664
     } catch (Exception $e) {
1665 1665
       // TODO - MESSAGE BOX
1666
-      if($e instanceof ExceptionFleetInvalid) {
1666
+      if ($e instanceof ExceptionFleetInvalid) {
1667 1667
         sn_db_transaction_rollback();
1668 1668
         pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]);
1669 1669
       } else {
@@ -1724,7 +1724,7 @@  discard block
 block discarded – undo
1724 1724
 
1725 1725
 
1726 1726
     if (!empty($this->captain['unit_id'])) {
1727
-      DBStaticUnit::db_unit_set_by_id($this->captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$this->_dbId}");
1727
+      DBStaticUnit::db_unit_set_by_id($this->captain['unit_id'], "`unit_location_type` = ".LOC_FLEET.", `unit_location_id` = {$this->_dbId}");
1728 1728
     }
1729 1729
 
1730 1730
 //    return $this->fleet->acs['ankunft'] - $this->fleet->time_launch >= $this->fleet->travelData['duration'];
@@ -1736,7 +1736,7 @@  discard block
 block discarded – undo
1736 1736
     $template_result['.']['fleets'][] = $this->renderFleet(SN_TIME_NOW, $timeMissionJob);
1737 1737
 
1738 1738
     $template_result += array(
1739
-      'mission'         => classLocale::$lang['type_mission'][$this->_mission_type] . ($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' ' . pretty_time($timeMissionJob) : ''),
1739
+      'mission'         => classLocale::$lang['type_mission'][$this->_mission_type].($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' '.pretty_time($timeMissionJob) : ''),
1740 1740
       'dist'            => pretty_number($this->travelData['distance']),
1741 1741
       'speed'           => pretty_number($this->travelData['fleet_speed']),
1742 1742
       'deute_need'      => pretty_number($this->travelData['consumption']),
Please login to merge, or discard this patch.
includes/debug.class.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -70,6 +70,9 @@  discard block
 block discarded – undo
70 70
     $this->numqueries = 0;
71 71
   }
72 72
 
73
+  /**
74
+   * @param string $mes
75
+   */
73 76
   function add($mes) {
74 77
     $this->log .= $mes;
75 78
     $this->numqueries++;
@@ -185,6 +188,9 @@  discard block
 block discarded – undo
185 188
     return $error_backtrace;
186 189
   }
187 190
 
191
+  /**
192
+   * @param string $die_message
193
+   */
188 194
   function error_fatal($die_message, $details = 'There is a fatal error on page') {
189 195
     // TODO - Записывать детали ошибки в лог-файл
190 196
     die($die_message);
Please login to merge, or discard this patch.
Spacing   +74 added lines, -75 removed lines patch added patch discarded remove patch
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 
31 31
 defined('INSIDE') || die();
32 32
 
33
-if(php_sapi_name() == "cli") {
33
+if (php_sapi_name() == "cli") {
34 34
   // In cli-mode
35 35
   define('__DEBUG_CRLF', "\r\n");
36
-  define('__DEBUG_LINE', '-------------------------------------------------' . __DEBUG_CRLF);
36
+  define('__DEBUG_LINE', '-------------------------------------------------'.__DEBUG_CRLF);
37 37
 } else {
38 38
   // Not in cli-mode
39 39
   define('__DEBUG_CRLF', '<br />');
@@ -50,17 +50,17 @@  discard block
 block discarded – undo
50 50
   function log_file($message, $ident_change = 0) {
51 51
     static $ident = 0;
52 52
 
53
-    if(!defined('SN_DEBUG_LOG')) {
53
+    if (!defined('SN_DEBUG_LOG')) {
54 54
       return;
55 55
     }
56 56
 
57
-    if($this->log_file_handler === null) {
58
-      $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+');
57
+    if ($this->log_file_handler === null) {
58
+      $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL.'/.logs/supernova.log', 'a+');
59 59
       @fwrite($this->log_file_handler, "\r\n\r\n");
60 60
     }
61 61
     $ident_change < 0 ? $ident += $ident_change * 2 : false;
62
-    if($this->log_file_handler) {
63
-      @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n");
62
+    if ($this->log_file_handler) {
63
+      @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()).str_repeat(' ', $ident + 1).$message."\r\n");
64 64
     }
65 65
     $ident_change > 0 ? $ident += $ident_change * 2 : false;
66 66
   }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
   }
81 81
 
82 82
   function echo_log() {
83
-    echo '<br><table><tr><td class=k colspan=4><a href="' . SN_ROOT_PHYSICAL . "admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>";
83
+    echo '<br><table><tr><td class=k colspan=4><a href="'.SN_ROOT_PHYSICAL."admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>";
84 84
     die();
85 85
   }
86 86
 
@@ -90,25 +90,25 @@  discard block
 block discarded – undo
90 90
     $result = array();
91 91
     $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++;
92 92
     $result[] = "tID {$transaction_id}";
93
-    foreach($backtrace as $a_trace) {
94
-      if(in_array($a_trace['function'], $exclude_functions)) {
93
+    foreach ($backtrace as $a_trace) {
94
+      if (in_array($a_trace['function'], $exclude_functions)) {
95 95
         continue;
96 96
       }
97 97
       $function =
98 98
         ($a_trace['type']
99 99
           ? ($a_trace['type'] == '->'
100
-            ? "({$a_trace['class']})" . get_class($a_trace['object'])
100
+            ? "({$a_trace['class']})".get_class($a_trace['object'])
101 101
             : $a_trace['class']
102
-          ) . $a_trace['type']
102
+          ).$a_trace['type']
103 103
           : ''
104
-        ) . $a_trace['function'] . '()';
104
+        ).$a_trace['function'].'()';
105 105
 
106 106
       $file = str_replace(SN_ROOT_PHYSICAL, '', str_replace('\\', '/', $a_trace['file']));
107 107
 
108 108
       // $result[] = "{$function} ({$a_trace['line']})'{$file}'";
109 109
       $result[] = "{$function} - '{$file}' Line {$a_trace['line']}";
110 110
 
111
-      if(!$long_comment) {
111
+      if (!$long_comment) {
112 112
         break;
113 113
       }
114 114
     }
@@ -122,26 +122,26 @@  discard block
 block discarded – undo
122 122
   function dump($dump = false, $force_base = false, $deadlock = false) {
123 123
     global $user, $planetrow;
124 124
 
125
-    if($dump === false) {
125
+    if ($dump === false) {
126 126
       return;
127 127
     }
128 128
 
129 129
     $error_backtrace = array();
130 130
     $base_dump = false;
131 131
 
132
-    if($force_base === true) {
132
+    if ($force_base === true) {
133 133
       $base_dump = true;
134 134
     }
135 135
 
136
-    if($dump === true) {
136
+    if ($dump === true) {
137 137
       $base_dump = true;
138 138
     } else {
139
-      if(!is_array($dump)) {
139
+      if (!is_array($dump)) {
140 140
         $dump = array('var' => $dump);
141 141
       }
142 142
 
143
-      foreach($dump as $dump_var_name => $dump_var) {
144
-        if($dump_var_name == 'base_dump') {
143
+      foreach ($dump as $dump_var_name => $dump_var) {
144
+        if ($dump_var_name == 'base_dump') {
145 145
           $base_dump = $dump_var;
146 146
         } else {
147 147
           $error_backtrace[$dump_var_name] = $dump_var;
@@ -149,22 +149,21 @@  discard block
 block discarded – undo
149 149
       }
150 150
     }
151 151
 
152
-    if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
152
+    if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
153 153
       $error_backtrace['deadlock'] = explode("\n", $q['Status']);
154 154
       $error_backtrace['locks'] = classSupernova::$locks;
155 155
       $error_backtrace['cSN_data'] = classSupernova::$data;
156
-      foreach($error_backtrace['cSN_data'] as &$location) {
157
-        foreach($location as $location_id => &$location_data) {
158
-          $location_data = isset($location_data['username']) ? $location_data['username'] :
159
-            (isset($location_data['name']) ? $location_data['name'] : $location_id);
156
+      foreach ($error_backtrace['cSN_data'] as &$location) {
157
+        foreach ($location as $location_id => &$location_data) {
158
+          $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id);
160 159
         }
161 160
       }
162 161
       $error_backtrace['cSN_queries'] = classSupernova::$queries;
163 162
     }
164 163
 
165
-    if($base_dump) {
166
-      if(is_array($this->log_array) && count($this->log_array) > 0) {
167
-        foreach($this->log_array as $log) {
164
+    if ($base_dump) {
165
+      if (is_array($this->log_array) && count($this->log_array) > 0) {
166
+        foreach ($this->log_array as $log) {
168 167
           $error_backtrace['queries'][] = $log;
169 168
         }
170 169
       }
@@ -193,14 +192,14 @@  discard block
 block discarded – undo
193 192
   function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) {
194 193
     global $sys_stop_log_hit, $sys_log_disabled, $user;
195 194
 
196
-    if(empty(classSupernova::$db->connected)) {
195
+    if (empty(classSupernova::$db->connected)) {
197 196
       // TODO - писать ошибку в файл
198 197
       die('SQL server currently unavailable. Please contact Administration...');
199 198
     }
200 199
 
201 200
     sn_db_transaction_rollback();
202 201
 
203
-    if(classSupernova::$config->debug == 1) {
202
+    if (classSupernova::$config->debug == 1) {
204 203
       echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>";
205 204
       echo "<table>{$this->log}</table>";
206 205
     }
@@ -212,16 +211,16 @@  discard block
 block discarded – undo
212 211
 
213 212
     $userId = empty($user['id']) ? 0 : $user['id'];
214 213
 
215
-    if(!$sys_log_disabled) {
214
+    if (!$sys_log_disabled) {
216 215
       $query = "INSERT INTO `{{logs}}` SET
217
-        `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($userId) . "',
218
-        `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
219
-        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" .
216
+        `log_time` = '" . time()."', `log_code` = '".db_escape($error_code)."', `log_sender` = '".db_escape($userId)."',
217
+        `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."',  `log_text` = '".db_escape($message)."',
218
+        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'".
220 219
 //        ($error_backtrace ? ", `log_dump` = '" . db_escape(serialize($error_backtrace)) . "'" : '') . ";";
221
-      ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";";
222
-      doquery($query, '', false, true) or die($fatal_error . db_error());
220
+      ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";";
221
+      doquery($query, '', false, true) or die($fatal_error.db_error());
223 222
 
224
-      $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>" . db_insert_id() . "</b>";
223
+      $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>".db_insert_id()."</b>";
225 224
 
226 225
       $sys_stop_log_hit = true;
227 226
       $sys_log_disabled = true;
@@ -231,7 +230,7 @@  discard block
 block discarded – undo
231 230
       ob_start();
232 231
       print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}");
233 232
 
234
-      foreach($error_backtrace as $name => $value) {
233
+      foreach ($error_backtrace as $name => $value) {
235 234
         print(__DEBUG_LINE);
236 235
         pdump($value, $name);
237 236
       }
@@ -243,7 +242,7 @@  discard block
 block discarded – undo
243 242
   function warning($message, $title = 'System Message', $log_code = 300, $dump = false) {
244 243
     global $user, $sys_log_disabled;
245 244
 
246
-    if(empty(classSupernova::$db->connected)) {
245
+    if (empty(classSupernova::$db->connected)) {
247 246
       // TODO - писать ошибку в файл
248 247
       die('SQL server currently unavailable. Please contact Administration...');
249 248
     }
@@ -252,12 +251,12 @@  discard block
 block discarded – undo
252 251
 
253 252
     $userId = empty($user['id']) ? 0 : $user['id'];
254 253
 
255
-    if(!$sys_log_disabled) {
254
+    if (!$sys_log_disabled) {
256 255
       $query = "INSERT INTO `{{logs}}` SET
257
-        `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($userId) . "',
258
-        `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
259
-        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" .
260
-        ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";";
256
+        `log_time` = '" . time()."', `log_code` = '".db_escape($log_code)."', `log_sender` = '".db_escape($userId)."',
257
+        `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."',  `log_text` = '".db_escape($message)."',
258
+        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'".
259
+        ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";";
261 260
       doquery($query, '', false, true);
262 261
     } else {
263 262
 //        // TODO Здесь надо писать в файло
@@ -270,11 +269,11 @@  discard block
 block discarded – undo
270 269
 // Dump variables nicer then var_dump()
271 270
 
272 271
 function dump($value, $varname = null, $level = 0, $dumper = '') {
273
-  if(isset($varname)) {
272
+  if (isset($varname)) {
274 273
     $varname .= " = ";
275 274
   }
276 275
 
277
-  if($level == -1) {
276
+  if ($level == -1) {
278 277
     $trans[' '] = '&there4;';
279 278
     $trans["\t"] = '&rArr;';
280 279
     $trans["\n"] = '&para;;';
@@ -283,31 +282,31 @@  discard block
 block discarded – undo
283 282
 
284 283
     return strtr(htmlspecialchars($value), $trans);
285 284
   }
286
-  if($level == 0) {
285
+  if ($level == 0) {
287 286
 //    $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname;
288
-    $dumper = mt_rand(10, 99) . '|' . $varname;
287
+    $dumper = mt_rand(10, 99).'|'.$varname;
289 288
   }
290 289
 
291 290
   $type = gettype($value);
292 291
   $dumper .= $type;
293 292
 
294
-  if($type == 'string') {
295
-    $dumper .= '(' . strlen($value) . ')';
293
+  if ($type == 'string') {
294
+    $dumper .= '('.strlen($value).')';
296 295
     $value = dump($value, '', -1);
297
-  } elseif($type == 'boolean') {
296
+  } elseif ($type == 'boolean') {
298 297
     $value = ($value ? 'true' : 'false');
299
-  } elseif($type == 'object') {
298
+  } elseif ($type == 'object') {
300 299
     $props = get_class_vars(get_class($value));
301
-    $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>';
302
-    foreach($props as $key => $val) {
303
-      $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => ';
300
+    $dumper .= '('.count($props).') <u>'.get_class($value).'</u>';
301
+    foreach ($props as $key => $val) {
302
+      $dumper .= "\n".str_repeat("\t", $level + 1).$key.' => ';
304 303
       $dumper .= dump($value->$key, '', $level + 1);
305 304
     }
306 305
     $value = '';
307
-  } elseif($type == 'array') {
308
-    $dumper .= '(' . count($value) . ')';
309
-    foreach($value as $key => $val) {
310
-      $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => ';
306
+  } elseif ($type == 'array') {
307
+    $dumper .= '('.count($value).')';
308
+    foreach ($value as $key => $val) {
309
+      $dumper .= "\n".str_repeat("\t", $level + 1).dump($key, '', -1).' => ';
311 310
       $dumper .= dump($val, '', $level + 1);
312 311
     }
313 312
     $value = '';
@@ -326,24 +325,24 @@  discard block
 block discarded – undo
326 325
 //  $backtrace = $backtrace[1];
327 326
 
328 327
   $caller = '';
329
-  if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
330
-    $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') .
331
-      (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') .
332
-      $backtrace[1]['function'] .
328
+  if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
329
+    $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '').
330
+      (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '').
331
+      $backtrace[1]['function'].
333 332
       (!empty($backtrace[0]['file'])
334 333
         ? (
335
-          ' (' . substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN) .
336
-          (!empty($backtrace[0]['line']) ? ':' . $backtrace[0]['line'] : '') .
334
+          ' ('.substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN).
335
+          (!empty($backtrace[0]['line']) ? ':'.$backtrace[0]['line'] : '').
337 336
           ')'
338 337
         )
339 338
         : ''
340 339
       );
341
-    $caller = "\r\n" . $caller;
340
+    $caller = "\r\n".$caller;
342 341
   }
343 342
 
344
-  print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">' .
345
-    dump($value, $varname) .
346
-    $caller .
343
+  print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">'.
344
+    dump($value, $varname).
345
+    $caller.
347 346
     '</pre>'
348 347
   );
349 348
 }
@@ -353,24 +352,24 @@  discard block
 block discarded – undo
353 352
 }
354 353
 
355 354
 function pr($prePrint = false) {
356
-  if($prePrint) {
355
+  if ($prePrint) {
357 356
     print(__DEBUG_CRLF);
358 357
   }
359
-  print(mt_rand() . __DEBUG_CRLF);
358
+  print(mt_rand().__DEBUG_CRLF);
360 359
 }
361 360
 
362 361
 function pc($prePrint = false) {
363 362
   global $_PRINT_COUNT_VALUE;
364 363
   $_PRINT_COUNT_VALUE++;
365 364
 
366
-  if($prePrint) {
365
+  if ($prePrint) {
367 366
     print(__DEBUG_CRLF);
368 367
   }
369
-  print($_PRINT_COUNT_VALUE . __DEBUG_CRLF);
368
+  print($_PRINT_COUNT_VALUE.__DEBUG_CRLF);
370 369
 }
371 370
 
372 371
 function prep($message) {
373
-  print('<pre>' . $message . '</pre>');
372
+  print('<pre>'.$message.'</pre>');
374 373
 }
375 374
 
376 375
 function backtrace_no_arg() {
@@ -393,5 +392,5 @@  discard block
 block discarded – undo
393 392
  */
394 393
 function pdie($message = '') {
395 394
   $backtrace = debug_backtrace();
396
-  die(__DEBUG_LINE . ($message ? $message . ' @ ' : '') . $backtrace[0]['file'] . ':' . $backtrace[0]['line']);
395
+  die(__DEBUG_LINE.($message ? $message.' @ ' : '').$backtrace[0]['file'].':'.$backtrace[0]['line']);
397 396
 }
Please login to merge, or discard this patch.
metamatter.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -4,9 +4,9 @@  discard block
 block discarded – undo
4 4
 // Может добавить спецстатус "Ответ системы платежа" и парсить дальше getMessage
5 5
 // см constants.php
6 6
 
7
-include_once('common.' . substr(strrchr(__FILE__, '.'), 1));
7
+include_once('common.'.substr(strrchr(__FILE__, '.'), 1));
8 8
 
9
-if(!sn_module_get_active_count('payment')) {
9
+if (!sn_module_get_active_count('payment')) {
10 10
   sys_redirect('dark_matter.php');
11 11
   die();
12 12
 }
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
 
24 24
 // Таблица скидок
25 25
 $prev_discount = 0;
26
-if(isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) {
27
-  foreach(sn_module_payment::$bonus_table as $sum => $discount) {
28
-    if($discount && $discount != $prev_discount) {
26
+if (isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) {
27
+  foreach (sn_module_payment::$bonus_table as $sum => $discount) {
28
+    if ($discount && $discount != $prev_discount) {
29 29
       $template->assign_block_vars('discount', array(
30 30
         'SUM'          => $sum,
31 31
         'DISCOUNT'     => $discount * 100,
@@ -38,19 +38,19 @@  discard block
 block discarded – undo
38 38
 }
39 39
 
40 40
 // Результат платежа
41
-if($payment_id = sys_get_param_id('payment_id')) {
41
+if ($payment_id = sys_get_param_id('payment_id')) {
42 42
   $payment = db_payment_get($payment_id);
43
-  if($payment && $payment['payment_user_id'] == $user['id']) {
44
-    if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
43
+  if ($payment && $payment['payment_user_id'] == $user['id']) {
44
+    if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
45 45
       $template->assign_block_vars('result', array('MESSAGE' => sprintf(classLocale::$lang['pay_msg_mm_purchase_complete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name'], $payment['payment_dark_matter_gained'])));
46 46
     }
47
-    if($payment['payment_status'] == PAYMENT_STATUS_NONE) {
47
+    if ($payment['payment_status'] == PAYMENT_STATUS_NONE) {
48 48
       $template->assign_block_vars('result', array(
49 49
         'MESSAGE' => sprintf(classLocale::$lang['pay_msg_mm_purchase_incomplete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name']),
50 50
         'STATUS'  => 1,
51 51
       ));
52 52
     }
53
-    if($payment['payment_test']) {
53
+    if ($payment['payment_test']) {
54 54
       $template->assign_block_vars('result', array(
55 55
         'MESSAGE' => sprintf(classLocale::$lang['pay_msg_mm_purchase_test']),
56 56
         'STATUS'  => -1,
@@ -65,28 +65,28 @@  discard block
 block discarded – undo
65 65
   'metamatter' => sys_get_param_float('metamatter'),
66 66
 );
67 67
 
68
-if(!$request['metamatter']) {
68
+if (!$request['metamatter']) {
69 69
   unset($_POST);
70 70
 }
71 71
 
72 72
 $payment_methods_available = array_combine(array_keys(sn_module_payment::$payment_methods), array_fill(0, count(sn_module_payment::$payment_methods), null));
73
-array_walk($payment_methods_available, function (&$value, $index) {
73
+array_walk($payment_methods_available, function(&$value, $index) {
74 74
   $value = !empty(sn_module_payment::$payment_methods[$index]) ? array_combine(array_keys(sn_module_payment::$payment_methods[$index]), array_fill(0, count(sn_module_payment::$payment_methods[$index]), null)) : $value;
75 75
 });
76 76
 
77 77
 // pdump($payment_methods_available);
78 78
 $payment_module_valid = false;
79 79
 $payment_module = sys_get_param_str('payment_module');
80
-foreach(sn_module::$sn_module_list['payment'] as $module_name => $module) {
81
-  if(!is_object($module) || !$module->manifest['active']) {
80
+foreach (sn_module::$sn_module_list['payment'] as $module_name => $module) {
81
+  if (!is_object($module) || !$module->manifest['active']) {
82 82
     continue;
83 83
   }
84 84
 
85 85
   lng_include($module_name, $module->manifest['root_relative']);
86 86
 
87
-  foreach(sn_module_payment::$payment_methods as $payment_type_id => $available_methods) {
88
-    foreach($available_methods as $payment_method => $payment_currency) {
89
-      if(isset($module->manifest['payment_method'][$payment_method])) {
87
+  foreach (sn_module_payment::$payment_methods as $payment_type_id => $available_methods) {
88
+    foreach ($available_methods as $payment_method => $payment_currency) {
89
+      if (isset($module->manifest['payment_method'][$payment_method])) {
90 90
         $payment_methods_available[$payment_type_id][$payment_method][$module_name] = $module->manifest['payment_method'][$payment_method];
91 91
       }
92 92
     }
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 
98 98
 global $template_result;
99 99
 // Доступные платежные методы
100
-foreach($payment_methods_available as $payment_type_id => $payment_methods) {
101
-  if(empty($payment_methods)) {
100
+foreach ($payment_methods_available as $payment_type_id => $payment_methods) {
101
+  if (empty($payment_methods)) {
102 102
     continue;
103 103
   }
104 104
 
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
     'ID'   => $payment_type_id,
107 107
     'NAME' => classLocale::$lang['pay_methods'][$payment_type_id],
108 108
   );
109
-  foreach($payment_methods as $payment_method_id => $module_list) {
110
-    if(empty($module_list)) {
109
+  foreach ($payment_methods as $payment_method_id => $module_list) {
110
+    if (empty($module_list)) {
111 111
       continue;
112 112
     }
113 113
     $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id] = array(
@@ -118,14 +118,14 @@  discard block
 block discarded – undo
118 118
       'NAME_FORCE' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['name']),
119 119
       'BUTTON'     => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['button']),
120 120
     );
121
-    foreach($module_list as $payment_module_name => $payment_module_method_details) {
121
+    foreach ($module_list as $payment_module_name => $payment_module_method_details) {
122 122
       $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id]['.']['module'][] = array(
123 123
         'MODULE' => $payment_module_name,
124 124
       );
125 125
     }
126 126
   }
127 127
 
128
-  if(empty($template_result['.']['payment'][$payment_type_id]['.'])) {
128
+  if (empty($template_result['.']['payment'][$payment_type_id]['.'])) {
129 129
     unset($template_result['.']['payment'][$payment_type_id]);
130 130
   }
131 131
 }
@@ -138,19 +138,19 @@  discard block
 block discarded – undo
138 138
 $payment_module_valid = $payment_module_valid && (!$payment_method_selected || isset($payment_methods_available[$payment_type_selected][$payment_method_selected][$module_name]));
139 139
 
140 140
 // If payment_module invalid - making it empty OR if there is only one payment_module - selecting it
141
-if($payment_module_valid) {
141
+if ($payment_module_valid) {
142 142
   // $payment_module = $payment_module; // Really - do nothing
143
-} elseif($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) {
143
+} elseif ($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) {
144 144
   reset($payment_methods_available[$payment_type_selected][$payment_method_selected]);
145 145
   $payment_module = key($payment_methods_available[$payment_type_selected][$payment_method_selected]);
146
-} elseif(count(sn_module::$sn_module_list['payment']) == 1) {
146
+} elseif (count(sn_module::$sn_module_list['payment']) == 1) {
147 147
   $payment_module = $module_name;
148 148
 } else {
149 149
   $payment_module = '';
150 150
 }
151 151
 
152
-if($payment_type_selected && $payment_method_selected) {
153
-  foreach($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) {
152
+if ($payment_type_selected && $payment_method_selected) {
153
+  foreach ($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) {
154 154
     $template->assign_block_vars('payment_module', array(
155 155
       'ID'          => $module_name,
156 156
       'NAME'        => classLocale::$lang["module_{$module_name}_name"],
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
   }
160 160
 }
161 161
 
162
-foreach(classLocale::$lang['pay_currency_list'] as $key => $value) {
162
+foreach (classLocale::$lang['pay_currency_list'] as $key => $value) {
163 163
   $course = get_exchange_rate($key);
164
-  if(!$course) {
164
+  if (!$course) {
165 165
     continue;
166 166
   }
167 167
   $template->assign_block_vars('exchange', array(
@@ -176,17 +176,17 @@  discard block
 block discarded – undo
176 176
   ));
177 177
 }
178 178
 
179
-if($request['metamatter'] && $payment_module) {
179
+if ($request['metamatter'] && $payment_module) {
180 180
   try {
181 181
     // Any possible errors about generating paylink should be raised in module!
182 182
     $pay_link = sn_module::$sn_module[$payment_module]->compile_request($request);
183 183
 
184 184
     // Поддержка дополнительной информации
185
-    if(is_array($pay_link['RENDER'])) {
186
-      foreach($pay_link['RENDER'] as $html_data) {
185
+    if (is_array($pay_link['RENDER'])) {
186
+      foreach ($pay_link['RENDER'] as $html_data) {
187 187
         $template->assign_block_vars('render', $html_data);
188
-        if(isset($html_data['VALUE']) && is_array($html_data['VALUE'])) {
189
-          foreach($html_data['VALUE'] as $value_id => $value_value) {
188
+        if (isset($html_data['VALUE']) && is_array($html_data['VALUE'])) {
189
+          foreach ($html_data['VALUE'] as $value_id => $value_value) {
190 190
             $template->assign_block_vars('render.value', array(
191 191
               'FIELD' => $value_id,
192 192
               'VALUE' => $value_value,
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
     }
198 198
 
199 199
     // Поддержка передачи данных для многошаговых платежных систем
200
-    if(is_array($pay_link['DATA'])) {
201
-      foreach($pay_link['DATA'] as $key => $value) {
200
+    if (is_array($pay_link['DATA'])) {
201
+      foreach ($pay_link['DATA'] as $key => $value) {
202 202
         $template->assign_block_vars('pay_link_data', array(
203 203
           'FIELD' => $key,
204 204
           'VALUE' => $value,
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
       }
207 207
     }
208 208
 
209
-    if(is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) {
209
+    if (is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) {
210 210
       // TODO Переделать это под assign_vars_recursive и возвращать пустые строки если нет платежного метода - для унификации формы в темплейте
211 211
       $template->assign_vars(array(
212 212
         'PAY_LINK_METHOD' => $pay_link['PAY_LINK_METHOD'],
@@ -215,17 +215,17 @@  discard block
 block discarded – undo
215 215
     } else {
216 216
       throw new exception(classLocale::$lang['pay_msg_request_paylink_unsupported'], ERR_ERROR);
217 217
     }
218
-  } catch(exception $e) {
218
+  } catch (exception $e) {
219 219
     $template->assign_block_vars('result', $response = array(
220 220
       'STATUS'  => $e->getCode(),
221 221
       'MESSAGE' => $e->getMessage(),
222 222
     ));
223
-    classSupernova::$debug->warning('Результат операции: код ' . $e->getCode() . ' сообщение "' . $e->getMessage() . '"', 'Ошибка платежа', LOG_INFO_PAYMENT);
223
+    classSupernova::$debug->warning('Результат операции: код '.$e->getCode().' сообщение "'.$e->getMessage().'"', 'Ошибка платежа', LOG_INFO_PAYMENT);
224 224
   }
225 225
 }
226 226
 
227 227
 // Прегенерированные пакеты
228
-foreach($unit_available_amount_list as $unit_amount => $discount) {
228
+foreach ($unit_available_amount_list as $unit_amount => $discount) {
229 229
   $temp = sn_module_payment::currency_convert($unit_amount, 'MM_', $player_currency);
230 230
   $template->assign_block_vars('mm_amount', array(
231 231
     'VALUE'            => $unit_amount,
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
   'PLAYER_CURRENCY'              => $player_currency,
261 261
   'PLAYER_CURRENCY_PRICE_PER_MM' => sn_module_payment::currency_convert(1, $player_currency, 'MM_', 10),
262 262
 
263
-  'UNIT_AMOUNT'                 => (float)$request['metamatter'],
263
+  'UNIT_AMOUNT'                 => (float) $request['metamatter'],
264 264
   'UNIT_AMOUNT_TEXT'            => pretty_number($request['metamatter']),
265 265
   'UNIT_AMOUNT_BONUS_PERCENT'   => $bonus_percent,
266 266
   'UNIT_AMOUNT_TEXT_DISCOUNTED' => $income_metamatter_text,
Please login to merge, or discard this patch.
infos.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @version 1.1
10 10
  * @copyright 2008 By Chlorel for XNova
11 11
  */
12
-include('common.' . substr(strrchr(__FILE__, '.'), 1));
12
+include('common.'.substr(strrchr(__FILE__, '.'), 1));
13 13
 
14 14
 function ShowProductionTable($CurrentUser, $CurrentPlanet, $BuildID, $Template) {
15 15
   $config_resource_multiplier = game_resource_multiplier();
@@ -47,20 +47,20 @@  discard block
 block discarded – undo
47 47
   ));
48 48
 
49 49
   $ActualProd = floor($Prod[$BuildID]);
50
-  if($BuildID != STRUC_MINE_FUSION) {
50
+  if ($BuildID != STRUC_MINE_FUSION) {
51 51
     $ActualNeed = floor($Prod[STRUC_MINE_SOLAR]);
52 52
   } else {
53 53
     $ActualNeed = floor($Prod[STRUC_MINE_DEUTERIUM]);
54 54
   }
55 55
 
56 56
   $BuildStartLvl = $CurrentBuildtLvl - 2;
57
-  if($BuildStartLvl < 1) {
57
+  if ($BuildStartLvl < 1) {
58 58
     $BuildStartLvl = 1;
59 59
   }
60 60
   $Table = '';
61 61
   $ProdFirst = 0;
62
-  for($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 10; $BuildLevel++) {
63
-    if($BuildID != STRUC_MOON_PHALANX) {
62
+  for ($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 10; $BuildLevel++) {
63
+    if ($BuildID != STRUC_MOON_PHALANX) {
64 64
       $Prod[STRUC_MINE_METAL] = floor(mrc_modify_value(
65 65
         $CurrentUser,
66 66
         $CurrentPlanet,
@@ -86,17 +86,17 @@  discard block
 block discarded – undo
86 86
         $config_resource_multiplier_plain * $unit_data[P_UNIT_PRODUCTION][RES_ENERGY]($BuildLevel, 100, $CurrentUser, $CurrentPlanet)
87 87
       ));
88 88
 
89
-      $bloc['build_lvl'] = ($CurrentBuildtLvl == $BuildLevel) ? "<font color=\"#ff0000\">" . $BuildLevel . "</font>" : $BuildLevel;
90
-      if($ProdFirst > 0) {
91
-        if($BuildID != STRUC_MINE_FUSION) {
92
-          $bloc['build_gain'] = "<font color=\"lime\">(" . pretty_number(floor($Prod[$BuildID] - $ProdFirst)) . ")</font>";
89
+      $bloc['build_lvl'] = ($CurrentBuildtLvl == $BuildLevel) ? "<font color=\"#ff0000\">".$BuildLevel."</font>" : $BuildLevel;
90
+      if ($ProdFirst > 0) {
91
+        if ($BuildID != STRUC_MINE_FUSION) {
92
+          $bloc['build_gain'] = "<font color=\"lime\">(".pretty_number(floor($Prod[$BuildID] - $ProdFirst)).")</font>";
93 93
         } else {
94
-          $bloc['build_gain'] = "<font color=\"lime\">(" . pretty_number(floor($Prod[STRUC_MINE_SOLAR] - $ProdFirst)) . ")</font>";
94
+          $bloc['build_gain'] = "<font color=\"lime\">(".pretty_number(floor($Prod[STRUC_MINE_SOLAR] - $ProdFirst)).")</font>";
95 95
         }
96 96
       } else {
97 97
         $bloc['build_gain'] = '';
98 98
       }
99
-      if($BuildID != STRUC_MINE_FUSION) {
99
+      if ($BuildID != STRUC_MINE_FUSION) {
100 100
         $bloc['build_prod'] = pretty_number(floor($Prod[$BuildID]));
101 101
         $bloc['build_prod_diff'] = pretty_number(floor($Prod[$BuildID] - $ActualProd), true, true);
102 102
         $bloc['build_need'] = pretty_number(floor($Prod[STRUC_MINE_SOLAR]), true, true);
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
         $bloc['build_need'] = pretty_number(floor($Prod[STRUC_MINE_DEUTERIUM]), true, true);
108 108
         $bloc['build_need_diff'] = pretty_number(floor($Prod[STRUC_MINE_DEUTERIUM] - $ActualNeed), true, true);
109 109
       }
110
-      if($ProdFirst == 0) {
111
-        if($BuildID != STRUC_MINE_FUSION) {
110
+      if ($ProdFirst == 0) {
111
+        if ($BuildID != STRUC_MINE_FUSION) {
112 112
           $ProdFirst = floor($Prod[$BuildID]);
113 113
         } else {
114 114
           $ProdFirst = floor($Prod[STRUC_MINE_SOLAR]);
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
       }
117 117
     } else {
118 118
       // Cas particulier de la phalange
119
-      $bloc['build_lvl'] = ($CurrentBuildtLvl == $BuildLevel) ? "<font color=\"#ff0000\">" . $BuildLevel . "</font>" : $BuildLevel;
119
+      $bloc['build_lvl'] = ($CurrentBuildtLvl == $BuildLevel) ? "<font color=\"#ff0000\">".$BuildLevel."</font>" : $BuildLevel;
120 120
       $bloc['build_range'] = ($BuildLevel * $BuildLevel) - 1;
121 121
     }
122 122
     $Table .= parsetemplate($Template, $bloc);
@@ -133,22 +133,22 @@  discard block
 block discarded – undo
133 133
 
134 134
   $str_rapid_from = '';
135 135
   $str_rapid_to = '';
136
-  foreach(sn_get_groups(array('fleet', 'defense_active')) as $enemy_id) {
136
+  foreach (sn_get_groups(array('fleet', 'defense_active')) as $enemy_id) {
137 137
     $enemy_data = get_unit_param($enemy_id);
138 138
     $enemy_durability = $enemy_data['shield'] + $enemy_data['armor'];
139 139
 
140 140
     $rapid = floor($unit_data['attack'] * (isset($unit_data['amplify'][$enemy_id]) ? $unit_data['amplify'][$enemy_id] : 1) / $enemy_durability);
141
-    if($rapid >= 1) {
141
+    if ($rapid >= 1) {
142 142
       $str_rapid_to .= "{$classLocale['nfo_rf_again']} {$classLocale['tech'][$enemy_id]} <font color=\"#00ff00\">{$rapid}</font><br>";
143 143
     }
144 144
 
145 145
     $rapid = floor($enemy_data['attack'] * (isset($enemy_data['amplify'][$unit_id]) ? $enemy_data['amplify'][$unit_id] : 1) / $unit_durability);
146
-    if($rapid >= 1) {
146
+    if ($rapid >= 1) {
147 147
       $str_rapid_from .= "{$classLocale['tech'][$enemy_id]} {$classLocale['nfo_rf_from']} <font color=\"#ff0000\">{$rapid}</font><br>";
148 148
     }
149 149
   }
150 150
 
151
-  if($str_rapid_to && $str_rapid_from) {
151
+  if ($str_rapid_to && $str_rapid_from) {
152 152
     $str_rapid_to .= '<hr>';
153 153
   }
154 154
 
@@ -156,16 +156,16 @@  discard block
 block discarded – undo
156 156
 }
157 157
 
158 158
 $unit_id = sys_get_param_id('gid');
159
-if($unit_id == RES_DARK_MATTER) {
159
+if ($unit_id == RES_DARK_MATTER) {
160 160
   sys_redirect('dark_matter.php');
161 161
 }
162 162
 
163
-if($unit_id == RES_METAMATTER) {
163
+if ($unit_id == RES_METAMATTER) {
164 164
   sys_redirect('metamatter.php');
165 165
 }
166 166
 
167 167
 lng_include('infos');
168
-if(!$unit_id || (!get_unit_param($unit_id) && !isset(classLocale::$lang['info'][$unit_id]))) {
168
+if (!$unit_id || (!get_unit_param($unit_id) && !isset(classLocale::$lang['info'][$unit_id]))) {
169 169
   sys_redirect('index.php?page=techtree');
170 170
 }
171 171
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 $unit_data = get_unit_param($unit_id);
175 175
 $unit_type = $unit_data['type'];
176 176
 
177
-if($unit_type == UNIT_SHIPS) {
177
+if ($unit_type == UNIT_SHIPS) {
178 178
   $template_result['UNIT_IS_SHIP'] = true;
179 179
 
180 180
   $ship_data = get_ship_data($unit_id, $user);
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
   );
191 191
 
192 192
   $engine_template_info = array();
193
-  foreach($unit_data['engine'] as $unit_engine_data) {
193
+  foreach ($unit_data['engine'] as $unit_engine_data) {
194 194
     $unit_engine_data = get_engine_data($user, $unit_engine_data);
195 195
 
196 196
     $engine_template_info[] = array(
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 
210 210
 
211 211
 $sn_data_group_combat = sn_get_groups('combat');
212
-if(in_array($unit_id, $sn_data_group_combat)) {
212
+if (in_array($unit_id, $sn_data_group_combat)) {
213 213
   $template_result['UNIT_IS_COMBAT'] = true;
214 214
 
215 215
   $unit_durability = $unit_data['shield'] + $unit_data['armor'];
@@ -217,21 +217,21 @@  discard block
 block discarded – undo
217 217
   $volley_arr = $rapid_to = $rapid_from = array();
218 218
   $str_rapid_from = '';
219 219
   $str_rapid_to = '';
220
-  foreach($sn_data_group_combat as $enemy_id) {
220
+  foreach ($sn_data_group_combat as $enemy_id) {
221 221
     $enemy_data = get_unit_param($enemy_id);
222 222
     $enemy_durability = $enemy_data['shield'] + $enemy_data['armor'];
223 223
 
224 224
     $rapid = $unit_data['attack'] * (isset($unit_data['amplify'][$enemy_id]) ? $unit_data['amplify'][$enemy_id] : 1) / $enemy_durability;
225
-    if($rapid >= 1) {
225
+    if ($rapid >= 1) {
226 226
       $volley_arr[$enemy_id]['TO'] = floor($rapid);
227 227
     }
228 228
 
229 229
     $rapid = $enemy_data['attack'] * (isset($enemy_data['amplify'][$unit_id]) ? $enemy_data['amplify'][$unit_id] : 1) / $unit_durability;
230
-    if($rapid >= 1) {
230
+    if ($rapid >= 1) {
231 231
       $volley_arr[$enemy_id]['FROM'] = floor($rapid);
232 232
     }
233 233
   }
234
-  foreach($volley_arr as $enemy_id => &$rapid) {
234
+  foreach ($volley_arr as $enemy_id => &$rapid) {
235 235
     $rapid['ENEMY_ID'] = $enemy_id;
236 236
     $rapid['ENEMY_NAME'] = classLocale::$lang['tech'][$enemy_id];
237 237
   }
@@ -249,13 +249,13 @@  discard block
 block discarded – undo
249 249
 
250 250
 }
251 251
 
252
-if(classLocale::$lang['info'][$unit_id]['effect']) {
252
+if (classLocale::$lang['info'][$unit_id]['effect']) {
253 253
   $template_result['UNIT_EFFECT'] = classLocale::$lang['info'][$unit_id]['effect'];
254 254
 }
255 255
 
256
-if($unit_data['bonus']) {
256
+if ($unit_data['bonus']) {
257 257
   $unit_bonus = !$unit_data['bonus'] || $unit_data['bonus_type'] == BONUS_ABILITY ? '' : (
258
-    ($unit_data['bonus'] >= 0 ? '+' : '') . $unit_data['bonus'] . ($unit_data['bonus_type'] == BONUS_PERCENT ? '%' : '')
258
+    ($unit_data['bonus'] >= 0 ? '+' : '').$unit_data['bonus'].($unit_data['bonus_type'] == BONUS_PERCENT ? '%' : '')
259 259
   );
260 260
   $template_result['UNIT_BONUS'] = $unit_bonus;
261 261
 }
Please login to merge, or discard this patch.
buildings.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
  * @copyright 2008 by Chlorel for XNova
15 15
  */
16 16
 
17
-include('common.' . substr(strrchr(__FILE__, '.'), 1));
17
+include('common.'.substr(strrchr(__FILE__, '.'), 1));
18 18
 
19 19
 define('SN_RENDER_NAVBAR_PLANET', true);
20 20
 
21 21
 $mode = sys_get_param_escaped('mode');
22 22
 $mode = (!$mode || $mode == 'buildings') ? QUE_STRUCTURES : ($mode == 'fleet' ? SUBQUE_FLEET : ($mode == 'defense' ? SUBQUE_DEFENSE : ($mode == 'research' ? QUE_RESEARCH : $mode)));
23 23
 
24
-if($building_sort = sys_get_param_id('sort_elements')) {
25
-  if(!empty(classLocale::$lang['player_option_building_sort'][$building_sort])) {
24
+if ($building_sort = sys_get_param_id('sort_elements')) {
25
+  if (!empty(classLocale::$lang['player_option_building_sort'][$building_sort])) {
26 26
     classSupernova::$user_options[array(PLAYER_OPTION_BUILDING_SORT, $mode)] = $building_sort;
27 27
     classSupernova::$user_options[array(PLAYER_OPTION_BUILDING_SORT_INVERSE, $mode)] = sys_get_param_id('sort_elements_inverse', 0);
28 28
   }
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 lng_include('buildings');
33 33
 lng_include('infos');
34 34
 
35
-sn_sys_sector_buy('buildings.php?mode=' . $mode);
35
+sn_sys_sector_buy('buildings.php?mode='.$mode);
36 36
 
37 37
 require_once('includes/includes/eco_bld_structures.php');
38 38
 switch ($mode) {
Please login to merge, or discard this patch.
banned.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@
 block discarded – undo
14 14
  */
15 15
 
16 16
 $allow_anonymous = true;
17
-include('common.' . substr(strrchr(__FILE__, '.'), 1));
17
+include('common.'.substr(strrchr(__FILE__, '.'), 1));
18 18
 
19 19
 $template = gettemplate('banned_body', true);
20 20
 
21 21
 $query = db_banned_list_select();
22 22
 $i = 0;
23
-while($ban_row = db_fetch($query)) {
23
+while ($ban_row = db_fetch($query)) {
24 24
   $template->assign_block_vars('banlist', array(
25 25
     'USER_NAME'   => $ban_row['ban_user_name'],
26 26
     'REASON'      => $ban_row['ban_reason'],
Please login to merge, or discard this patch.