@@ -30,8 +30,7 @@ |
||
30 | 30 | * @param $resource_id |
31 | 31 | * @param ResourceCalculations $capsObj |
32 | 32 | */ |
33 | -function int_calc_storage_bar($resource_id, $capsObj) |
|
34 | -{ |
|
33 | +function int_calc_storage_bar($resource_id, $capsObj) { |
|
35 | 34 | global $lang, $template, $planetrow, $user; |
36 | 35 | |
37 | 36 | $totalProduction = $capsObj->getProduction($resource_id); |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | |
97 | 97 | for ($Option = 10; $Option >= 0; $Option--) |
98 | 98 | { |
99 | - $template->assign_block_vars('option', array( |
|
100 | - 'VALUE' => $Option * 10, |
|
101 | - )); |
|
99 | + $template->assign_block_vars('option', array( |
|
100 | + 'VALUE' => $Option * 10, |
|
101 | + )); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | $capsObj = new ResourceCalculations(); |
@@ -165,12 +165,12 @@ discard block |
||
165 | 165 | int_calc_storage_bar(RES_DEUTERIUM, $capsObj); |
166 | 166 | |
167 | 167 | $template->assign_vars(array( |
168 | - 'PLANET_NAME' => $planetrow['name'], |
|
169 | - 'PLANET_TYPE' => $planetrow['planet_type'], |
|
168 | + 'PLANET_NAME' => $planetrow['name'], |
|
169 | + 'PLANET_TYPE' => $planetrow['planet_type'], |
|
170 | 170 | |
171 | - 'PRODUCTION_LEVEL' => floor($capsObj->efficiency * 100), |
|
171 | + 'PRODUCTION_LEVEL' => floor($capsObj->efficiency * 100), |
|
172 | 172 | |
173 | - 'PAGE_HINT' => $lang['res_hint'], |
|
173 | + 'PAGE_HINT' => $lang['res_hint'], |
|
174 | 174 | )); |
175 | 175 | |
176 | 176 | display($template, $lang['res_planet_production']); |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | ]); |
51 | 51 | }; |
52 | 52 | |
53 | -$ValidList['percent'] = array ( 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 ); |
|
53 | +$ValidList['percent'] = array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100); |
|
54 | 54 | $template = gettemplate('resources', true); |
55 | 55 | |
56 | 56 | $planet = new \Planet\Planet($planetrow['id']); |
57 | -if(!empty($transmutation_result = $planet->sn_sys_planet_core_transmute($user))) { |
|
57 | +if (!empty($transmutation_result = $planet->sn_sys_planet_core_transmute($user))) { |
|
58 | 58 | $template->assign_block_vars('result', $transmutation_result); |
59 | 59 | $planet = new \Planet\Planet($planetrow['id']); |
60 | 60 | } |
@@ -63,20 +63,20 @@ discard block |
||
63 | 63 | $production = $_POST['production']; |
64 | 64 | //$SubQry = ''; |
65 | 65 | $SubQry = array(); |
66 | -if(is_array($production)) { |
|
67 | - foreach($production as $prod_id => $percent) { |
|
68 | - if($percent > 100 || $percent < 0) { |
|
66 | +if (is_array($production)) { |
|
67 | + foreach ($production as $prod_id => $percent) { |
|
68 | + if ($percent > 100 || $percent < 0) { |
|
69 | 69 | $debug->warning('Supplying wrong production percent (less then 0 or greater then 100)', 'Hack attempt', 302, array('base_dump' => true)); |
70 | 70 | die(); |
71 | 71 | } |
72 | 72 | |
73 | 73 | $prod_id = intval($prod_id); |
74 | - if(in_array($prod_id, $sn_group_factories) && get_unit_param($prod_id, P_MINING_IS_MANAGED)) { |
|
74 | + if (in_array($prod_id, $sn_group_factories) && get_unit_param($prod_id, P_MINING_IS_MANAGED)) { |
|
75 | 75 | $field_name = pname_factory_production_field_name($prod_id); |
76 | 76 | $percent = floor($percent / 10); |
77 | 77 | $planetrow[$field_name] = $percent; |
78 | 78 | //$SubQry .= "`{$field_name}` = '{$percent}',"; |
79 | - $SubQry[] = "`{$field_name}` = '{$percent}'"; |
|
79 | + $SubQry[] = "`{$field_name}` = '{$percent}'"; |
|
80 | 80 | } else { |
81 | 81 | $debug->warning('Supplying wrong ID in production array - attempt to change some field - ID' . $prod_id, 'Resource Page', 301); |
82 | 82 | continue; |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | 'ENERGY_TYPE' => $capsObj->productionCurrentMatrix[RES_ENERGY][0], |
114 | 114 | )); |
115 | 115 | |
116 | -foreach($sn_group_factories as $unit_id) |
|
116 | +foreach ($sn_group_factories as $unit_id) |
|
117 | 117 | { |
118 | - if(mrc_get_level($user, $planetrow, $unit_id) > 0 && get_unit_param($unit_id)) |
|
118 | + if (mrc_get_level($user, $planetrow, $unit_id) > 0 && get_unit_param($unit_id)) |
|
119 | 119 | { |
120 | 120 | $level_plain = mrc_get_level($user, $planetrow, $unit_id, false, true); |
121 | 121 | $template->assign_block_vars('production', array( |
@@ -30,7 +30,7 @@ |
||
30 | 30 | |
31 | 31 | $this->target_message = "{$lang['sys_mess_spy_enemy_fleet']} {$this->src_planet['name']} " . uni_render_coordinates_href($this->src_planet, '', 3); |
32 | 32 | $this->target_message .= " {$lang['sys_mess_spy_seen_at']} {$this->dst_planet['name']} " . uni_render_coordinates($this->dst_planet); |
33 | - if($this->missionReport->isSpyDetected()) { |
|
33 | + if ($this->missionReport->isSpyDetected()) { |
|
34 | 34 | $this->target_message .= "<br />{$lang['sys_mess_spy_destroyed_enemy']}"; |
35 | 35 | } |
36 | 36 |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | $groups[get_unit_param($unitId, P_UNIT_TYPE)][$unitId] = $unitAmount; |
26 | 26 | } |
27 | 27 | |
28 | - foreach(static::ALLOWED_UNITS as $groupId) { |
|
29 | - if(empty($groups[$groupId])) { |
|
28 | + foreach (static::ALLOWED_UNITS as $groupId) { |
|
29 | + if (empty($groups[$groupId])) { |
|
30 | 30 | continue; |
31 | 31 | } |
32 | 32 | |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | 'NAME' => $lang['tech'][$groupId], |
36 | 36 | ]); |
37 | 37 | |
38 | - foreach($general->getGroupsById($groupId) as $unitId) { |
|
39 | - if((!isset($groups[$groupId][$unitId]) || floor($groups[$groupId][$unitId]) < 1) && $unitId != RES_ENERGY) { |
|
38 | + foreach ($general->getGroupsById($groupId) as $unitId) { |
|
39 | + if ((!isset($groups[$groupId][$unitId]) || floor($groups[$groupId][$unitId]) < 1) && $unitId != RES_ENERGY) { |
|
40 | 40 | continue; |
41 | 41 | } |
42 | 42 |
@@ -15,8 +15,7 @@ discard block |
||
15 | 15 | 1.5 - copyright (c) 2010-2011 by Gorlum for http://supernova.ws |
16 | 16 | [+] SuperMassMailing - authlevel=3 player can send messages to whole server ('*' as $owners) |
17 | 17 | */ |
18 | -function msg_ali_send($message, $subject, $ally_rank_id = 0, $ally_id = 0) |
|
19 | -{ |
|
18 | +function msg_ali_send($message, $subject, $ally_rank_id = 0, $ally_id = 0) { |
|
20 | 19 | global $user; |
21 | 20 | |
22 | 21 | $ally_id = $ally_id ? $ally_id : $user['ally_id']; |
@@ -49,8 +48,7 @@ discard block |
||
49 | 48 | * @param bool $force |
50 | 49 | * @param bool $json |
51 | 50 | */ |
52 | -function msg_send_simple_message($owners, $sender, $timestamp, $message_type, $from, $subject, $text, $escaped = STRING_NEED_ESCAPING, $force = false, $json = false) |
|
53 | -{ |
|
51 | +function msg_send_simple_message($owners, $sender, $timestamp, $message_type, $from, $subject, $text, $escaped = STRING_NEED_ESCAPING, $force = false, $json = false) { |
|
54 | 52 | global $config, $user, $sn_message_class_list; |
55 | 53 | |
56 | 54 | if(!$owners) |
@@ -91,8 +89,7 @@ discard block |
||
91 | 89 | // TODO Добавить $sender - рассылка может быть и от кого-то |
92 | 90 | db_message_insert_all($message_type, $from, $subject, $text); |
93 | 91 | $owners = []; |
94 | - } |
|
95 | - else |
|
92 | + } else |
|
96 | 93 | { |
97 | 94 | $insert_values = []; |
98 | 95 | $insert_template = "('%u'," . str_replace('%', '%%', " '{$sender}', '{$timestamp}', '{$message_type}', '{$from}', '{$subject}', '{$text}', '" . intval($json) . "')"); |
@@ -102,8 +99,7 @@ discard block |
||
102 | 99 | if($user['id'] != $owner) |
103 | 100 | { |
104 | 101 | $owner_row = db_user_by_id($owner); |
105 | - } |
|
106 | - else |
|
102 | + } else |
|
107 | 103 | { |
108 | 104 | $owner_row = $user; |
109 | 105 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | "ally_id = '{$ally_id}'" . ($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''), |
27 | 27 | false, 'id, username'); |
28 | 28 | // while ($u = db_fetch($query)) |
29 | - foreach($query as $u) |
|
29 | + foreach ($query as $u) |
|
30 | 30 | { |
31 | 31 | $sendList[] = $u['id']; |
32 | 32 | $list .= "<br>{$u['username']} "; |
@@ -53,19 +53,19 @@ discard block |
||
53 | 53 | { |
54 | 54 | global $config, $user, $sn_message_class_list; |
55 | 55 | |
56 | - if(!$owners) |
|
56 | + if (!$owners) |
|
57 | 57 | { |
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | 61 | $timestamp = $timestamp ? $timestamp : SN_TIME_NOW; |
62 | 62 | $sender = intval($sender); |
63 | - if(!is_array($owners)) |
|
63 | + if (!is_array($owners)) |
|
64 | 64 | { |
65 | 65 | $owners = array($owners); |
66 | 66 | } |
67 | 67 | |
68 | - if($escaped == STRING_NEED_ESCAPING) |
|
68 | + if ($escaped == STRING_NEED_ESCAPING) |
|
69 | 69 | { |
70 | 70 | $from = db_escape($from); |
71 | 71 | $subject = db_escape($subject); |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | |
82 | 82 | $message_class_name_total = $sn_message_class_list[MSG_TYPE_NEW]['name']; |
83 | 83 | |
84 | - if($owners[0] == '*') |
|
84 | + if ($owners[0] == '*') |
|
85 | 85 | { |
86 | - if($user['authlevel'] < 3) |
|
86 | + if ($user['authlevel'] < 3) |
|
87 | 87 | { |
88 | 88 | return false; |
89 | 89 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | foreach ($owners as $owner) |
101 | 101 | { |
102 | - if($user['id'] != $owner) |
|
102 | + if ($user['id'] != $owner) |
|
103 | 103 | { |
104 | 104 | $owner_row = db_user_by_id($owner); |
105 | 105 | } |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | } |
110 | 110 | sys_user_options_unpack($owner_row); |
111 | 111 | |
112 | - if($force || !$message_class_switchable || $owner_row["opt_{$message_class_name}"]) |
|
112 | + if ($force || !$message_class_switchable || $owner_row["opt_{$message_class_name}"]) |
|
113 | 113 | { |
114 | 114 | $insert_values[] = sprintf($insert_template, $owner); |
115 | 115 | } |
116 | 116 | |
117 | - if($message_class_email && $config->game_email_pm && $owner_row["opt_email_{$message_class_name}"]) |
|
117 | + if ($message_class_email && $config->game_email_pm && $owner_row["opt_email_{$message_class_name}"]) |
|
118 | 118 | { |
119 | - if($message_type == MSG_TYPE_SPY) { |
|
119 | + if ($message_type == MSG_TYPE_SPY) { |
|
120 | 120 | @$result = mymail($owner_row['email'], $subject, SN::$lang['sys_spy_activity'], '', true); |
121 | 121 | } else { |
122 | 122 | @$result = mymail($owner_row['email'], $subject, $text_unescaped, '', true); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | - if(empty($insert_values)) |
|
127 | + if (empty($insert_values)) |
|
128 | 128 | { |
129 | 129 | return; |
130 | 130 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | } |
135 | 135 | db_user_list_set_mass_mail($owners, "`{$message_class_name}` = `{$message_class_name}` + 1, `{$message_class_name_total}` = `{$message_class_name_total}` + 1"); |
136 | 136 | |
137 | - if(in_array($user['id'], $owners) || $owners[0] == '*') |
|
137 | + if (in_array($user['id'], $owners) || $owners[0] == '*') |
|
138 | 138 | { |
139 | 139 | $user[$message_class_name]++; |
140 | 140 | $user[$message_class_name_total]++; |
@@ -223,7 +223,7 @@ |
||
223 | 223 | 'factor' => 1, |
224 | 224 | ), |
225 | 225 | P_UNIT_PRODUCTION => array( |
226 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) { return ($planet_row["temp_max"] / 4 + 20) * $level * (0.1 * $production_factor); }, |
|
226 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) { return ($planet_row["temp_max"] / 4 + 20) * $level * (0.1 * $production_factor); }, |
|
227 | 227 | ), |
228 | 228 | P_MINING_IS_MANAGED => true, |
229 | 229 |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | 'factor' => 1.5, |
17 | 17 | ), |
18 | 18 | P_UNIT_PRODUCTION => array( |
19 | - RES_METAL => function ($level, $production_factor, $user, $planet_row) { return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
20 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) { return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
19 | + RES_METAL => function($level, $production_factor, $user, $planet_row) { return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
20 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) { return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
21 | 21 | ), |
22 | 22 | P_MINING_IS_MANAGED => true, |
23 | 23 | ), |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | 'factor' => 1.6, |
35 | 35 | ), |
36 | 36 | P_UNIT_PRODUCTION => array( |
37 | - RES_CRYSTAL => function ($level, $production_factor, $user, $planet_row) { return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
38 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) { return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
37 | + RES_CRYSTAL => function($level, $production_factor, $user, $planet_row) { return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
38 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) { return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
39 | 39 | ), |
40 | 40 | P_MINING_IS_MANAGED => true, |
41 | 41 | ), |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | 'factor' => 1.5, |
53 | 53 | ), |
54 | 54 | P_UNIT_PRODUCTION => array( |
55 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) { return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28); }, |
|
56 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) { return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
55 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) { return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28); }, |
|
56 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) { return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
57 | 57 | ), |
58 | 58 | P_MINING_IS_MANAGED => true, |
59 | 59 | ), |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | 'factor' => 1.5, |
71 | 71 | ), |
72 | 72 | P_UNIT_PRODUCTION => array( |
73 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) { return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
73 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) { return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
74 | 74 | ), |
75 | 75 | P_MINING_IS_MANAGED => true, |
76 | 76 | ), |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | 'factor' => 1.8, |
89 | 89 | ), |
90 | 90 | P_UNIT_PRODUCTION => array( |
91 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) { return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
92 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) { return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, "", TECH_ENERGY), $level) * (0.1 * $production_factor); }, |
|
91 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) { return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
92 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) { return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, "", TECH_ENERGY), $level) * (0.1 * $production_factor); }, |
|
93 | 93 | ), |
94 | 94 | P_MINING_IS_MANAGED => true, |
95 | 95 | ), |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | 'factor' => 2, |
107 | 107 | ), |
108 | 108 | 'storage' => array( |
109 | - RES_METAL => function ($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
109 | + RES_METAL => function($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
110 | 110 | ), |
111 | 111 | ), |
112 | 112 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | 'factor' => 2, |
123 | 123 | ), |
124 | 124 | 'storage' => array( |
125 | - RES_CRYSTAL => function ($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
125 | + RES_CRYSTAL => function($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
126 | 126 | ), |
127 | 127 | ), |
128 | 128 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | 'factor' => 2, |
139 | 139 | ), |
140 | 140 | 'storage' => array( |
141 | - RES_DEUTERIUM => function ($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
141 | + RES_DEUTERIUM => function($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
142 | 142 | ), |
143 | 143 | ), |
144 | 144 |
@@ -52,7 +52,7 @@ |
||
52 | 52 | //print("<br />CACHE CLEAR {$cache_id} " . ($hard ? 'HARD' : 'SOFT') . "<br />"); |
53 | 53 | if ($hard && !empty(_SnCacheInternal::$data[$location_type])) { |
54 | 54 | // Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях |
55 | - array_walk(_SnCacheInternal::$data[$location_type], function (&$item) { $item = null; }); |
|
55 | + array_walk(_SnCacheInternal::$data[$location_type], function(&$item) { $item = null; }); |
|
56 | 56 | } |
57 | 57 | _SnCacheInternal::$locator[$location_type] = []; |
58 | 58 | _SnCacheInternal::$queries[$location_type] = []; |
@@ -139,11 +139,13 @@ |
||
139 | 139 | $error_backtrace['locks'] = _SnCacheInternal::$locks; |
140 | 140 | $error_backtrace['cSN_data'] = _SnCacheInternal::$data; |
141 | 141 | foreach($error_backtrace['cSN_data'] as &$location) { |
142 | - foreach($location as $location_id => &$location_data) // $location_data = $location_id; |
|
142 | + foreach($location as $location_id => &$location_data) { |
|
143 | + // $location_data = $location_id; |
|
143 | 144 | { |
144 | 145 | $location_data = isset($location_data['username']) ? $location_data['username'] : |
145 | 146 | (isset($location_data['name']) ? $location_data['name'] : $location_id); |
146 | 147 | } |
148 | + } |
|
147 | 149 | } |
148 | 150 | } |
149 | 151 |
@@ -80,7 +80,7 @@ |
||
80 | 80 | |
81 | 81 | $result = array(); |
82 | 82 | $transaction_id = SN::db_transaction_check(false) ? SN::$transaction_id : SN::$transaction_id++; |
83 | - $result[] = "tID {$transaction_id}"; |
|
83 | + $result[] = "tid {$transaction_id}"; |
|
84 | 84 | foreach($backtrace as $a_trace) { |
85 | 85 | if(in_array($a_trace['function'], $exclude_functions)) { |
86 | 86 | continue; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * que esperabas!!! soy newbie!!! D':< |
25 | 25 | */ |
26 | 26 | |
27 | -if(!defined('INSIDE')) { |
|
27 | +if (!defined('INSIDE')) { |
|
28 | 28 | die("attemp hacking"); |
29 | 29 | } |
30 | 30 | |
@@ -37,16 +37,16 @@ discard block |
||
37 | 37 | function log_file($message, $ident_change = 0) { |
38 | 38 | static $ident = 0; |
39 | 39 | |
40 | - if(!defined('SN_DEBUG_LOG')) { |
|
40 | + if (!defined('SN_DEBUG_LOG')) { |
|
41 | 41 | return; |
42 | 42 | } |
43 | 43 | |
44 | - if($this->log_file_handler === null) { |
|
44 | + if ($this->log_file_handler === null) { |
|
45 | 45 | $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+'); |
46 | 46 | @fwrite($this->log_file_handler, "\r\n\r\n"); |
47 | 47 | } |
48 | 48 | $ident_change < 0 ? $ident += $ident_change * 2 : false; |
49 | - if($this->log_file_handler) { |
|
49 | + if ($this->log_file_handler) { |
|
50 | 50 | @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n"); |
51 | 51 | } |
52 | 52 | $ident_change > 0 ? $ident += $ident_change * 2 : false; |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | $result = array(); |
82 | 82 | $transaction_id = SN::db_transaction_check(false) ? SN::$transaction_id : SN::$transaction_id++; |
83 | 83 | $result[] = "tID {$transaction_id}"; |
84 | - foreach($backtrace as $a_trace) { |
|
85 | - if(in_array($a_trace['function'], $exclude_functions)) { |
|
84 | + foreach ($backtrace as $a_trace) { |
|
85 | + if (in_array($a_trace['function'], $exclude_functions)) { |
|
86 | 86 | continue; |
87 | 87 | } |
88 | 88 | $function = |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $line = !empty($a_trace['line']) ? $a_trace['line'] : '_UNDEFINED_'; |
100 | 100 | $result[] = "{$function} - '{$file}' Line {$line}"; |
101 | 101 | |
102 | - if(!$long_comment) { |
|
102 | + if (!$long_comment) { |
|
103 | 103 | break; |
104 | 104 | } |
105 | 105 | } |
@@ -108,26 +108,26 @@ discard block |
||
108 | 108 | } |
109 | 109 | |
110 | 110 | function dump($dump = false, $force_base = false, $deadlock = false) { |
111 | - if($dump === false) { |
|
111 | + if ($dump === false) { |
|
112 | 112 | return; |
113 | 113 | } |
114 | 114 | |
115 | 115 | $error_backtrace = array(); |
116 | 116 | $base_dump = false; |
117 | 117 | |
118 | - if($force_base === true) { |
|
118 | + if ($force_base === true) { |
|
119 | 119 | $base_dump = true; |
120 | 120 | } |
121 | 121 | |
122 | - if($dump === true) { |
|
122 | + if ($dump === true) { |
|
123 | 123 | $base_dump = true; |
124 | 124 | } else { |
125 | - if(!is_array($dump)) { |
|
125 | + if (!is_array($dump)) { |
|
126 | 126 | $dump = array('var' => $dump); |
127 | 127 | } |
128 | 128 | |
129 | - foreach($dump as $dump_var_name => $dump_var) { |
|
130 | - if($dump_var_name == 'base_dump') { |
|
129 | + foreach ($dump as $dump_var_name => $dump_var) { |
|
130 | + if ($dump_var_name == 'base_dump') { |
|
131 | 131 | $base_dump = $dump_var; |
132 | 132 | } else { |
133 | 133 | $error_backtrace[$dump_var_name] = $dump_var; |
@@ -135,24 +135,23 @@ discard block |
||
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | - if($deadlock && ($q = db_fetch(SN::$db->mysql_get_innodb_status()))) { |
|
138 | + if ($deadlock && ($q = db_fetch(SN::$db->mysql_get_innodb_status()))) { |
|
139 | 139 | $error_backtrace['deadlock'] = explode("\n", $q['Status']); |
140 | 140 | $error_backtrace['locks'] = _SnCacheInternal::$locks; |
141 | 141 | $error_backtrace['cSN_data'] = _SnCacheInternal::$data; |
142 | - foreach($error_backtrace['cSN_data'] as &$location) { |
|
143 | - foreach($location as $location_id => &$location_data) // $location_data = $location_id; |
|
142 | + foreach ($error_backtrace['cSN_data'] as &$location) { |
|
143 | + foreach ($location as $location_id => &$location_data) // $location_data = $location_id; |
|
144 | 144 | { |
145 | - $location_data = isset($location_data['username']) ? $location_data['username'] : |
|
146 | - (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
145 | + $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
147 | 146 | } |
148 | 147 | } |
149 | 148 | } |
150 | 149 | |
151 | - if($base_dump) { |
|
152 | - if(!is_array($this->log_array) || empty($this->log_array)) { |
|
150 | + if ($base_dump) { |
|
151 | + if (!is_array($this->log_array) || empty($this->log_array)) { |
|
153 | 152 | $this->log_array = []; |
154 | 153 | } else { |
155 | - foreach($this->log_array as $log) { |
|
154 | + foreach ($this->log_array as $log) { |
|
156 | 155 | $error_backtrace['queries'][] = $log; |
157 | 156 | } |
158 | 157 | } |
@@ -164,17 +163,17 @@ discard block |
||
164 | 163 | // Converting object instances to object names |
165 | 164 | |
166 | 165 | foreach ($error_backtrace['backtrace'] as &$backtrace) { |
167 | - if(is_object($backtrace['object'])) { |
|
166 | + if (is_object($backtrace['object'])) { |
|
168 | 167 | $backtrace['object'] = get_class($backtrace['object']); |
169 | 168 | } |
170 | 169 | |
171 | - if(empty($backtrace['args'])) { |
|
170 | + if (empty($backtrace['args'])) { |
|
172 | 171 | continue; |
173 | 172 | } |
174 | 173 | |
175 | 174 | // Doing same conversion for backtrace params |
176 | - foreach($backtrace['args'] as &$arg) { |
|
177 | - if(is_object($arg)) { |
|
175 | + foreach ($backtrace['args'] as &$arg) { |
|
176 | + if (is_object($arg)) { |
|
178 | 177 | $arg = 'object::' . get_class($arg); |
179 | 178 | } |
180 | 179 | } |
@@ -203,14 +202,14 @@ discard block |
||
203 | 202 | function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) { |
204 | 203 | global $config, $sys_stop_log_hit, $lang, $sys_log_disabled, $user; |
205 | 204 | |
206 | - if(empty(SN::$db->connected)) { |
|
205 | + if (empty(SN::$db->connected)) { |
|
207 | 206 | // TODO - писать ошибку в файл |
208 | 207 | die('SQL server currently unavailable. Please contact Administration...'); |
209 | 208 | } |
210 | 209 | |
211 | 210 | sn_db_transaction_rollback(); |
212 | 211 | |
213 | - if(SN::$config->debug == 1) { |
|
212 | + if (SN::$config->debug == 1) { |
|
214 | 213 | echo "<h2>{$title}</h2><br><font color=red>" . htmlspecialchars($message) . "</font><br><hr>"; |
215 | 214 | echo "<table>{$this->log}</table>"; |
216 | 215 | } |
@@ -220,7 +219,7 @@ discard block |
||
220 | 219 | $error_text = db_escape($message); |
221 | 220 | $error_backtrace = $this->dump($dump, true, strpos($message, 'Deadlock') !== false); |
222 | 221 | |
223 | - if(!$sys_log_disabled) { |
|
222 | + if (!$sys_log_disabled) { |
|
224 | 223 | $query = "INSERT INTO `{{logs}}` SET |
225 | 224 | `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "', |
226 | 225 | `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
@@ -238,7 +237,7 @@ discard block |
||
238 | 237 | ob_start(); |
239 | 238 | print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}"); |
240 | 239 | |
241 | - foreach($error_backtrace as $name => $value) { |
|
240 | + foreach ($error_backtrace as $name => $value) { |
|
242 | 241 | print('<hr>'); |
243 | 242 | pdump($value, $name); |
244 | 243 | } |
@@ -250,14 +249,14 @@ discard block |
||
250 | 249 | function warning($message, $title = 'System Message', $log_code = 300, $dump = false) { |
251 | 250 | global $user, $lang, $sys_log_disabled; |
252 | 251 | |
253 | - if(empty(SN::$db->connected)) { |
|
252 | + if (empty(SN::$db->connected)) { |
|
254 | 253 | // TODO - писать ошибку в файл |
255 | 254 | die('SQL server currently unavailable. Please contact Administration...'); |
256 | 255 | } |
257 | 256 | |
258 | 257 | $error_backtrace = $this->dump($dump, false); |
259 | 258 | |
260 | - if(!$sys_log_disabled) { |
|
259 | + if (!$sys_log_disabled) { |
|
261 | 260 | $query = "INSERT INTO `{{logs}}` SET |
262 | 261 | `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "', |
263 | 262 | `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
@@ -275,11 +274,11 @@ discard block |
||
275 | 274 | // Dump variables nicer then var_dump() |
276 | 275 | |
277 | 276 | function dump($value, $varname = null, $level = 0, $dumper = '') { |
278 | - if(isset($varname)) { |
|
277 | + if (isset($varname)) { |
|
279 | 278 | $varname .= " = "; |
280 | 279 | } |
281 | 280 | |
282 | - if($level == -1) { |
|
281 | + if ($level == -1) { |
|
283 | 282 | $trans[' '] = '∴'; |
284 | 283 | $trans["\t"] = '⇒'; |
285 | 284 | $trans["\n"] = '¶;'; |
@@ -288,7 +287,7 @@ discard block |
||
288 | 287 | |
289 | 288 | return strtr(htmlspecialchars($value), $trans); |
290 | 289 | } |
291 | - if($level == 0) { |
|
290 | + if ($level == 0) { |
|
292 | 291 | // $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname; |
293 | 292 | $dumper = mt_rand(10, 99) . '|' . $varname; |
294 | 293 | } |
@@ -296,22 +295,22 @@ discard block |
||
296 | 295 | $type = gettype($value); |
297 | 296 | $dumper .= $type; |
298 | 297 | |
299 | - if($type == 'string') { |
|
298 | + if ($type == 'string') { |
|
300 | 299 | $dumper .= '(' . strlen($value) . ')'; |
301 | 300 | $value = dump($value, '', -1); |
302 | - } elseif($type == 'boolean') { |
|
301 | + } elseif ($type == 'boolean') { |
|
303 | 302 | $value = ($value ? 'true' : 'false'); |
304 | - } elseif($type == 'object') { |
|
303 | + } elseif ($type == 'object') { |
|
305 | 304 | $props = get_class_vars(get_class($value)); |
306 | 305 | $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>'; |
307 | - foreach($props as $key => $val) { |
|
306 | + foreach ($props as $key => $val) { |
|
308 | 307 | $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => '; |
309 | 308 | $dumper .= dump($value->$key, '', $level + 1); |
310 | 309 | } |
311 | 310 | $value = ''; |
312 | - } elseif($type == 'array') { |
|
311 | + } elseif ($type == 'array') { |
|
313 | 312 | $dumper .= '(' . count($value) . ')'; |
314 | - foreach($value as $key => $val) { |
|
313 | + foreach ($value as $key => $val) { |
|
315 | 314 | $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => '; |
316 | 315 | $dumper .= dump($val, '', $level + 1); |
317 | 316 | } |
@@ -331,7 +330,7 @@ discard block |
||
331 | 330 | // $backtrace = $backtrace[1]; |
332 | 331 | |
333 | 332 | $caller = ''; |
334 | - if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
333 | + if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
335 | 334 | $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') . |
336 | 335 | (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') . |
337 | 336 | $backtrace[1]['function'] . |
@@ -358,7 +357,7 @@ discard block |
||
358 | 357 | } |
359 | 358 | |
360 | 359 | function pr($prePrint = false) { |
361 | - if($prePrint) { |
|
360 | + if ($prePrint) { |
|
362 | 361 | print("<br>"); |
363 | 362 | } |
364 | 363 | print(mt_rand() . "<br>"); |
@@ -368,7 +367,7 @@ discard block |
||
368 | 367 | global $_PRINT_COUNT_VALUE; |
369 | 368 | $_PRINT_COUNT_VALUE++; |
370 | 369 | |
371 | - if($prePrint) { |
|
370 | + if ($prePrint) { |
|
372 | 371 | print("<br>"); |
373 | 372 | } |
374 | 373 | print($_PRINT_COUNT_VALUE . "<br>"); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | "SELECT `id` AS `ID`, `username` AS `NAME`, `ally_name` AS `ALLY`, `total_points` AS `STAT_POINTS`, |
181 | 181 | `onlinetime` AS `ACTIVITY` |
182 | 182 | FROM `{{users}}` |
183 | - WHERE `onlinetime` >= ". (SN_TIME_NOW - $config->game_users_online_timeout) ." ORDER BY user_as_ally, `". $TypeSort ."` ASC;"); |
|
183 | + WHERE `onlinetime` >= ". (SN_TIME_NOW - $config->game_users_online_timeout) . " ORDER BY user_as_ally, `" . $TypeSort . "` ASC;"); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | return doquery("SELECT u.*, COUNT(r.id) AS referral_count, SUM(r.dark_matter) AS referral_dm FROM {{users}} as u |
196 | 196 | LEFT JOIN {{referrals}} as r on r.id_partner = u.id |
197 | 197 | WHERE" . |
198 | - ($online ? " `onlinetime` >= ". (SN_TIME_NOW - $config->game_users_online_timeout) : ' user_as_ally IS NULL') . |
|
198 | + ($online ? " `onlinetime` >= " . (SN_TIME_NOW - $config->game_users_online_timeout) : ' user_as_ally IS NULL') . |
|
199 | 199 | " GROUP BY u.id |
200 | 200 | ORDER BY user_as_ally, {$sort} ASC"); |
201 | 201 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | !is_array($user_id_list) ? $user_id_list = array($user_id_list) : false; |
212 | 212 | |
213 | 213 | $user_list = array(); |
214 | - foreach($user_id_list as $user_id_unsafe) { |
|
214 | + foreach ($user_id_list as $user_id_unsafe) { |
|
215 | 215 | $user = db_user_by_id($user_id_unsafe); |
216 | 216 | !empty($user) ? $user_list[$user_id_unsafe] = $user : false; |
217 | 217 | } |