@@ -1,42 +1,42 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once('includes/init.' . substr(strrchr(__FILE__, '.'), 1)); |
|
3 | +require_once('includes/init.'.substr(strrchr(__FILE__, '.'), 1)); |
|
4 | 4 | |
5 | 5 | $mode = sys_get_param_int('mode'); |
6 | 6 | $ajax = sys_get_param_int('ajax'); |
7 | 7 | |
8 | -$url = 'http://supernova.ws/version_check.php?mode=' . $mode |
|
9 | - . '&db=' . DB_VERSION |
|
10 | - . '&release=' . SN_RELEASE |
|
11 | - . '&version=' . SN_VERSION |
|
12 | - . '&key=' . urlencode(classSupernova::$config->server_updater_key) |
|
13 | - . '&id=' . urlencode(classSupernova::$config->server_updater_id); |
|
8 | +$url = 'http://supernova.ws/version_check.php?mode='.$mode |
|
9 | + . '&db='.DB_VERSION |
|
10 | + . '&release='.SN_RELEASE |
|
11 | + . '&version='.SN_VERSION |
|
12 | + . '&key='.urlencode(classSupernova::$config->server_updater_key) |
|
13 | + . '&id='.urlencode(classSupernova::$config->server_updater_id); |
|
14 | 14 | |
15 | -switch($mode) { |
|
15 | +switch ($mode) { |
|
16 | 16 | case SNC_MODE_REGISTER: |
17 | - if(classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) { |
|
18 | - if($ajax) { |
|
17 | + if (classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) { |
|
18 | + if ($ajax) { |
|
19 | 19 | print(SNC_VER_REGISTER_ERROR_REGISTERED); |
20 | 20 | } |
21 | 21 | die(); |
22 | 22 | } |
23 | - $url .= "&name=" . urlencode(classSupernova::$config->game_name) . "&url=" . urlencode(SN_ROOT_VIRTUAL); |
|
23 | + $url .= "&name=".urlencode(classSupernova::$config->game_name)."&url=".urlencode(SN_ROOT_VIRTUAL); |
|
24 | 24 | break; |
25 | 25 | } |
26 | 26 | |
27 | 27 | $check_result = sn_get_url_contents($url); |
28 | -if(!$check_result) { |
|
28 | +if (!$check_result) { |
|
29 | 29 | $version_check = SNC_VER_ERROR_CONNECT; |
30 | -} elseif(($version_check = intval($check_result)) && $version_check == $check_result) { |
|
30 | +} elseif (($version_check = intval($check_result)) && $version_check == $check_result) { |
|
31 | 31 | $version_check = $check_result; |
32 | 32 | } else { |
33 | 33 | // JSON decode if string |
34 | 34 | $check_result = json_decode($check_result, true); |
35 | 35 | $version_check = $check_result === null ? SNC_VER_UNKNOWN_RESPONSE : $check_result['version_check']; |
36 | 36 | |
37 | - switch($mode) { |
|
37 | + switch ($mode) { |
|
38 | 38 | case SNC_MODE_REGISTER: |
39 | - if($check_result['site']['site_key'] && $check_result['site']['site_id'] && $check_result['site']['result'] == SNC_VER_REGISTER_REGISTERED) { |
|
39 | + if ($check_result['site']['site_key'] && $check_result['site']['site_id'] && $check_result['site']['result'] == SNC_VER_REGISTER_REGISTERED) { |
|
40 | 40 | classSupernova::$config->db_saveItem('server_updater_key', $check_result['site']['site_key']); |
41 | 41 | classSupernova::$config->db_saveItem('server_updater_id', $check_result['site']['site_id']); |
42 | 42 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | classSupernova::$config->db_saveItem('server_updater_check_last', SN_TIME_NOW); |
50 | 50 | classSupernova::$config->db_saveItem('server_updater_check_result', $version_check); |
51 | 51 | |
52 | -if($ajax) { |
|
52 | +if ($ajax) { |
|
53 | 53 | define('IN_AJAX', true); |
54 | 54 | print($version_check); |
55 | 55 | } |
@@ -4,9 +4,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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, |
@@ -9,7 +9,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -14,15 +14,15 @@ discard block |
||
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 |
||
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) { |
@@ -14,13 +14,13 @@ |
||
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'], |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(isset($sn_page_name) || ($sn_page_name = isset($_GET['page']) ? trim(strip_tags($_GET['page'])) : '')) { |
|
4 | - require_once('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
3 | +if (isset($sn_page_name) || ($sn_page_name = isset($_GET['page']) ? trim(strip_tags($_GET['page'])) : '')) { |
|
4 | + require_once('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
5 | 5 | |
6 | - if($sn_page_name) { |
|
6 | + if ($sn_page_name) { |
|
7 | 7 | // Loading page-specific language files |
8 | 8 | global $template; |
9 | 9 | !empty(classSupernova::$sn_mvc['model'][$sn_page_name]) ? execute_hooks(classSupernova::$sn_mvc['model'][$sn_page_name], $template, 'model', $sn_page_name) : false; |
10 | 10 | !empty(classSupernova::$sn_mvc['view'][$sn_page_name]) ? execute_hooks(classSupernova::$sn_mvc['view'][$sn_page_name], $template, 'view', $sn_page_name) : false; |
11 | 11 | |
12 | - if(!empty($template_result) && is_object($template)) { |
|
12 | + if (!empty($template_result) && is_object($template)) { |
|
13 | 13 | $template->assign_recursive($template_result); |
14 | 14 | } |
15 | 15 | display($template, '', true, '', defined('IN_ADMIN') && (IN_ADMIN === true), true); |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
3 | +include('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
4 | 4 | |
5 | 5 | global $user, $planetrow; |
6 | 6 | |
7 | -if(!empty($_POST['return']) && is_array($_POST['return'])) { |
|
8 | - foreach($_POST['return'] as $fleet_id) { |
|
9 | - if($fleet_id = idval($fleet_id)) { |
|
7 | +if (!empty($_POST['return']) && is_array($_POST['return'])) { |
|
8 | + foreach ($_POST['return'] as $fleet_id) { |
|
9 | + if ($fleet_id = idval($fleet_id)) { |
|
10 | 10 | sn_db_transaction_start(); |
11 | 11 | $objFleet = new Fleet(); |
12 | 12 | $objFleet->dbLoad($fleet_id); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | lng_include('overview'); |
31 | 31 | lng_include('fleet'); |
32 | 32 | |
33 | -if(!$planetrow) { |
|
33 | +if (!$planetrow) { |
|
34 | 34 | message(classLocale::$lang['fl_noplanetrow'], classLocale::$lang['fl_error']); |
35 | 35 | } |
36 | 36 | |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | |
39 | 39 | $i = 0; |
40 | 40 | $objFleetList = FleetList::dbGetFleetListByOwnerId($user['id']); |
41 | -if(!empty($objFleetList)) { |
|
42 | - foreach($objFleetList->_container as $fleet_id => $objFleet) { |
|
41 | +if (!empty($objFleetList)) { |
|
42 | + foreach ($objFleetList->_container as $fleet_id => $objFleet) { |
|
43 | 43 | $i++; |
44 | 44 | $fleet_data = tplParseFleetObject($objFleet, $i, $user); |
45 | 45 | |
46 | 46 | $template->assign_block_vars('fleets', $fleet_data['fleet']); |
47 | 47 | |
48 | - foreach($fleet_data['ships'] as $ship_data) { |
|
48 | + foreach ($fleet_data['ships'] as $ship_data) { |
|
49 | 49 | $template->assign_block_vars('fleets.ships', $ship_data); |
50 | 50 | } |
51 | 51 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * |
10 | 10 | */ |
11 | 11 | |
12 | -require_once('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
12 | +require_once('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
13 | 13 | |
14 | 14 | define('SN_IN_MARKET', true); |
15 | 15 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $newstock = $stock; |
27 | 27 | $intError = MARKET_DEAL; |
28 | 28 | |
29 | -switch($mode) |
|
29 | +switch ($mode) |
|
30 | 30 | { |
31 | 31 | case MARKET_RESOURCES: // Resource trader |
32 | 32 | require('includes/includes/market_trader.inc'); |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | $message_id = sys_get_param_int('message'); |
85 | -if($message_id != MARKET_NOTHING) |
|
85 | +if ($message_id != MARKET_NOTHING) |
|
86 | 86 | { |
87 | 87 | $template->assign_block_vars('result', array('MESSAGE' => classLocale::$lang['eco_mrk_errors'][$message_id])); |
88 | 88 | } |
89 | 89 | |
90 | -if($message) |
|
90 | +if ($message) |
|
91 | 91 | { |
92 | 92 | $template->assign_block_vars('result', array('MESSAGE' => $message)); |
93 | 93 | } |
@@ -1,58 +1,58 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function dump($value,$varname = "",$level=0,$dumper = "") |
|
3 | +function dump($value, $varname = "", $level = 0, $dumper = "") |
|
4 | 4 | { |
5 | 5 | if ($varname) $varname .= " = "; |
6 | 6 | |
7 | - if ($level==-1) |
|
7 | + if ($level == -1) |
|
8 | 8 | { |
9 | - $trans[' ']='∴'; |
|
10 | - $trans["\t"]='⇒'; |
|
11 | - $trans["\n"]='¶;'; |
|
12 | - $trans["\r"]='⇐'; |
|
13 | - $trans["\0"]='⊕'; |
|
14 | - return strtr(htmlspecialchars($value),$trans); |
|
9 | + $trans[' '] = '∴'; |
|
10 | + $trans["\t"] = '⇒'; |
|
11 | + $trans["\n"] = '¶;'; |
|
12 | + $trans["\r"] = '⇐'; |
|
13 | + $trans["\0"] = '⊕'; |
|
14 | + return strtr(htmlspecialchars($value), $trans); |
|
15 | 15 | } |
16 | - if ($level==0) $dumper = '<pre>' . $varname; |
|
16 | + if ($level == 0) $dumper = '<pre>'.$varname; |
|
17 | 17 | |
18 | 18 | $type = gettype($value); |
19 | 19 | $dumper .= $type; |
20 | 20 | |
21 | - if ($type=='string') |
|
21 | + if ($type == 'string') |
|
22 | 22 | { |
23 | 23 | $dumper .= '('.strlen($value).')'; |
24 | - $value = dump($value,"",-1); |
|
24 | + $value = dump($value, "", -1); |
|
25 | 25 | } |
26 | - elseif ($type=='boolean') $value= ($value?'true':'false'); |
|
27 | - elseif ($type=='object') |
|
26 | + elseif ($type == 'boolean') $value = ($value ? 'true' : 'false'); |
|
27 | + elseif ($type == 'object') |
|
28 | 28 | { |
29 | - $props= get_class_vars(get_class($value)); |
|
29 | + $props = get_class_vars(get_class($value)); |
|
30 | 30 | $dumper .= '('.count($props).') <u>'.get_class($value).'</u>'; |
31 | - foreach($props as $key=>$val) |
|
31 | + foreach ($props as $key=>$val) |
|
32 | 32 | { |
33 | - $dumper .= "\n".str_repeat("\t",$level+1).$key.' => '; |
|
34 | - $dumper .= dump($value->$key,"",$level+1); |
|
33 | + $dumper .= "\n".str_repeat("\t", $level + 1).$key.' => '; |
|
34 | + $dumper .= dump($value->$key, "", $level + 1); |
|
35 | 35 | } |
36 | - $value= ''; |
|
36 | + $value = ''; |
|
37 | 37 | } |
38 | - elseif ($type=='array') |
|
38 | + elseif ($type == 'array') |
|
39 | 39 | { |
40 | 40 | $dumper .= '('.count($value).')'; |
41 | - foreach($value as $key=>$val) |
|
41 | + foreach ($value as $key=>$val) |
|
42 | 42 | { |
43 | - $dumper .= "\n".str_repeat("\t",$level+1).dump($key,"",-1).' => '; |
|
44 | - $dumper .= dump($val,"",$level+1); |
|
43 | + $dumper .= "\n".str_repeat("\t", $level + 1).dump($key, "", -1).' => '; |
|
44 | + $dumper .= dump($val, "", $level + 1); |
|
45 | 45 | } |
46 | - $value= ''; |
|
46 | + $value = ''; |
|
47 | 47 | } |
48 | 48 | $dumper .= " <b>$value</b>"; |
49 | - if ($level==0) $dumper .= '</pre>'; |
|
49 | + if ($level == 0) $dumper .= '</pre>'; |
|
50 | 50 | return $dumper; |
51 | 51 | } |
52 | 52 | |
53 | 53 | function pdump($value, $varname = '') |
54 | 54 | { |
55 | - print('<span style="text-align: left">' . dump($value, $varname) . '</span>'); |
|
55 | + print('<span style="text-align: left">'.dump($value, $varname).'</span>'); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | function debug($value, $varname = '') |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $output_buffer .= $string; |
68 | 68 | } |
69 | 69 | |
70 | -if(substr(getcwd(), -4) != 'docs') |
|
70 | +if (substr(getcwd(), -4) != 'docs') |
|
71 | 71 | { |
72 | 72 | $path_prefix = 'docs/'; |
73 | 73 | } |
@@ -80,22 +80,22 @@ discard block |
||
80 | 80 | |
81 | 81 | $filename = 'changelog'; |
82 | 82 | |
83 | -$input = file_get_contents($path_prefix . $filename . '.txt'); |
|
83 | +$input = file_get_contents($path_prefix.$filename.'.txt'); |
|
84 | 84 | //$input = iconv('CP1251', 'UTF-8', $input); |
85 | 85 | |
86 | 86 | $input = preg_replace("/\r\n\d\d\d\d\-\d\d\-\d\d\ \d\d\:\d\d/", "[D] $0", $input); |
87 | 87 | |
88 | -while(strpos($input, "\r\n\r\n") !== false) |
|
88 | +while (strpos($input, "\r\n\r\n") !== false) |
|
89 | 89 | { |
90 | 90 | $input = str_replace("\r\n\r\n", "\r\n", $input); |
91 | 91 | } |
92 | -while(strpos($input, "~~~") !== false) |
|
92 | +while (strpos($input, "~~~") !== false) |
|
93 | 93 | { |
94 | 94 | $input = str_replace("~~~", "~~", $input); |
95 | 95 | } |
96 | 96 | $input = str_replace("\r\n~~", "~~", $input); |
97 | 97 | |
98 | -while(strpos($input, "===") !== false) |
|
98 | +while (strpos($input, "===") !== false) |
|
99 | 99 | { |
100 | 100 | $input = str_replace("===", "==", $input); |
101 | 101 | } |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | $prev_chapter_is_header = false; |
107 | 107 | $output = array(); |
108 | 108 | $buffer = array(); |
109 | -foreach($input as &$chapter) |
|
109 | +foreach ($input as &$chapter) |
|
110 | 110 | { |
111 | 111 | $chapter = preg_split("/(\r\n[\[])/", $chapter, -1, PREG_SPLIT_NO_EMPTY); // , PREG_SPLIT_DELIM_CAPTURE |
112 | 112 | |
113 | - if(count($chapter) == 1 && !$prev_chapter_is_header) |
|
113 | + if (count($chapter) == 1 && !$prev_chapter_is_header) |
|
114 | 114 | { |
115 | - if(!empty($chapter)) |
|
115 | + if (!empty($chapter)) |
|
116 | 116 | { |
117 | 117 | $output[] = $buffer; |
118 | 118 | $buffer = array(); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | else |
124 | 124 | { |
125 | 125 | $prev_chapter_is_header = false; |
126 | - foreach($chapter as &$note) |
|
126 | + foreach ($chapter as &$note) |
|
127 | 127 | { |
128 | 128 | $note = explode("\r\n", $note); |
129 | 129 | $new_note = true; |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | |
132 | 132 | $note_out = array(); |
133 | 133 | |
134 | - foreach($note as &$line) |
|
134 | + foreach ($note as &$line) |
|
135 | 135 | { |
136 | - if(!$line) |
|
136 | + if (!$line) |
|
137 | 137 | { |
138 | 138 | continue; |
139 | 139 | } |
140 | - if($new_note) |
|
140 | + if ($new_note) |
|
141 | 141 | { |
142 | 142 | // 78 - 3 = 75 |
143 | 143 | $note_out['style'] = $line[0]; |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | } |
146 | 146 | |
147 | 147 | $buf_str .= $line; |
148 | - if(mb_strlen($line, 'utf-8') < ($new_note ? 75 : 79)) |
|
148 | + if (mb_strlen($line, 'utf-8') < ($new_note ? 75 : 79)) |
|
149 | 149 | { |
150 | - if(!isset($note_out['name'])) |
|
150 | + if (!isset($note_out['name'])) |
|
151 | 151 | { |
152 | 152 | $note_out['name'] = $buf_str; |
153 | 153 | } |
@@ -201,31 +201,31 @@ discard block |
||
201 | 201 | 'D' => 'date', |
202 | 202 | ); |
203 | 203 | |
204 | -foreach($output as $chapter) |
|
204 | +foreach ($output as $chapter) |
|
205 | 205 | { |
206 | - if(!$chapter) |
|
206 | + if (!$chapter) |
|
207 | 207 | { |
208 | 208 | continue; |
209 | 209 | } |
210 | 210 | |
211 | 211 | buf_print("<h1>{$chapter['name']}</h1>\r\n"); |
212 | - foreach($chapter['content'] as $block) |
|
212 | + foreach ($chapter['content'] as $block) |
|
213 | 213 | { |
214 | - buf_print("<div class=\"{$styles[$block['style']]}\">" . ($block['style'] != 'D' ? "[{$block['style']}] " : '')); |
|
215 | - buf_print(preg_replace("/\s{2,10}/", " ", $block['name']) . '<br />'); |
|
216 | - if(isset($block['lines'])) |
|
214 | + buf_print("<div class=\"{$styles[$block['style']]}\">".($block['style'] != 'D' ? "[{$block['style']}] " : '')); |
|
215 | + buf_print(preg_replace("/\s{2,10}/", " ", $block['name']).'<br />'); |
|
216 | + if (isset($block['lines'])) |
|
217 | 217 | { |
218 | 218 | $last_spaces = ''; |
219 | 219 | $depth = array(); |
220 | - foreach($block['lines'] as $line) |
|
220 | + foreach ($block['lines'] as $line) |
|
221 | 221 | { |
222 | - if(preg_match("/^(\s+)(\d*|\s)\.*\s*(.*)/", $line, $matches)) |
|
222 | + if (preg_match("/^(\s+)(\d*|\s)\.*\s*(.*)/", $line, $matches)) |
|
223 | 223 | { |
224 | 224 | //$line = strlen($matches[1]) . '/' . $matches[2] . '/' . $matches[3]; |
225 | 225 | $line = $matches[3]; |
226 | - if(strlen($matches[1]) > strlen($last_spaces)) |
|
226 | + if (strlen($matches[1]) > strlen($last_spaces)) |
|
227 | 227 | { |
228 | - if($matches[2]) |
|
228 | + if ($matches[2]) |
|
229 | 229 | { |
230 | 230 | buf_print("<ol>\r\n"); |
231 | 231 | } |
@@ -237,9 +237,9 @@ discard block |
||
237 | 237 | $last_spaces = $matches[1]; |
238 | 238 | $depth[] = $matches[2]; |
239 | 239 | } |
240 | - elseif(strlen($matches[1]) < strlen($last_spaces) && count($depth)) |
|
240 | + elseif (strlen($matches[1]) < strlen($last_spaces) && count($depth)) |
|
241 | 241 | { |
242 | - if(array_pop($depth)) |
|
242 | + if (array_pop($depth)) |
|
243 | 243 | { |
244 | 244 | buf_print("</ol>\r\n"); |
245 | 245 | } |
@@ -250,14 +250,14 @@ discard block |
||
250 | 250 | $last_spaces = $matches[1]; |
251 | 251 | buf_print('<li>'); |
252 | 252 | } |
253 | - elseif(strlen($last_spaces) == strlen($matches[1])) |
|
253 | + elseif (strlen($last_spaces) == strlen($matches[1])) |
|
254 | 254 | { |
255 | - if($matches[2] == '' && $depth[count($depth) - 1] != '') |
|
255 | + if ($matches[2] == '' && $depth[count($depth) - 1] != '') |
|
256 | 256 | { |
257 | 257 | buf_print("</ol>\r\n"); |
258 | 258 | buf_print("<ul>\r\n"); |
259 | 259 | } |
260 | - elseif($matches[2] != '' && $depth[count($depth) - 1] == '') |
|
260 | + elseif ($matches[2] != '' && $depth[count($depth) - 1] == '') |
|
261 | 261 | { |
262 | 262 | buf_print("</ul>\r\n"); |
263 | 263 | buf_print("<ol>\r\n"); |
@@ -267,11 +267,11 @@ discard block |
||
267 | 267 | } |
268 | 268 | } |
269 | 269 | $line = preg_replace("/\s{2,10}/", " ", $line); |
270 | - buf_print($line . "<br />\r\n"); |
|
270 | + buf_print($line."<br />\r\n"); |
|
271 | 271 | } |
272 | - while(count($depth)) |
|
272 | + while (count($depth)) |
|
273 | 273 | { |
274 | - if(array_pop($depth)) |
|
274 | + if (array_pop($depth)) |
|
275 | 275 | { |
276 | 276 | buf_print("</ol>\r\n"); |
277 | 277 | } |
@@ -286,11 +286,11 @@ discard block |
||
286 | 286 | } |
287 | 287 | buf_print("</body>\r\n</html>\r\n"); |
288 | 288 | |
289 | -$html = file_get_contents($path_prefix . 'html/' . $filename . '.html'); |
|
290 | -if($html != $output_buffer) |
|
289 | +$html = file_get_contents($path_prefix.'html/'.$filename.'.html'); |
|
290 | +if ($html != $output_buffer) |
|
291 | 291 | { |
292 | - file_put_contents($path_prefix . 'html/' . $filename . '.html', $output_buffer); |
|
293 | - if(!$path_prefix) |
|
292 | + file_put_contents($path_prefix.'html/'.$filename.'.html', $output_buffer); |
|
293 | + if (!$path_prefix) |
|
294 | 294 | { |
295 | 295 | print($output_buffer); |
296 | 296 | } |