@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if((!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) && (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)) { |
|
3 | +if ((!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) && (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)) { |
|
4 | 4 | $debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403); |
5 | 5 | } |
6 | 6 | |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | |
28 | 28 | // $dm_db_name = pname_resource_name(RES_DARK_MATTER); |
29 | 29 | $exchangeTo = in_array($exchangeTo = sys_get_param_int('exchangeTo'), sn_get_groups('resources_trader')) ? $exchangeTo : 0; |
30 | - if($exchangeTo && is_array($tradeList = $_POST['spend'])) { |
|
30 | + if ($exchangeTo && is_array($tradeList = $_POST['spend'])) { |
|
31 | 31 | $value = 0; |
32 | 32 | $qry = array(); |
33 | 33 | |
34 | 34 | sn_db_transaction_start(); |
35 | - if($planetrow['id_owner']) { |
|
35 | + if ($planetrow['id_owner']) { |
|
36 | 36 | $global_data = sys_o_get_updated($user, $planetrow, SN_TIME_NOW); |
37 | 37 | $planetrow = $global_data['planet']; |
38 | 38 | } |
@@ -41,27 +41,27 @@ discard block |
||
41 | 41 | $user = db_user_by_id($user['id'], true); |
42 | 42 | } |
43 | 43 | |
44 | - foreach(sn_get_groups('resources_trader') as $resource_id) { |
|
44 | + foreach (sn_get_groups('resources_trader') as $resource_id) { |
|
45 | 45 | $amount = floatval($tradeList[$resource_id]); |
46 | - if($amount < 0) { |
|
46 | + if ($amount < 0) { |
|
47 | 47 | $debug->error('Trying to supply negative resource amount on Black Market Page', 'Hack Attempt', 305); |
48 | 48 | } |
49 | 49 | |
50 | - if($resource_id == RES_DARK_MATTER && $exchangeTo == RES_DARK_MATTER) { |
|
50 | + if ($resource_id == RES_DARK_MATTER && $exchangeTo == RES_DARK_MATTER) { |
|
51 | 51 | continue; |
52 | 52 | } |
53 | 53 | |
54 | 54 | $resource_db_name = pname_resource_name($resource_id); |
55 | - if($exchangeTo == RES_DARK_MATTER) { |
|
55 | + if ($exchangeTo == RES_DARK_MATTER) { |
|
56 | 56 | $sign = '+'; |
57 | 57 | $amount = floor($tradeList[RES_DARK_MATTER] / 3 * $rates[RES_DARK_MATTER] / $rates[$resource_id]); |
58 | 58 | $value += $amount; |
59 | 59 | } else { |
60 | 60 | $value += floor($amount * $rates[$resource_id] / $rates[$exchangeTo]); |
61 | - if($resource_id == RES_DARK_MATTER) { |
|
61 | + if ($resource_id == RES_DARK_MATTER) { |
|
62 | 62 | $amount = 0; |
63 | 63 | } else { |
64 | - if(mrc_get_level($user, $planetrow, $resource_id, true) < $amount) { |
|
64 | + if (mrc_get_level($user, $planetrow, $resource_id, true) < $amount) { |
|
65 | 65 | $intError = MARKET_NO_RESOURCES; |
66 | 66 | break; |
67 | 67 | } |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | - if($amount) { |
|
73 | + if ($amount) { |
|
74 | 74 | $qry[] = "`{$resource_db_name}` = `{$resource_db_name}` {$sign} {$amount}"; |
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
78 | - if($exchangeTo != RES_DARK_MATTER) { |
|
78 | + if ($exchangeTo != RES_DARK_MATTER) { |
|
79 | 79 | $amount = floor($value); |
80 | 80 | $exchange_to_db_name = pname_resource_name($exchangeTo); |
81 | 81 | $qry[] = "`{$exchange_to_db_name}` = `{$exchange_to_db_name}` + {$amount}"; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $intError = $value <= 0 ? MARKET_ZERO_DEAL : $intError; |
87 | 87 | $intError = mrc_get_level($user, null, RES_DARK_MATTER) < $operation_cost ? MARKET_NO_DM : $intError; |
88 | 88 | |
89 | - if($intError == MARKET_DEAL) { |
|
89 | + if ($intError == MARKET_DEAL) { |
|
90 | 90 | $qry = implode(', ', $qry); |
91 | 91 | $table = $planetrow['id_owner'] ? 'planets' : 'users'; |
92 | 92 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | 'EXCHANGE_TO_RESOURCE_ID' => $exchangeTo, |
112 | 112 | )); |
113 | 113 | |
114 | - foreach(sn_get_groups('resources_trader') as $resource_id) { |
|
115 | - if($resource_id == RES_DARK_MATTER) { |
|
114 | + foreach (sn_get_groups('resources_trader') as $resource_id) { |
|
115 | + if ($resource_id == RES_DARK_MATTER) { |
|
116 | 116 | $amount = floor(mrc_get_level($user, null, RES_DARK_MATTER) - $config->rpg_cost_trader); |
117 | 117 | } else { |
118 | 118 | $amount = floor(mrc_get_level($user, $planetrow, $resource_id)); |
@@ -35,8 +35,7 @@ |
||
35 | 35 | if($planetrow['id_owner']) { |
36 | 36 | $global_data = sys_o_get_updated($user, $planetrow, SN_TIME_NOW); |
37 | 37 | $planetrow = $global_data['planet']; |
38 | - } |
|
39 | - else { |
|
38 | + } else { |
|
40 | 39 | // Locking user record |
41 | 40 | $user = db_user_by_id($user['id'], true); |
42 | 41 | } |
@@ -4,18 +4,18 @@ discard block |
||
4 | 4 | // @version 1.0 |
5 | 5 | // @copyright 2008 by Chlorel for XNova |
6 | 6 | |
7 | -if(SN_IN_FLEET !== true) { |
|
7 | +if (SN_IN_FLEET !== true) { |
|
8 | 8 | $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
9 | 9 | } |
10 | 10 | |
11 | 11 | $template = gettemplate('fleet1', true); |
12 | 12 | |
13 | 13 | $ships = sys_get_param('ships', array()); |
14 | -if(!is_array($ships)) { |
|
14 | +if (!is_array($ships)) { |
|
15 | 15 | $ships = array(); |
16 | 16 | } |
17 | 17 | |
18 | -foreach(array(PT_PLANET, PT_DEBRIS, PT_MOON) as $possible_planet_type_id) { |
|
18 | +foreach (array(PT_PLANET, PT_DEBRIS, PT_MOON) as $possible_planet_type_id) { |
|
19 | 19 | $template->assign_block_vars('possible_planet_type_id', array( |
20 | 20 | 'ID' => $possible_planet_type_id, |
21 | 21 | 'NAME' => $lang['sys_planet_type_sh'][$possible_planet_type_id], |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | 'START_NAME' => $planetrow['name'], |
29 | 29 | ); |
30 | 30 | |
31 | -if(!empty($TargetPlanet)) { |
|
31 | +if (!empty($TargetPlanet)) { |
|
32 | 32 | $template_route += array( |
33 | 33 | 'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$TargetPlanet['planet_type']], |
34 | 34 | 'END_COORDS' => uni_render_coordinates($TargetPlanet), |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | $template->assign_block_vars('fleets', $template_route); |
40 | 40 | |
41 | 41 | $sn_groups_fleet = sn_get_groups('fleet'); |
42 | -foreach($ships as $ship_id => $ship_count) { |
|
43 | - if(in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
42 | +foreach ($ships as $ship_id => $ship_count) { |
|
43 | + if (in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
44 | 44 | $ship_info = get_unit_param($ship_id); |
45 | - if($ship_count > mrc_get_level($user, $planetrow, $ship_id, false, true)) { |
|
45 | + if ($ship_count > mrc_get_level($user, $planetrow, $ship_id, false, true)) { |
|
46 | 46 | $page .= $lang['fl_noenought']; |
47 | 47 | } else { |
48 | 48 | $fleet['fleetarray'][$ship_id] = $ship_count; |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | -if(empty($fleet['fleetarray'])) { |
|
64 | +if (empty($fleet['fleetarray'])) { |
|
65 | 65 | message($lang['fl_err_no_ships'], $lang['fl_error'], 'fleet' . DOT_PHP_EX, 5); |
66 | 66 | } |
67 | 67 | |
68 | 68 | // Building list of shortcuts |
69 | 69 | $query = doquery("SELECT * FROM {{notes}} WHERE `owner` = {$user['id']} AND `galaxy` <> 0 AND `system` <> 0 AND `planet` <> 0 ORDER BY `priority` DESC, `galaxy`, `system`, `planet`, `planet_type`;"); |
70 | -while($shortcut = db_fetch($query)) { |
|
70 | +while ($shortcut = db_fetch($query)) { |
|
71 | 71 | $template->assign_block_vars('shortcut', array( |
72 | 72 | 'NAME' => $shortcut['title'], |
73 | 73 | 'GALAXY' => $shortcut['galaxy'], |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | // Building list of own planets & moons |
84 | -$colonies = db_planet_list_sorted ( $user ); |
|
85 | -if(count($colonies) > 1) { |
|
84 | +$colonies = db_planet_list_sorted($user); |
|
85 | +if (count($colonies) > 1) { |
|
86 | 86 | // while($row = db_fetch($colonies)) |
87 | - foreach($colonies as $row) { |
|
87 | + foreach ($colonies as $row) { |
|
88 | 88 | $template->assign_block_vars('colonies', array( |
89 | 89 | 'NAME' => $row['name'], |
90 | 90 | 'GALAXY' => $row['galaxy'], |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | //ACS Start |
100 | 100 | //Need to look for acs attacks. |
101 | 101 | $aks_madnessred = doquery('SELECT * FROM {{aks}};'); |
102 | -while($row = db_fetch($aks_madnessred)) { |
|
102 | +while ($row = db_fetch($aks_madnessred)) { |
|
103 | 103 | $members = explode(',', $row['eingeladen']); |
104 | - foreach($members as $a => $b) { |
|
104 | + foreach ($members as $a => $b) { |
|
105 | 105 | if ($b == $user['id']) { |
106 | 106 | $template->assign_block_vars('acss', array( |
107 | 107 | 'ID' => $row['id'], |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | print($round); |
28 | 28 | print('<table border=1>'); |
29 | 29 | print('<tr align="left">'); |
30 | - foreach($header as $key => $value) |
|
30 | + foreach ($header as $key => $value) |
|
31 | 31 | { |
32 | - if(is_array($value)) |
|
32 | + if (is_array($value)) |
|
33 | 33 | { |
34 | 34 | continue; |
35 | 35 | } |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | ); |
62 | 62 | |
63 | 63 | print('<tr align="right">'); |
64 | - foreach($debug_unit_crossfire_result as $key => $value) |
|
64 | + foreach ($debug_unit_crossfire_result as $key => $value) |
|
65 | 65 | { |
66 | - if(is_array($value)) |
|
66 | + if (is_array($value)) |
|
67 | 67 | { |
68 | 68 | continue; |
69 | 69 | } |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | !is_array($offset) ? $offset = array($offset) : false; |
39 | 39 | |
40 | 40 | $current_leaf = $this->__get(reset($offset)); |
41 | - while(($leaf_index = next($offset)) !== false) { |
|
42 | - if(!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) { |
|
41 | + while (($leaf_index = next($offset)) !== false) { |
|
42 | + if (!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) { |
|
43 | 43 | unset($current_leaf); |
44 | 44 | break; |
45 | 45 | } |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | |
65 | 65 | !is_array($offset) ? $offset = array($offset) : false; |
66 | 66 | |
67 | - if($this->offsetExists($offset)) { |
|
67 | + if ($this->offsetExists($offset)) { |
|
68 | 68 | $result = $this->__get(reset($offset)); |
69 | - while(($leaf_index = next($offset)) !== false) { |
|
69 | + while (($leaf_index = next($offset)) !== false) { |
|
70 | 70 | $result = $result[$leaf_index]; |
71 | 71 | } |
72 | 72 | } |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function offsetSet($offset, $value = null) { |
93 | 93 | // Если нет никакого индекса - значит нечего записывать |
94 | - if(!isset($offset) || (is_array($offset) && empty($offset))) { |
|
94 | + if (!isset($offset) || (is_array($offset) && empty($offset))) { |
|
95 | 95 | return; |
96 | 96 | } |
97 | 97 | |
98 | 98 | // Если в массиве индекса только один элемент - значит это просто индекс |
99 | - if(is_array($offset) && count($offset) == 1) { |
|
99 | + if (is_array($offset) && count($offset) == 1) { |
|
100 | 100 | // Разворачиваем его в индекс |
101 | 101 | $offset = array(reset($offset) => $value); |
102 | 102 | unset($value); |
@@ -104,20 +104,20 @@ discard block |
||
104 | 104 | } |
105 | 105 | |
106 | 106 | // Адресация многомерного массива через массив индексов в $option |
107 | - if(is_array($offset) && isset($value)) { |
|
107 | + if (is_array($offset) && isset($value)) { |
|
108 | 108 | // TODO - а не переделать ли это всё на __isset() ?? |
109 | 109 | //pdump($offset, '$offset'); |
110 | 110 | //pdump($value, '$value'); |
111 | 111 | // Вытаскиваем корневой элемент |
112 | 112 | $root = $this->__get(reset($offset)); |
113 | 113 | $current_leaf = &$root; |
114 | - while(($leaf_index = next($offset)) !== false) { |
|
114 | + while (($leaf_index = next($offset)) !== false) { |
|
115 | 115 | !is_array($current_leaf[$leaf_index]) ? $current_leaf[$leaf_index] = array() : false; |
116 | 116 | $current_leaf = &$current_leaf[$leaf_index]; |
117 | 117 | } |
118 | 118 | //pdump($current_leaf, '$current_leaf'); |
119 | 119 | //pdump($value, '$value'); |
120 | - if($current_leaf != $value) { |
|
120 | + if ($current_leaf != $value) { |
|
121 | 121 | $current_leaf = $value; |
122 | 122 | //pdump(reset($offset), 'reset($offset)'); |
123 | 123 | //pdump($root, '$root'); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | // Пакетная запись из массива ключ -> значение |
129 | 129 | !is_array($offset) ? $offset = array($offset => $value) : false; |
130 | 130 | |
131 | - foreach($offset as $key => $value) { |
|
131 | + foreach ($offset as $key => $value) { |
|
132 | 132 | $this->__get($key) !== $value ? $this->__set($key, $value) : false; |
133 | 133 | } |
134 | 134 | } |
@@ -149,13 +149,13 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function offsetUnset($offset) { |
151 | 151 | // Если нет никакого индекса - значит нечего записывать |
152 | - if(!isset($offset) || (is_array($offset) && empty($offset))) { |
|
152 | + if (!isset($offset) || (is_array($offset) && empty($offset))) { |
|
153 | 153 | return; |
154 | 154 | } |
155 | 155 | |
156 | 156 | !is_array($offset) ? $offset = array($offset) : false; |
157 | 157 | |
158 | - if($this->offsetExists($offset)) { |
|
158 | + if ($this->offsetExists($offset)) { |
|
159 | 159 | //pdump($offset); |
160 | 160 | // Перематываем массив в конец |
161 | 161 | $key_to_delete = end($offset); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | //pdump($key_to_delete, '$key_to_delete'); |
164 | 164 | $parent_offset = $offset; |
165 | 165 | array_pop($parent_offset); |
166 | - if(!count($parent_offset)) { |
|
166 | + if (!count($parent_offset)) { |
|
167 | 167 | // В массиве был один элемент - мы удаляем в корне. Просто удаляем элемент |
168 | 168 | $this->__unset($key_to_delete); |
169 | 169 | } else { |
@@ -59,7 +59,7 @@ |
||
59 | 59 | if(self::$mode === CACHER_NOT_INIT) { |
60 | 60 | self::$mode = CACHER_NO_CACHE; |
61 | 61 | if(!self::$data) { |
62 | - self::$data = array(); |
|
62 | + self::$data = array(); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | } |
@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | * Defining some constants |
14 | 14 | */ |
15 | 15 | define('CACHER_NOT_INIT', -1); |
16 | -define('CACHER_NO_CACHE', 0); |
|
17 | -define('CACHER_XCACHE' , 1); |
|
16 | +define('CACHER_NO_CACHE', 0); |
|
17 | +define('CACHER_XCACHE', 1); |
|
18 | 18 | |
19 | 19 | define('CACHER_LOCK_WAIT', 5); // maximum cacher wait for table unlock in seconds. Can be float |
20 | 20 | |
@@ -46,19 +46,19 @@ discard block |
||
46 | 46 | protected static $cacheObject; |
47 | 47 | |
48 | 48 | public function __construct($prefIn = 'CACHE_', $init_mode = false) { |
49 | - if( !($init_mode === false || $init_mode === CACHER_NO_CACHE || ($init_mode === CACHER_XCACHE && extension_loaded('xcache')) )) { |
|
49 | + if (!($init_mode === false || $init_mode === CACHER_NO_CACHE || ($init_mode === CACHER_XCACHE && extension_loaded('xcache')))) { |
|
50 | 50 | throw new UnexpectedValueException('Wrong work mode or current mode does not supported on your server'); |
51 | 51 | } |
52 | 52 | |
53 | 53 | $this->prefix = $prefIn; |
54 | - if(extension_loaded('xcache') && ($init_mode === CACHER_XCACHE || $init_mode === false)) { |
|
55 | - if(self::$mode === CACHER_NOT_INIT) { |
|
54 | + if (extension_loaded('xcache') && ($init_mode === CACHER_XCACHE || $init_mode === false)) { |
|
55 | + if (self::$mode === CACHER_NOT_INIT) { |
|
56 | 56 | self::$mode = CACHER_XCACHE; |
57 | 57 | } |
58 | 58 | } else { |
59 | - if(self::$mode === CACHER_NOT_INIT) { |
|
59 | + if (self::$mode === CACHER_NOT_INIT) { |
|
60 | 60 | self::$mode = CACHER_NO_CACHE; |
61 | - if(!self::$data) { |
|
61 | + if (!self::$data) { |
|
62 | 62 | self::$data = array(); |
63 | 63 | } |
64 | 64 | } |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | default: |
95 | 95 | switch (self::$mode) { |
96 | 96 | case CACHER_NO_CACHE: |
97 | - self::$data[$this->prefix.$name] = $value; |
|
97 | + self::$data[$this->prefix . $name] = $value; |
|
98 | 98 | break; |
99 | 99 | |
100 | 100 | case CACHER_XCACHE: |
101 | - xcache_set($this->prefix.$name, $value); |
|
101 | + xcache_set($this->prefix . $name, $value); |
|
102 | 102 | break; |
103 | 103 | } |
104 | 104 | break; |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | default: |
119 | 119 | switch (self::$mode) { |
120 | 120 | case CACHER_NO_CACHE: |
121 | - return self::$data[$this->prefix.$name]; |
|
121 | + return self::$data[$this->prefix . $name]; |
|
122 | 122 | break; |
123 | 123 | |
124 | 124 | case CACHER_XCACHE: |
125 | - return xcache_get($this->prefix.$name); |
|
125 | + return xcache_get($this->prefix . $name); |
|
126 | 126 | break; |
127 | 127 | |
128 | 128 | } |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | public function __isset($name) { |
136 | 136 | switch (self::$mode) { |
137 | 137 | case CACHER_NO_CACHE: |
138 | - return isset(self::$data[$this->prefix.$name]); |
|
138 | + return isset(self::$data[$this->prefix . $name]); |
|
139 | 139 | break; |
140 | 140 | |
141 | 141 | case CACHER_XCACHE: |
142 | - return xcache_isset($this->prefix.$name) && ($this->__get($name) !== null); |
|
142 | + return xcache_isset($this->prefix . $name) && ($this->__get($name) !== null); |
|
143 | 143 | break; |
144 | 144 | } |
145 | 145 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | public function unset_by_prefix($prefix_unset = '') { |
162 | 162 | static $array_clear; |
163 | - !$array_clear ? $array_clear = function(&$v,$k,$p) { |
|
163 | + !$array_clear ? $array_clear = function(&$v, $k, $p) { |
|
164 | 164 | strpos($k, $p) === 0 ? $v = NULL : false; |
165 | 165 | } : false; |
166 | 166 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | break; |
173 | 173 | |
174 | 174 | case CACHER_XCACHE: |
175 | - if(!function_exists('xcache_unset_by_prefix')) { |
|
175 | + if (!function_exists('xcache_unset_by_prefix')) { |
|
176 | 176 | return false; |
177 | 177 | } |
178 | 178 | return xcache_unset_by_prefix($this->prefix . $prefix_unset); |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | protected function make_element_name($args, $diff = 0) { |
189 | 189 | $num_args = count($args); |
190 | 190 | |
191 | - if($num_args < 1) { |
|
191 | + if ($num_args < 1) { |
|
192 | 192 | return false; |
193 | 193 | } |
194 | 194 | |
195 | 195 | $name = ''; |
196 | 196 | $aName = array(); |
197 | - for($i = 0; $i <= $num_args - 1 - $diff; $i++) { |
|
197 | + for ($i = 0; $i <= $num_args - 1 - $diff; $i++) { |
|
198 | 198 | $name .= "[{$args[$i]}]"; |
199 | 199 | array_unshift($aName, $name); |
200 | 200 | } |
@@ -206,15 +206,15 @@ discard block |
||
206 | 206 | $args = func_get_args(); |
207 | 207 | $name = $this->make_element_name($args, 1); |
208 | 208 | |
209 | - if(!$name) { |
|
209 | + if (!$name) { |
|
210 | 210 | return NULL; |
211 | 211 | } |
212 | 212 | |
213 | - if($this->$name[0] === NULL) { |
|
214 | - for($i = count($name) - 1; $i > 0; $i--) { |
|
213 | + if ($this->$name[0] === NULL) { |
|
214 | + for ($i = count($name) - 1; $i > 0; $i--) { |
|
215 | 215 | $cName = "{$name[$i]}_COUNT"; |
216 | - $cName1 = "{$name[$i-1]}_COUNT"; |
|
217 | - if($this->$cName1 == NULL || $i == 1) { |
|
216 | + $cName1 = "{$name[$i - 1]}_COUNT"; |
|
217 | + if ($this->$cName1 == NULL || $i == 1) { |
|
218 | 218 | $this->$cName++; |
219 | 219 | } |
220 | 220 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | |
227 | 227 | public function array_get() { |
228 | 228 | $name = $this->make_element_name(func_get_args()); |
229 | - if(!$name) { |
|
229 | + if (!$name) { |
|
230 | 230 | return NULL; |
231 | 231 | } |
232 | 232 | return $this->$name[0]; |
@@ -234,12 +234,12 @@ discard block |
||
234 | 234 | |
235 | 235 | public function array_count() { |
236 | 236 | $name = $this->make_element_name(func_get_args()); |
237 | - if(!$name) { |
|
237 | + if (!$name) { |
|
238 | 238 | return 0; |
239 | 239 | } |
240 | 240 | $cName = "{$name[0]}_COUNT"; |
241 | 241 | $retVal = $this->$cName; |
242 | - if(!$retVal) { |
|
242 | + if (!$retVal) { |
|
243 | 243 | $retVal = NULL; |
244 | 244 | } |
245 | 245 | return $retVal; |
@@ -248,18 +248,18 @@ discard block |
||
248 | 248 | public function array_unset() { |
249 | 249 | $name = $this->make_element_name(func_get_args()); |
250 | 250 | |
251 | - if(!$name) { |
|
251 | + if (!$name) { |
|
252 | 252 | return false; |
253 | 253 | } |
254 | 254 | $this->unset_by_prefix($name[0]); |
255 | 255 | |
256 | - for($i = 1; $i < count($name); $i++) { |
|
256 | + for ($i = 1; $i < count($name); $i++) { |
|
257 | 257 | $cName = "{$name[$i]}_COUNT"; |
258 | - $cName1 = "{$name[$i-1]}_COUNT"; |
|
258 | + $cName1 = "{$name[$i - 1]}_COUNT"; |
|
259 | 259 | |
260 | - if($i == 1 || $this->$cName1 === NULL) { |
|
260 | + if ($i == 1 || $this->$cName1 === NULL) { |
|
261 | 261 | $this->$cName--; |
262 | - if($this->$cName <= 0) { |
|
262 | + if ($this->$cName <= 0) { |
|
263 | 263 | unset($this->$cName); |
264 | 264 | } |
265 | 265 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | $this->sql_index_field = "{$table_name}_name"; |
320 | 320 | $this->sql_value_field = "{$table_name}_value"; |
321 | 321 | |
322 | - if(!$this->_DB_LOADED) { |
|
322 | + if (!$this->_DB_LOADED) { |
|
323 | 323 | $this->db_loadAll(); |
324 | 324 | } |
325 | 325 | } |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | |
335 | 335 | public function db_loadItem($index) { |
336 | 336 | $result = null; |
337 | - if($index) { |
|
337 | + if ($index) { |
|
338 | 338 | $index_safe = db_escape($index); |
339 | 339 | $result = doquery("SELECT `{$this->sql_value_field}` FROM `{{{$this->table_name}}}` WHERE `{$this->sql_index_field}` = '{$index_safe}' FOR UPDATE", true); |
340 | 340 | // В две строки - что бы быть уверенным в порядке выполнения |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | $this->loadDefaults(); |
349 | 349 | |
350 | 350 | $query = doquery("SELECT * FROM {{{$this->table_name}}} FOR UPDATE;"); |
351 | - while($row = db_fetch($query)) { |
|
351 | + while ($row = db_fetch($query)) { |
|
352 | 352 | $this->$row[$this->sql_index_field] = $row[$this->sql_value_field]; |
353 | 353 | } |
354 | 354 | |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | } |
357 | 357 | |
358 | 358 | public function loadDefaults() { |
359 | - foreach($this->defaults as $defName => $defValue) { |
|
359 | + foreach ($this->defaults as $defName => $defValue) { |
|
360 | 360 | $this->$defName = $defValue; |
361 | 361 | } |
362 | 362 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | } |
373 | 373 | |
374 | 374 | public function db_saveItem($item_list, $value = NULL) { |
375 | - if(empty($item_list)) { |
|
375 | + if (empty($item_list)) { |
|
376 | 376 | return; |
377 | 377 | } |
378 | 378 | |
@@ -380,8 +380,8 @@ discard block |
||
380 | 380 | |
381 | 381 | // Сначала записываем данные в базу - что бы поймать все блокировки |
382 | 382 | $qry = array(); |
383 | - foreach($item_list as $item_name => $item_value) { |
|
384 | - if($item_name) { |
|
383 | + foreach ($item_list as $item_name => $item_value) { |
|
384 | + if ($item_name) { |
|
385 | 385 | $item_value = db_escape($item_value === NULL ? $this->$item_name : $item_value); |
386 | 386 | $item_name = db_escape($item_name); |
387 | 387 | $qry[] = "('{$item_name}', '{$item_value}')"; |
@@ -390,8 +390,8 @@ discard block |
||
390 | 390 | doquery("REPLACE INTO `{{" . $this->table_name . "}}` (`{$this->sql_index_field}`, `{$this->sql_value_field}`) VALUES " . implode(',', $qry) . ";"); |
391 | 391 | |
392 | 392 | // И только после взятия блокировок - меняем значения в кэше |
393 | - foreach($item_list as $item_name => $item_value) { |
|
394 | - if($item_name && $item_value !== NULL) { |
|
393 | + foreach ($item_list as $item_name => $item_value) { |
|
394 | + if ($item_name && $item_value !== NULL) { |
|
395 | 395 | $this->$item_name = $item_value; |
396 | 396 | } |
397 | 397 | } |
@@ -419,9 +419,9 @@ discard block |
||
419 | 419 | 'advGoogleLeftMenuCode' => '(Place here code for banner)', |
420 | 420 | |
421 | 421 | // Alliance bonus calculations |
422 | - 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
422 | + 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
423 | 423 | 'ali_bonus_brackets' => 10, // Brackets count for ALI_BONUS_BY_RANK |
424 | - 'ali_bonus_brackets_divisor' => 10,// Bonus divisor for ALI_BONUS_BY_RANK |
|
424 | + 'ali_bonus_brackets_divisor' => 10, // Bonus divisor for ALI_BONUS_BY_RANK |
|
425 | 425 | 'ali_bonus_divisor' => 10000000, // Rank divisor for ALI_BONUS_BY_POINTS |
426 | 426 | 'ali_bonus_members' => 10, // Minumum alliace size to start using bonus |
427 | 427 | |
@@ -452,25 +452,25 @@ discard block |
||
452 | 452 | 'deuterium_basic_income' => 0, |
453 | 453 | 'eco_scale_storage' => 1, |
454 | 454 | 'eco_stockman_fleet' => '', // Black Market - Starting amount of s/h ship merchant to sell |
455 | - 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
455 | + 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
456 | 456 | 'empire_mercenary_base_period' => PERIOD_MONTH, // Base |
457 | 457 | 'empire_mercenary_temporary' => 0, // Temporary empire-wide mercenaries |
458 | 458 | 'energy_basic_income' => 0, |
459 | 459 | |
460 | 460 | // Bashing protection settings |
461 | - 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
462 | - 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
463 | - 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
464 | - 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
465 | - 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
461 | + 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
462 | + 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
463 | + 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
464 | + 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
465 | + 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
466 | 466 | |
467 | 467 | 'Fleet_Cdr' => 30, |
468 | 468 | 'fleet_speed' => 1, |
469 | 469 | |
470 | 470 | 'fleet_update_interval' => 4, |
471 | 471 | |
472 | - 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
473 | - 'game_counter' => 0, // Does built-in page hit counter is on? |
|
472 | + 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
473 | + 'game_counter' => 0, // Does built-in page hit counter is on? |
|
474 | 474 | // Defaults |
475 | 475 | 'game_default_language' => 'ru', |
476 | 476 | 'game_default_skin' => 'skins/EpicBlue/', |
@@ -484,13 +484,13 @@ discard block |
||
484 | 484 | 'game_maxSystem' => 199, |
485 | 485 | 'game_maxPlanet' => 15, |
486 | 486 | // Game global settings |
487 | - 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
487 | + 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
488 | 488 | 'game_name' => 'SuperNova', // Server name (would be on banners and on top of left menu) |
489 | 489 | |
490 | 490 | 'game_news_actual' => 259200, // How long announcement would be marked as "New". In seconds. Default - 3 days |
491 | - 'game_news_overview' => 3, // How much last news to show in Overview page |
|
491 | + 'game_news_overview' => 3, // How much last news to show in Overview page |
|
492 | 492 | // Noob protection |
493 | - 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
493 | + 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
494 | 494 | 'game_noob_points' => 5000, // Below this point user threated as noob. 0 to disable |
495 | 495 | |
496 | 496 | 'game_multiaccount_enabled' => 0, // 1 - allow interactions for players with same IP (multiaccounts) |
@@ -539,8 +539,8 @@ discard block |
||
539 | 539 | 'payment_currency_exchange_wmu' => 30, |
540 | 540 | 'payment_currency_exchange_wmz' => 1, |
541 | 541 | |
542 | - 'payment_lot_price' => 1, // Lot price in default currency |
|
543 | - 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
542 | + 'payment_lot_price' => 1, // Lot price in default currency |
|
543 | + 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
544 | 544 | |
545 | 545 | 'planet_teleport_cost' => 50000, // |
546 | 546 | 'planet_teleport_timeout' => 86400, // |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | 'resource_multiplier' => 1, |
559 | 559 | |
560 | 560 | //Roleplay system |
561 | - 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
561 | + 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
562 | 562 | 'rpg_bonus_minimum' => 10000, // Minimum DM ammount for starting paying bonuses to affiliate |
563 | 563 | |
564 | 564 | // Black Market - General |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | } |
645 | 645 | |
646 | 646 | public static function getInstance($gamePrefix = 'sn_', $table_name = 'config') { |
647 | - if(!isset(self::$cacheObject)) { |
|
647 | + if (!isset(self::$cacheObject)) { |
|
648 | 648 | $className = get_class(); |
649 | 649 | self::$cacheObject = new $className($gamePrefix, $table_name); |
650 | 650 | } |
@@ -81,6 +81,10 @@ discard block |
||
81 | 81 | // ------------------------------------------------------------------------- |
82 | 82 | // Here comes low-level functions - those that directly works with cacher engines |
83 | 83 | // ------------------------------------------------------------------------- |
84 | + |
|
85 | + /** |
|
86 | + * @param string $name |
|
87 | + */ |
|
84 | 88 | public function __set($name, $value) { |
85 | 89 | switch ($name) { |
86 | 90 | case '_MODE': |
@@ -132,6 +136,9 @@ discard block |
||
132 | 136 | return null; |
133 | 137 | } |
134 | 138 | |
139 | + /** |
|
140 | + * @param string $name |
|
141 | + */ |
|
135 | 142 | public function __isset($name) { |
136 | 143 | switch (self::$mode) { |
137 | 144 | case CACHER_NO_CACHE: |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | protected static $is_init = false; |
20 | 20 | |
21 | 21 | protected static function init() { |
22 | - if(!empty(static::$db)) { |
|
22 | + if (!empty(static::$db)) { |
|
23 | 23 | return; |
24 | 24 | } |
25 | 25 | static::$db = classSupernova::$db; |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | $provider_id_safe = intval($provider_id_unsafe); |
67 | 67 | !is_array($account_list) ? $account_list = array($account_list) : false; |
68 | 68 | |
69 | - foreach($account_list as $provider_account_id_unsafe) { |
|
69 | + foreach ($account_list as $provider_account_id_unsafe) { |
|
70 | 70 | $provider_account_id_safe = intval($provider_account_id_unsafe); |
71 | 71 | |
72 | 72 | // TODO - Здесь могут отсутствовать аккаунты - проверять провайдером |
73 | 73 | $query = static::$db->doquery("SELECT `user_id` FROM {{account_translate}} WHERE `provider_id` = {$provider_id_safe} AND `provider_account_id` = {$provider_account_id_safe} FOR UPDATE"); |
74 | - while($row = static::$db->db_fetch($query)) { |
|
74 | + while ($row = static::$db->db_fetch($query)) { |
|
75 | 75 | $account_translation[$row['user_id']][$provider_id_unsafe][$provider_account_id_unsafe] = true; |
76 | 76 | } |
77 | 77 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | "SELECT * FROM {{account_translate}} WHERE `user_id` = {$user_id_safe} " . |
92 | 92 | ($provider_id_unsafe ? "AND `provider_id` = {$provider_id_safe} " : '') . |
93 | 93 | "ORDER BY `timestamp` FOR UPDATE"); |
94 | - while($row = static::$db->db_fetch($query)) { |
|
94 | + while ($row = static::$db->db_fetch($query)) { |
|
95 | 95 | $account_translation[$row['user_id']][$row['provider_id']][$row['provider_account_id']] = $row; |
96 | 96 | } |
97 | 97 |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | // OK 4.9 |
37 | 37 | public function __construct($filename = __FILE__) { |
38 | - if($this->provider_id == ACCOUNT_PROVIDER_NONE) { |
|
38 | + if ($this->provider_id == ACCOUNT_PROVIDER_NONE) { |
|
39 | 39 | die('У всех провайдеров должен быть $provider_id!'); |
40 | 40 | } |
41 | 41 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | // OK 4.6 |
134 | 134 | public function player_name_suggest() { |
135 | 135 | $name = ''; |
136 | - if(is_object($this->account) && !empty($this->account->account_email)) { |
|
136 | + if (is_object($this->account) && !empty($this->account->account_email)) { |
|
137 | 137 | list($name) = explode('@', $this->account->account_email); |
138 | 138 | } |
139 | 139 |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * Инициализация харнилища скинов |
153 | 153 | */ |
154 | 154 | protected static function init() { |
155 | - if(static::$is_init) { |
|
155 | + if (static::$is_init) { |
|
156 | 156 | return; |
157 | 157 | } |
158 | 158 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | // Загружены ли уже данные по текущему скину? |
167 | 167 | //pdump(static::$skin_list[$ini_path], 'static'); |
168 | - if(empty(static::$skin_list[$skin_path])) { |
|
168 | + if (empty(static::$skin_list[$skin_path])) { |
|
169 | 169 | // Прогружаем текущий скин |
170 | 170 | static::$skin_list[$skin_path] = new skin($skin_path); |
171 | 171 | static::$active = static::$skin_list[$skin_path]; |
@@ -201,22 +201,22 @@ discard block |
||
201 | 201 | |
202 | 202 | $this->is_ini_present = false; |
203 | 203 | // Проверка на корректность и существование пути |
204 | - if(is_file($this->root_physical_absolute . 'skin.ini')) { |
|
204 | + if (is_file($this->root_physical_absolute . 'skin.ini')) { |
|
205 | 205 | // Пытаемся распарсить файл |
206 | 206 | |
207 | 207 | // По секциям? images и config? Что бы не копировать конфигурацию? Или просто unset(__inherit) а затем заново записать |
208 | 208 | $this->config = parse_ini_file($this->root_physical_absolute . 'skin.ini'); |
209 | - if(!empty($this->config)) { |
|
209 | + if (!empty($this->config)) { |
|
210 | 210 | |
211 | 211 | $this->is_ini_present = true; |
212 | 212 | |
213 | - if(!empty($this->config['_inherit'])) { |
|
213 | + if (!empty($this->config['_inherit'])) { |
|
214 | 214 | // Если скин наследует себя... |
215 | - if($this->config['_inherit'] == $skin_path) { |
|
215 | + if ($this->config['_inherit'] == $skin_path) { |
|
216 | 216 | // TODO - определять более сложные случаи циклических ссылок в _inherit |
217 | 217 | die('">circular skin inheritance!'); |
218 | 218 | } |
219 | - if(empty(static::$skin_list[$this->config['_inherit']])) { |
|
219 | + if (empty(static::$skin_list[$this->config['_inherit']])) { |
|
220 | 220 | static::$skin_list[$this->config['_inherit']] = new skin($this->config['_inherit']); |
221 | 221 | } |
222 | 222 | $this->parent = static::$skin_list[$this->config['_inherit']]; |
@@ -232,12 +232,12 @@ discard block |
||
232 | 232 | } |
233 | 233 | |
234 | 234 | // Пытаемся скомпилировать _no_image заранее |
235 | - if(!empty($this->config[SKIN_IMAGE_MISSED_FIELD])) { |
|
235 | + if (!empty($this->config[SKIN_IMAGE_MISSED_FIELD])) { |
|
236 | 236 | $this->container[SKIN_IMAGE_MISSED_FIELD] = $this->compile_try_path(SKIN_IMAGE_MISSED_FIELD, $this->config[SKIN_IMAGE_MISSED_FIELD]); |
237 | 237 | } |
238 | 238 | |
239 | 239 | // Если нет заглушки |
240 | - if(empty($this->container[SKIN_IMAGE_MISSED_FIELD])) { |
|
240 | + if (empty($this->container[SKIN_IMAGE_MISSED_FIELD])) { |
|
241 | 241 | $this->container[SKIN_IMAGE_MISSED_FIELD] = empty($this->parent) |
242 | 242 | // Если нет парента - берем хардкод |
243 | 243 | ? $this->container[SKIN_IMAGE_MISSED_FIELD] = SN_ROOT_VIRTUAL . SKIN_IMAGE_MISSED_FILE_PATH |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | $image_tag = $this->image_tag_parse($image_tag, $template); |
268 | 268 | |
269 | 269 | // Проверяем наличие ключа RIT в хранилища. В нём не может быть несуществующих файлов по построению |
270 | - if(!empty($this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]])) { |
|
270 | + if (!empty($this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]])) { |
|
271 | 271 | return $this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]]; |
272 | 272 | } |
273 | 273 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | // Нет - image ID не является путём к файлу. Пора обратиться к предкам за помощью... |
286 | 286 | // Пытаемся вытащить путь из родителя и применить к нему свои параметры |
287 | 287 | // Тащим по ID изображения, а не по ТЭГУ - мало ли что там делает с путём родитель и как преобразовывает его в строку? |
288 | - if(empty($this->container[$image_id]) && !empty($this->parent)) { |
|
288 | + if (empty($this->container[$image_id]) && !empty($this->parent)) { |
|
289 | 289 | $this->container[$image_id] = $this->parent->compile_image($image_id, $template); |
290 | 290 | |
291 | 291 | // Если у родителя нет картинки - он вернет пустую строку. Тогда нам надо использовать заглушку - свою или родительскую |
@@ -306,18 +306,18 @@ discard block |
||
306 | 306 | protected function image_tag_parse($image_tag, $template) { |
307 | 307 | $image_tag_ptl_resolved = $image_tag; |
308 | 308 | // Есть переменные из темплейта ? |
309 | - if(strpos($image_tag_ptl_resolved, '[') !== false && is_object($template)) { |
|
309 | + if (strpos($image_tag_ptl_resolved, '[') !== false && is_object($template)) { |
|
310 | 310 | // Что бы лишний раз не запускать регексп |
311 | 311 | // TODO - многоуровневые вложения ?! Надо ли и где их можно применить |
312 | 312 | preg_match_all('#(\[.+?\])#', $image_tag_ptl_resolved, $matches); |
313 | - foreach($matches[0] as &$match) { |
|
313 | + foreach ($matches[0] as &$match) { |
|
314 | 314 | $var_name = str_replace(array('[', ']'), '', $match); |
315 | - if(strpos($var_name, '.') !== false) { |
|
315 | + if (strpos($var_name, '.') !== false) { |
|
316 | 316 | // Вложенная переменная темплейта - на текущем уровне |
317 | 317 | // TODO Вложенная переменная из корня через "!" |
318 | 318 | list($block_name, $block_var) = explode('.', $var_name); |
319 | 319 | isset($template->_block_value[$block_name][$block_var]) ? $image_tag_ptl_resolved = str_replace($match, $template->_block_value[$block_name][$block_var], $image_tag_ptl_resolved) : false; |
320 | - } elseif(strpos($var_name, '$') !== false) { |
|
320 | + } elseif (strpos($var_name, '$') !== false) { |
|
321 | 321 | // Корневой DEFINE |
322 | 322 | $define_name = substr($var_name, 1); |
323 | 323 | isset($template->_tpldata['DEFINE']['.'][$define_name]) ? $image_tag_ptl_resolved = str_replace($match, $template->_tpldata['DEFINE']['.'][$define_name], $image_tag_ptl_resolved) : false; |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
331 | - if(strpos($image_tag_ptl_resolved, '|') !== false) { |
|
331 | + if (strpos($image_tag_ptl_resolved, '|') !== false) { |
|
332 | 332 | $params = explode('|', $image_tag_ptl_resolved); |
333 | 333 | $image_id = $params[0]; |
334 | 334 | unset($params[0]); |
@@ -392,11 +392,11 @@ discard block |
||
392 | 392 | $image_string = $this->container[$image_tag]; |
393 | 393 | |
394 | 394 | // Нет параметров - просто возвращаем значение по $image_name из контейнера |
395 | - if(!empty($params) && is_array($params)) { |
|
395 | + if (!empty($params) && is_array($params)) { |
|
396 | 396 | // Здесь автоматически произойдёт упорядочивание параметров |
397 | 397 | |
398 | 398 | // Параметр 'html' - выводить изображение в виде HTML-тэга |
399 | - if(in_array('html', $params)) { |
|
399 | + if (in_array('html', $params)) { |
|
400 | 400 | $image_tag = $image_tag . '|html'; |
401 | 401 | $image_string = '<img src="' . $image_string . '" />'; |
402 | 402 | $this->container[$image_tag] = $image_string; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | // $same_user = false; |
54 | 54 | // } |
55 | 55 | |
56 | - if(!$user_data) { |
|
56 | + if (!$user_data) { |
|
57 | 57 | message($lang['imp_imperator_none'], $lang['sys_error'], 'index.php', 10); |
58 | 58 | die(); |
59 | 59 | } |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | $stat_array = array(); |
65 | 65 | $query = doquery("SELECT * FROM {{statpoints}} WHERE `stat_type` = 1 AND `id_owner` = {$user_id} ORDER BY `stat_code` DESC;"); |
66 | 66 | $stat_count = classSupernova::$db->db_affected_rows(); |
67 | - while($row = db_fetch($query)) { |
|
68 | - foreach($stat_fields as $field_db_name => $field_template_name) { |
|
67 | + while ($row = db_fetch($query)) { |
|
68 | + foreach ($stat_fields as $field_db_name => $field_template_name) { |
|
69 | 69 | // $stat_count - $row['stat_code'] - для реверсирования ID статы в JS |
70 | 70 | $stat_array[$field_template_name]['DATA'][$stat_count - $row['stat_code']] = $row[$field_db_name]; |
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | 74 | $stat_array_date = $stat_array['STAT_DATE']; |
75 | - foreach($stat_array_date['DATA'] as $key => $value) { |
|
75 | + foreach ($stat_array_date['DATA'] as $key => $value) { |
|
76 | 76 | $template->assign_block_vars('stat_date', array( |
77 | 77 | 'ID' => $key, |
78 | 78 | 'VALUE' => $value, |
@@ -85,17 +85,17 @@ discard block |
||
85 | 85 | |
86 | 86 | unset($stat_array['STAT_DATE']); |
87 | 87 | $template_data = array(); |
88 | - foreach($stat_array as $stat_type => &$stat_type_data) { |
|
88 | + foreach ($stat_array as $stat_type => &$stat_type_data) { |
|
89 | 89 | $reverse_min_max = strpos($stat_type, '_RANK') !== false; |
90 | 90 | $stat_type_data['MIN'] = $reverse_min_max ? max($stat_type_data['DATA']) : min($stat_type_data['DATA']); |
91 | 91 | $stat_type_data['MAX'] = $reverse_min_max ? min($stat_type_data['DATA']) : max($stat_type_data['DATA']); |
92 | 92 | $stat_type_data['AVG'] = average($stat_type_data['DATA']); |
93 | - foreach($stat_type_data['DATA'] as $key => $value) { |
|
93 | + foreach ($stat_type_data['DATA'] as $key => $value) { |
|
94 | 94 | // $stat_type_data['PERCENT'][$key] = $stat_type_data['MAX'] - $value ? ($stat_type_data['MAX'] - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $value) : 100; |
95 | 95 | $stat_type_data['PERCENT'][$key] = ($stat_type_data['MAX'] - $value ? ($value - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $stat_type_data['MIN']) : 1) * 100; |
96 | 96 | $template_data[$stat_type][$key]['ID'] = $key; |
97 | 97 | $template_data[$stat_type][$key]['VALUE'] = $value; |
98 | - $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']); |
|
98 | + $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']); |
|
99 | 99 | $template_data[$stat_type][$key]['PERCENT'] = $stat_type_data['PERCENT'][$key]; |
100 | 100 | |
101 | 101 | //$template_data[$stat_type][$key]['PERCENT'] = $key ? $stat_type_data['PERCENT'][$key] : 50; // TODO DEBUG |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | } |
104 | 104 | // pdump($stat_array['RES_POINTS']); |
105 | 105 | |
106 | - foreach($template_data as $stat_type => $stat_type_data) { |
|
106 | + foreach ($template_data as $stat_type => $stat_type_data) { |
|
107 | 107 | $template->assign_block_vars('stat', array( |
108 | 108 | 'TYPE' => $stat_type, |
109 | 109 | 'TEXT' => $lang['imp_stat_types'][$stat_type], |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | 'MAX' => $stat_array[$stat_type]['MAX'], |
112 | 112 | 'AVG' => $stat_array[$stat_type]['AVG'], |
113 | 113 | )); |
114 | - foreach($stat_type_data as $stat_entry) { |
|
114 | + foreach ($stat_type_data as $stat_entry) { |
|
115 | 115 | $template->assign_block_vars('stat.entry', $stat_entry); |
116 | 116 | } |
117 | 117 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | // pdump($template_data); |
121 | 121 | |
122 | - if($same_user) { |
|
122 | + if ($same_user) { |
|
123 | 123 | rpg_level_up($user, RPG_STRUCTURE); |
124 | 124 | rpg_level_up($user, RPG_RAID); |
125 | 125 | rpg_level_up($user, RPG_TECH); |
@@ -153,29 +153,29 @@ discard block |
||
153 | 153 | 'builder_xp' => pretty_number($user_data['xpminier']), |
154 | 154 | 'builder_lvl' => pretty_number($user_data['lvl_minier']), |
155 | 155 | 'builder_lvl_st' => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'])), |
156 | - 'builder_lvl_up' => pretty_number(rpg_get_miner_xp($user_data['lvl_minier']+1)), |
|
156 | + 'builder_lvl_up' => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'] + 1)), |
|
157 | 157 | 'raid_xp' => pretty_number($user_data['xpraid']), |
158 | 158 | 'raid_lvl' => pretty_number($user_data['lvl_raid']), |
159 | - 'raid_lvl_up' => pretty_number(rpg_get_raider_xp($user_data['lvl_raid']+1)), |
|
159 | + 'raid_lvl_up' => pretty_number(rpg_get_raider_xp($user_data['lvl_raid'] + 1)), |
|
160 | 160 | 'raids' => pretty_number($user_data['raids']), |
161 | 161 | 'raidswin' => pretty_number($user_data['raidswin']), |
162 | 162 | 'raidsloose' => pretty_number($user_data['raidsloose']), |
163 | 163 | 'tech_xp' => pretty_number($user_data['player_rpg_tech_xp']), |
164 | 164 | 'tech_lvl' => pretty_number($user_data['player_rpg_tech_level']), |
165 | 165 | 'tech_lvl_st' => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'])), |
166 | - 'tech_lvl_up' => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level']+1)), |
|
166 | + 'tech_lvl_up' => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'] + 1)), |
|
167 | 167 | |
168 | 168 | 'explore_xp' => pretty_number($user_data['player_rpg_explore_xp']), |
169 | 169 | 'explore_lvl' => pretty_number($user_data['player_rpg_explore_level']), |
170 | 170 | 'explore_lvl_st' => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'])), |
171 | - 'explore_lvl_up' => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level']+1)), |
|
172 | - |
|
173 | - 'build_points' => pretty_number( $StatRecord['build_points'] ), |
|
174 | - 'tech_points' => pretty_number( $StatRecord['tech_points'] ), |
|
175 | - 'fleet_points' => pretty_number( $StatRecord['fleet_points'] ), |
|
176 | - 'defs_points' => pretty_number( $StatRecord['defs_points'] ), |
|
177 | - 'res_points' => pretty_number( $StatRecord['res_points'] ), |
|
178 | - 'total_points' => pretty_number( $StatRecord['total_points'] ), |
|
171 | + 'explore_lvl_up' => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'] + 1)), |
|
172 | + |
|
173 | + 'build_points' => pretty_number($StatRecord['build_points']), |
|
174 | + 'tech_points' => pretty_number($StatRecord['tech_points']), |
|
175 | + 'fleet_points' => pretty_number($StatRecord['fleet_points']), |
|
176 | + 'defs_points' => pretty_number($StatRecord['defs_points']), |
|
177 | + 'res_points' => pretty_number($StatRecord['res_points']), |
|
178 | + 'total_points' => pretty_number($StatRecord['total_points']), |
|
179 | 179 | 'user_rank' => $StatRecord['total_rank'], |
180 | 180 | 'RANK_DIFF' => $StatRecord['total_old_rank'] - $StatRecord['total_rank'], |
181 | 181 |