@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
4 | 4 | |
5 | -if(sys_get_param_int('BE_DEBUG') && !defined('BE_DEBUG')) |
|
5 | +if (sys_get_param_int('BE_DEBUG') && !defined('BE_DEBUG')) |
|
6 | 6 | { |
7 | 7 | define('BE_DEBUG', true); |
8 | 8 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | $sym_defender = $_POST['defender'] ? $_POST['defender'] : array(); |
16 | 16 | $sym_attacker = $_POST['attacker'] ? $_POST['attacker'] : array(); |
17 | 17 | |
18 | -if($replay) |
|
18 | +if ($replay) |
|
19 | 19 | { |
20 | 20 | $unpacked = sn_ube_simulator_decode_replay($replay); |
21 | 21 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $sym_attacker = array(1 => $sym_attacker); |
29 | 29 | } |
30 | 30 | |
31 | -if($_POST['submit'] || $execute) |
|
31 | +if ($_POST['submit'] || $execute) |
|
32 | 32 | { |
33 | 33 | $replay = sn_ube_simulator_encode_replay($sym_defender, 'D'); |
34 | 34 | $replay .= sn_ube_simulator_encode_replay($sym_attacker, 'A'); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | // sn_ube_report_save($combat_data); |
43 | 43 | // } |
44 | 44 | |
45 | - if(sys_get_param_str('reload')) |
|
45 | + if (sys_get_param_str('reload')) |
|
46 | 46 | { |
47 | 47 | $combat_data = sn_ube_report_load($combat_data[UBE_REPORT_CYPHER]); |
48 | 48 | } |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | $template = gettemplate('simulator', true); |
63 | 63 | $techs_and_officers = array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR, MRC_ADMIRAL); |
64 | 64 | |
65 | - foreach($techs_and_officers as $tech_id) |
|
65 | + foreach ($techs_and_officers as $tech_id) |
|
66 | 66 | { |
67 | - if(!$sym_attacker[1][$tech_id]) |
|
67 | + if (!$sym_attacker[1][$tech_id]) |
|
68 | 68 | { |
69 | 69 | $sym_attacker[1][$tech_id] = mrc_get_level($user, false, $tech_id); |
70 | 70 | } |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | UNIT_GOVERNORS => array(MRC_FORTIFIER), |
79 | 79 | UNIT_DEFENCE => sn_get_groups('defense_active'), |
80 | 80 | ); |
81 | - foreach($show_groups as $unit_group_id => $unit_group) |
|
81 | + foreach ($show_groups as $unit_group_id => $unit_group) |
|
82 | 82 | { |
83 | 83 | $template->assign_block_vars('simulator', array( |
84 | 84 | 'GROUP' => $unit_group_id, |
85 | 85 | 'NAME' => $lang['tech'][$unit_group_id], |
86 | 86 | )); |
87 | 87 | |
88 | - foreach($unit_group as $unit_id) |
|
88 | + foreach ($unit_group as $unit_id) |
|
89 | 89 | { |
90 | 90 | $tab++; |
91 | 91 |
@@ -21,8 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | $sym_defender = $unpacked['D']; |
23 | 23 | $sym_attacker = $unpacked['A']; |
24 | -} |
|
25 | -else |
|
24 | +} else |
|
26 | 25 | { |
27 | 26 | $sym_defender = array(0 => $sym_defender); |
28 | 27 | $sym_attacker = array(1 => $sym_attacker); |
@@ -56,8 +55,7 @@ discard block |
||
56 | 55 | $template = gettemplate('ube_combat_report', true); |
57 | 56 | $template->assign_recursive($template_result); |
58 | 57 | display($template, '', false, '', false, false, true); |
59 | -} |
|
60 | -else |
|
58 | +} else |
|
61 | 59 | { |
62 | 60 | $template = gettemplate('simulator', true); |
63 | 61 | $techs_and_officers = array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR, MRC_ADMIRAL); |
@@ -15,7 +15,7 @@ |
||
15 | 15 | |
16 | 16 | include('includes/init.' . substr(strrchr(__FILE__, '.'), 1)); |
17 | 17 | // die(); |
18 | -if($template_result[F_USER_IS_AUTHORIZED]) { |
|
18 | +if ($template_result[F_USER_IS_AUTHORIZED]) { |
|
19 | 19 | sys_redirect('index' . DOT_PHP_EX); |
20 | 20 | } |
21 | 21 | lng_include('login'); |
@@ -14,7 +14,7 @@ |
||
14 | 14 | $template = gettemplate('changelog_table'); |
15 | 15 | |
16 | 16 | |
17 | -foreach($lang['changelog'] as $a => $b) |
|
17 | +foreach ($lang['changelog'] as $a => $b) |
|
18 | 18 | { |
19 | 19 | |
20 | 20 | $parse['version_number'] = $a; |
@@ -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' => $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 | } |
@@ -18,25 +18,25 @@ discard block |
||
18 | 18 | |
19 | 19 | lng_include('announce'); |
20 | 20 | |
21 | -switch($action) |
|
21 | +switch ($action) |
|
22 | 22 | { |
23 | 23 | case 1://on veut poster une annonce |
24 | - $page .='<HTML> |
|
24 | + $page .= '<HTML> |
|
25 | 25 | <center> |
26 | 26 | <br> |
27 | 27 | <table width="600"> |
28 | - <td class="c" colspan="10" align="center"><b><font color="white">'.$lang['Classifieds'].'</font></b></td></tr> |
|
28 | + <td class="c" colspan="10" align="center"><b><font color="white">'.$lang['Classifieds'] . '</font></b></td></tr> |
|
29 | 29 | <form action="annonce.php?action=2" method="post"> |
30 | - <td class="c" colspan="10" align="center"><b>'.$lang['Resources_to_be_sold'].'</font></b></td> |
|
31 | - <tr><th colspan="5">'.$lang['metal'].'</th><th colspan="5"><input type="texte" value="0" name="metalvendre" /></th></tr> |
|
32 | - <tr><th colspan="5">'.$lang['crystal'].'</th><th colspan="5"><input type="texte" value="0" name="cristalvendre" /></th></tr> |
|
33 | - <tr><th colspan="5">'.$lang['deuterium'].'</th><th colspan="5"><input type="texte" value="0" name="deutvendre" /></th></tr> |
|
30 | + <td class="c" colspan="10" align="center"><b>'.$lang['Resources_to_be_sold'] . '</font></b></td> |
|
31 | + <tr><th colspan="5">'.$lang['metal'] . '</th><th colspan="5"><input type="texte" value="0" name="metalvendre" /></th></tr> |
|
32 | + <tr><th colspan="5">'.$lang['crystal'] . '</th><th colspan="5"><input type="texte" value="0" name="cristalvendre" /></th></tr> |
|
33 | + <tr><th colspan="5">'.$lang['deuterium'] . '</th><th colspan="5"><input type="texte" value="0" name="deutvendre" /></th></tr> |
|
34 | 34 | |
35 | - <td class="c" colspan="10" align="center"><b>'.$lang['Desired_resources'].'</font></b></td></tr> |
|
36 | - <tr><th colspan="5">'.$lang['metal'].'</th><th colspan="5"><input type="texte" value="0" name="metalsouhait" /></th></tr> |
|
37 | - <tr><th colspan="5">'.$lang['crystal'].'</th><th colspan="5"><input type="texte" value="0" name="cristalsouhait" /></th></tr> |
|
38 | - <tr><th colspan="5">'.$lang['deuterium'].'</th><th colspan="5"><input type="texte" value="0" name="deutsouhait" /></th></tr> |
|
39 | - <tr><th colspan="10"><input type="submit" value="'.$lang['send'].'" /></th></tr> |
|
35 | + <td class="c" colspan="10" align="center"><b>'.$lang['Desired_resources'] . '</font></b></td></tr> |
|
36 | + <tr><th colspan="5">'.$lang['metal'] . '</th><th colspan="5"><input type="texte" value="0" name="metalsouhait" /></th></tr> |
|
37 | + <tr><th colspan="5">'.$lang['crystal'] . '</th><th colspan="5"><input type="texte" value="0" name="cristalsouhait" /></th></tr> |
|
38 | + <tr><th colspan="5">'.$lang['deuterium'] . '</th><th colspan="5"><input type="texte" value="0" name="deutsouhait" /></th></tr> |
|
39 | + <tr><th colspan="10"><input type="submit" value="'.$lang['send'] . '" /></th></tr> |
|
40 | 40 | |
41 | 41 | <form> |
42 | 42 | </table> |
@@ -53,20 +53,20 @@ discard block |
||
53 | 53 | $deutvendre = sys_get_param_float('deutvendre'); |
54 | 54 | $deutsouhait = sys_get_param_float('deutsouhait'); |
55 | 55 | |
56 | - if(($metalvendre!=0 && $metalsouhait==0) ||($cristalvendre!=0 && $cristalsouhait==0) || ($deutvendre!=0 && $deutsouhait==0)) |
|
56 | + if (($metalvendre != 0 && $metalsouhait == 0) || ($cristalvendre != 0 && $cristalsouhait == 0) || ($deutvendre != 0 && $deutsouhait == 0)) |
|
57 | 57 | { |
58 | 58 | doquery("INSERT INTO {{annonce}} SET `user` ='{$users['username']}', `galaxie` ='{$users['galaxy']}', `systeme` ='{$users['system']}', `metala` ='{$metalvendre}', `cristala` ='{$cristalvendre}', `deuta` ='{$deutvendre}', `metals` ='{$metalsouhait}', `cristals` ='{$cristalsouhait}', `deuts` ='{$deutsouhait}'"); |
59 | - message ($lang['Your_announce_was_recorded'], $lang['announce_status'],"annonce.php"); |
|
59 | + message($lang['Your_announce_was_recorded'], $lang['announce_status'], "annonce.php"); |
|
60 | 60 | } |
61 | 61 | else |
62 | 62 | { |
63 | - message ($lang['Your_announce_not_recorded'], $lang['announce_status'],"annonce.php?action=1"); |
|
63 | + message($lang['Your_announce_not_recorded'], $lang['announce_status'], "annonce.php?action=1"); |
|
64 | 64 | } |
65 | 65 | break; |
66 | 66 | |
67 | 67 | case 3://Suppression d'annonce |
68 | 68 | doquery("DELETE FROM {{annonce}} WHERE `id` = {$GET_id}"); |
69 | - message ($lang['Your_announce_was_deleted'], $lang['announce_status'],"annonce.php"); |
|
69 | + message($lang['Your_announce_was_deleted'], $lang['announce_status'], "annonce.php"); |
|
70 | 70 | break; |
71 | 71 | |
72 | 72 | default://Sinon on affiche la liste des annonces |
@@ -81,15 +81,15 @@ discard block |
||
81 | 81 | while ($b = db_fetch($annonce)) |
82 | 82 | { |
83 | 83 | $page2 .= '<tr><th>'; |
84 | - foreach($b as $name => $value) |
|
84 | + foreach ($b as $name => $value) |
|
85 | 85 | { |
86 | - if($name!='id') |
|
86 | + if ($name != 'id') |
|
87 | 87 | { |
88 | - $page2 .= $value ; |
|
88 | + $page2 .= $value; |
|
89 | 89 | $page2 .= '</th><th>'; |
90 | 90 | } |
91 | 91 | } |
92 | - $page2 .= ($b['user']==$users['username'])?"<a href=\"annonce.php?action=3&id={$b[id]}\">X</a></th></tr>":"</th></tr>"; |
|
92 | + $page2 .= ($b['user'] == $users['username']) ? "<a href=\"annonce.php?action=3&id={$b[id]}\">X</a></th></tr>" : "</th></tr>"; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $page2 .= "<tr><th colspan=\"10\" align=\"center\"><a href=\"annonce.php?action=1\">{$lang['add_announce']}</a></th></tr></td></table></HTML>"; |
@@ -57,8 +57,7 @@ |
||
57 | 57 | { |
58 | 58 | doquery("INSERT INTO {{annonce}} SET `user` ='{$users['username']}', `galaxie` ='{$users['galaxy']}', `systeme` ='{$users['system']}', `metala` ='{$metalvendre}', `cristala` ='{$cristalvendre}', `deuta` ='{$deutvendre}', `metals` ='{$metalsouhait}', `cristals` ='{$cristalsouhait}', `deuts` ='{$deutsouhait}'"); |
59 | 59 | message ($lang['Your_announce_was_recorded'], $lang['announce_status'],"annonce.php"); |
60 | - } |
|
61 | - else |
|
60 | + } else |
|
62 | 61 | { |
63 | 62 | message ($lang['Your_announce_not_recorded'], $lang['announce_status'],"annonce.php?action=1"); |
64 | 63 | } |
@@ -140,7 +140,9 @@ |
||
140 | 140 | global $template_result; |
141 | 141 | // Доступные платежные методы |
142 | 142 | foreach($payment_methods_available as $payment_type_id => $payment_methods) { |
143 | - if(empty($payment_methods)) continue; |
|
143 | + if(empty($payment_methods)) { |
|
144 | + continue; |
|
145 | + } |
|
144 | 146 | |
145 | 147 | $template_result['.']['payment'][$payment_type_id] =array( |
146 | 148 | 'ID' => $payment_type_id, |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | include_once('common.' . substr(strrchr(__FILE__, '.'), 1)); |
10 | 10 | |
11 | -if(!sn_module_get_active_count('payment')) { |
|
11 | +if (!sn_module_get_active_count('payment')) { |
|
12 | 12 | sys_redirect('dark_matter.php'); |
13 | 13 | die(); |
14 | 14 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | // $player_currency_default = player_load_option($user, PLAYER_OPTION_CURRENCY_DEFAULT); |
24 | 24 | $player_currency_default = classSupernova::$user_options[PLAYER_OPTION_CURRENCY_DEFAULT]; |
25 | 25 | $player_currency = sys_get_param_str('player_currency', $player_currency_default); |
26 | -empty($lang['pay_currency_list'][$player_currency]) ? ($player_currency = $player_currency_default ? $player_currency_default : classSupernova::$config->payment_currency_default) : false; |
|
26 | +empty($lang['pay_currency_list'][$player_currency]) ? ($player_currency = $player_currency_default ? $player_currency_default : classSupernova::$config->payment_currency_default) : false; |
|
27 | 27 | // $player_currency_default != $player_currency ? player_save_option($user, PLAYER_OPTION_CURRENCY_DEFAULT, $player_currency) : false; |
28 | 28 | $player_currency_default != $player_currency ? classSupernova::$user_options[PLAYER_OPTION_CURRENCY_DEFAULT] = $player_currency : false; |
29 | 29 | |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | |
66 | 66 | // Таблица скидок |
67 | 67 | $prev_discount = 0; |
68 | -if(isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) { |
|
69 | - foreach(sn_module_payment::$bonus_table as $sum => $discount) { |
|
70 | - if($discount && $discount != $prev_discount) { |
|
68 | +if (isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) { |
|
69 | + foreach (sn_module_payment::$bonus_table as $sum => $discount) { |
|
70 | + if ($discount && $discount != $prev_discount) { |
|
71 | 71 | $template->assign_block_vars('discount', array( |
72 | 72 | 'SUM' => $sum, |
73 | 73 | 'DISCOUNT' => $discount * 100, |
@@ -80,19 +80,19 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | // Результат платежа |
83 | -if($payment_id = sys_get_param_id('payment_id')) { |
|
83 | +if ($payment_id = sys_get_param_id('payment_id')) { |
|
84 | 84 | $payment = doquery("SELECT * FROM {{payment}} WHERE `payment_id` = {$payment_id} LIMIT 1;", true); |
85 | - if($payment && $payment['payment_user_id'] == $user['id']) { |
|
86 | - if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
85 | + if ($payment && $payment['payment_user_id'] == $user['id']) { |
|
86 | + if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
87 | 87 | $template->assign_block_vars('result', array('MESSAGE' => sprintf($lang['pay_msg_mm_purchase_complete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name'], $payment['payment_dark_matter_gained']))); |
88 | 88 | } |
89 | - if($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
89 | + if ($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
90 | 90 | $template->assign_block_vars('result', array( |
91 | 91 | 'MESSAGE' => sprintf($lang['pay_msg_mm_purchase_incomplete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name']), |
92 | 92 | 'STATUS' => 1, |
93 | 93 | )); |
94 | 94 | } |
95 | - if($payment['payment_test']) { |
|
95 | + if ($payment['payment_test']) { |
|
96 | 96 | $template->assign_block_vars('result', array( |
97 | 97 | 'MESSAGE' => sprintf($lang['pay_msg_mm_purchase_test']), |
98 | 98 | 'STATUS' => -1, |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | 'metamatter' => sys_get_param_float('metamatter'), |
108 | 108 | ); |
109 | 109 | |
110 | -if(!$request['metamatter']) { |
|
110 | +if (!$request['metamatter']) { |
|
111 | 111 | unset($_POST); |
112 | 112 | } |
113 | 113 | |
@@ -118,16 +118,16 @@ discard block |
||
118 | 118 | |
119 | 119 | $payment_module_valid = false; |
120 | 120 | $payment_module = sys_get_param_str('payment_module'); |
121 | -foreach($sn_module_list['payment'] as $module_name => $module) { |
|
122 | - if(!is_object($module) || !$module->manifest['active']) { |
|
121 | +foreach ($sn_module_list['payment'] as $module_name => $module) { |
|
122 | + if (!is_object($module) || !$module->manifest['active']) { |
|
123 | 123 | continue; |
124 | 124 | } |
125 | 125 | |
126 | 126 | lng_include($module_name, $module->manifest['root_relative']); |
127 | 127 | |
128 | - foreach(sn_module_payment::$payment_methods as $payment_type_id => $available_methods) { |
|
129 | - foreach($available_methods as $payment_method => $payment_currency) { |
|
130 | - if(isset($module->manifest['payment_method'][$payment_method])) { |
|
128 | + foreach (sn_module_payment::$payment_methods as $payment_type_id => $available_methods) { |
|
129 | + foreach ($available_methods as $payment_method => $payment_currency) { |
|
130 | + if (isset($module->manifest['payment_method'][$payment_method])) { |
|
131 | 131 | $payment_methods_available[$payment_type_id][$payment_method][$module_name] = $module->manifest['payment_method'][$payment_method]; |
132 | 132 | } |
133 | 133 | } |
@@ -138,15 +138,15 @@ discard block |
||
138 | 138 | |
139 | 139 | global $template_result; |
140 | 140 | // Доступные платежные методы |
141 | -foreach($payment_methods_available as $payment_type_id => $payment_methods) { |
|
142 | - if(empty($payment_methods)) continue; |
|
141 | +foreach ($payment_methods_available as $payment_type_id => $payment_methods) { |
|
142 | + if (empty($payment_methods)) continue; |
|
143 | 143 | |
144 | - $template_result['.']['payment'][$payment_type_id] =array( |
|
144 | + $template_result['.']['payment'][$payment_type_id] = array( |
|
145 | 145 | 'ID' => $payment_type_id, |
146 | 146 | 'NAME' => $lang['pay_methods'][$payment_type_id], |
147 | 147 | ); |
148 | - foreach($payment_methods as $payment_method_id => $module_list) { |
|
149 | - if(empty($module_list)) { |
|
148 | + foreach ($payment_methods as $payment_method_id => $module_list) { |
|
149 | + if (empty($module_list)) { |
|
150 | 150 | continue; |
151 | 151 | } |
152 | 152 | $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id] = array( |
@@ -157,14 +157,14 @@ discard block |
||
157 | 157 | 'NAME_FORCE' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['name']), |
158 | 158 | 'BUTTON' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['button']), |
159 | 159 | ); |
160 | - foreach($module_list as $payment_module_name => $payment_module_method_details) { |
|
160 | + foreach ($module_list as $payment_module_name => $payment_module_method_details) { |
|
161 | 161 | $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id]['.']['module'][] = array( |
162 | 162 | 'MODULE' => $payment_module_name, |
163 | 163 | ); |
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | - if(empty($template_result['.']['payment'][$payment_type_id]['.'])) { |
|
167 | + if (empty($template_result['.']['payment'][$payment_type_id]['.'])) { |
|
168 | 168 | unset($template_result['.']['payment'][$payment_type_id]); |
169 | 169 | } |
170 | 170 | } |
@@ -177,19 +177,19 @@ discard block |
||
177 | 177 | $payment_module_valid = $payment_module_valid && (!$payment_method_selected || isset($payment_methods_available[$payment_type_selected][$payment_method_selected][$module_name])); |
178 | 178 | |
179 | 179 | // If payment_module invalid - making it empty OR if there is only one payment_module - selecting it |
180 | -if($payment_module_valid) { |
|
180 | +if ($payment_module_valid) { |
|
181 | 181 | // $payment_module = $payment_module; // Really - do nothing |
182 | -} elseif($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) { |
|
182 | +} elseif ($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) { |
|
183 | 183 | reset($payment_methods_available[$payment_type_selected][$payment_method_selected]); |
184 | 184 | $payment_module = key($payment_methods_available[$payment_type_selected][$payment_method_selected]); |
185 | -} elseif(count($sn_module_list['payment']) == 1) { |
|
185 | +} elseif (count($sn_module_list['payment']) == 1) { |
|
186 | 186 | $payment_module = $module_name; |
187 | 187 | } else { |
188 | 188 | $payment_module = ''; |
189 | 189 | } |
190 | 190 | |
191 | -if($payment_type_selected && $payment_method_selected) { |
|
192 | - foreach($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) { |
|
191 | +if ($payment_type_selected && $payment_method_selected) { |
|
192 | + foreach ($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) { |
|
193 | 193 | $template->assign_block_vars('payment_module', array( |
194 | 194 | 'ID' => $module_name, |
195 | 195 | 'NAME' => $lang["module_{$module_name}_name"], |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
201 | -foreach($lang['pay_currency_list'] as $key => $value) { |
|
201 | +foreach ($lang['pay_currency_list'] as $key => $value) { |
|
202 | 202 | $course = get_exchange_rate($key); |
203 | - if(!$course) { |
|
203 | + if (!$course) { |
|
204 | 204 | continue; |
205 | 205 | } |
206 | 206 | $template->assign_block_vars('exchange', array( |
@@ -214,17 +214,17 @@ discard block |
||
214 | 214 | )); |
215 | 215 | } |
216 | 216 | |
217 | -if($request['metamatter'] && $payment_module) { |
|
217 | +if ($request['metamatter'] && $payment_module) { |
|
218 | 218 | try { |
219 | 219 | // Any possible errors about generating paylink should be raised in module! |
220 | 220 | $pay_link = $sn_module[$payment_module]->compile_request($request); |
221 | 221 | |
222 | 222 | // Поддержка дополнительной информации |
223 | - if(is_array($pay_link['RENDER'])) { |
|
224 | - foreach($pay_link['RENDER'] as $html_data) { |
|
223 | + if (is_array($pay_link['RENDER'])) { |
|
224 | + foreach ($pay_link['RENDER'] as $html_data) { |
|
225 | 225 | $template->assign_block_vars('render', $html_data); |
226 | - if(isset($html_data['VALUE']) && is_array($html_data['VALUE'])) { |
|
227 | - foreach($html_data['VALUE'] as $value_id => $value_value) { |
|
226 | + if (isset($html_data['VALUE']) && is_array($html_data['VALUE'])) { |
|
227 | + foreach ($html_data['VALUE'] as $value_id => $value_value) { |
|
228 | 228 | $template->assign_block_vars('render.value', array( |
229 | 229 | 'FIELD' => $value_id, |
230 | 230 | 'VALUE' => $value_value, |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | } |
236 | 236 | |
237 | 237 | // Поддержка передачи данных для многошаговых платежных систем |
238 | - if(is_array($pay_link['DATA'])) { |
|
239 | - foreach($pay_link['DATA'] as $key => $value) { |
|
238 | + if (is_array($pay_link['DATA'])) { |
|
239 | + foreach ($pay_link['DATA'] as $key => $value) { |
|
240 | 240 | $template->assign_block_vars('pay_link_data', array( |
241 | 241 | 'FIELD' => $key, |
242 | 242 | 'VALUE' => $value, |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
247 | - if(is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) { |
|
247 | + if (is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) { |
|
248 | 248 | // TODO Переделать это под assign_vars_recursive и возвращать пустые строки если нет платежного метода - для унификации формы в темплейте |
249 | 249 | $template->assign_vars(array( |
250 | 250 | 'PAY_LINK_METHOD' => $pay_link['PAY_LINK_METHOD'], |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | } else { |
254 | 254 | throw new exception($lang['pay_msg_request_paylink_unsupported'], ERR_ERROR); |
255 | 255 | } |
256 | - } catch(exception $e) { |
|
256 | + } catch (exception $e) { |
|
257 | 257 | $template->assign_block_vars('result', $response = array( |
258 | 258 | 'STATUS' => $e->getCode(), |
259 | 259 | 'MESSAGE' => $e->getMessage(), |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | } |
264 | 264 | |
265 | 265 | // Прегенерированные пакеты |
266 | -foreach($unit_available_amount_list as $unit_amount => $discount) { |
|
266 | +foreach ($unit_available_amount_list as $unit_amount => $discount) { |
|
267 | 267 | $temp = sn_module_payment::currency_convert($unit_amount, 'MM_', $player_currency); |
268 | 268 | $template->assign_block_vars('mm_amount', array( |
269 | 269 | 'VALUE' => $unit_amount, |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | 'PLAYER_CURRENCY' => $player_currency, |
299 | 299 | 'PLAYER_CURRENCY_PRICE_PER_MM' => sn_module_payment::currency_convert(1, $player_currency, 'MM_', 10), |
300 | 300 | |
301 | - 'UNIT_AMOUNT' => (float)$request['metamatter'], |
|
301 | + 'UNIT_AMOUNT' => (float) $request['metamatter'], |
|
302 | 302 | 'UNIT_AMOUNT_TEXT' => pretty_number($request['metamatter']), |
303 | 303 | 'UNIT_AMOUNT_BONUS_PERCENT' => $bonus_percent, |
304 | 304 | 'UNIT_AMOUNT_TEXT_DISCOUNTED' => $income_metamatter_text, |
@@ -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: |
@@ -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 | } |
@@ -35,19 +35,19 @@ discard block |
||
35 | 35 | protected static $cacheObject; |
36 | 36 | |
37 | 37 | public function __construct($prefIn = 'CACHE_', $init_mode = false) { |
38 | - if( !($init_mode === false || $init_mode === CACHER_NO_CACHE || ($init_mode === CACHER_XCACHE && extension_loaded('xcache')) )) { |
|
38 | + if (!($init_mode === false || $init_mode === CACHER_NO_CACHE || ($init_mode === CACHER_XCACHE && extension_loaded('xcache')))) { |
|
39 | 39 | throw new UnexpectedValueException('Wrong work mode or current mode does not supported on your server'); |
40 | 40 | } |
41 | 41 | |
42 | 42 | $this->prefix = $prefIn; |
43 | - if(extension_loaded('xcache') && ($init_mode === CACHER_XCACHE || $init_mode === false)) { |
|
44 | - if(self::$mode === CACHER_NOT_INIT) { |
|
43 | + if (extension_loaded('xcache') && ($init_mode === CACHER_XCACHE || $init_mode === false)) { |
|
44 | + if (self::$mode === CACHER_NOT_INIT) { |
|
45 | 45 | self::$mode = CACHER_XCACHE; |
46 | 46 | } |
47 | 47 | } else { |
48 | - if(self::$mode === CACHER_NOT_INIT) { |
|
48 | + if (self::$mode === CACHER_NOT_INIT) { |
|
49 | 49 | self::$mode = CACHER_NO_CACHE; |
50 | - if(!self::$data) { |
|
50 | + if (!self::$data) { |
|
51 | 51 | self::$data = array(); |
52 | 52 | } |
53 | 53 | } |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | default: |
84 | 84 | switch (self::$mode) { |
85 | 85 | case CACHER_NO_CACHE: |
86 | - self::$data[$this->prefix.$name] = $value; |
|
86 | + self::$data[$this->prefix . $name] = $value; |
|
87 | 87 | break; |
88 | 88 | |
89 | 89 | case CACHER_XCACHE: |
90 | - xcache_set($this->prefix.$name, $value); |
|
90 | + xcache_set($this->prefix . $name, $value); |
|
91 | 91 | break; |
92 | 92 | } |
93 | 93 | break; |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | default: |
108 | 108 | switch (self::$mode) { |
109 | 109 | case CACHER_NO_CACHE: |
110 | - return self::$data[$this->prefix.$name]; |
|
110 | + return self::$data[$this->prefix . $name]; |
|
111 | 111 | break; |
112 | 112 | |
113 | 113 | case CACHER_XCACHE: |
114 | - return xcache_get($this->prefix.$name); |
|
114 | + return xcache_get($this->prefix . $name); |
|
115 | 115 | break; |
116 | 116 | |
117 | 117 | } |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | public function __isset($name) { |
125 | 125 | switch (self::$mode) { |
126 | 126 | case CACHER_NO_CACHE: |
127 | - return isset(self::$data[$this->prefix.$name]); |
|
127 | + return isset(self::$data[$this->prefix . $name]); |
|
128 | 128 | break; |
129 | 129 | |
130 | 130 | case CACHER_XCACHE: |
131 | - return xcache_isset($this->prefix.$name) && ($this->__get($name) !== null); |
|
131 | + return xcache_isset($this->prefix . $name) && ($this->__get($name) !== null); |
|
132 | 132 | break; |
133 | 133 | } |
134 | 134 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | public function unset_by_prefix($prefix_unset = '') { |
151 | 151 | static $array_clear; |
152 | - !$array_clear ? $array_clear = function(&$v,$k,$p) { |
|
152 | + !$array_clear ? $array_clear = function(&$v, $k, $p) { |
|
153 | 153 | strpos($k, $p) === 0 ? $v = NULL : false; |
154 | 154 | } : false; |
155 | 155 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | break; |
162 | 162 | |
163 | 163 | case CACHER_XCACHE: |
164 | - if(!function_exists('xcache_unset_by_prefix')) { |
|
164 | + if (!function_exists('xcache_unset_by_prefix')) { |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | return xcache_unset_by_prefix($this->prefix . $prefix_unset); |
@@ -177,13 +177,13 @@ discard block |
||
177 | 177 | protected function make_element_name($args, $diff = 0) { |
178 | 178 | $num_args = count($args); |
179 | 179 | |
180 | - if($num_args < 1) { |
|
180 | + if ($num_args < 1) { |
|
181 | 181 | return false; |
182 | 182 | } |
183 | 183 | |
184 | 184 | $name = ''; |
185 | 185 | $aName = array(); |
186 | - for($i = 0; $i <= $num_args - 1 - $diff; $i++) { |
|
186 | + for ($i = 0; $i <= $num_args - 1 - $diff; $i++) { |
|
187 | 187 | $name .= "[{$args[$i]}]"; |
188 | 188 | array_unshift($aName, $name); |
189 | 189 | } |
@@ -195,15 +195,15 @@ discard block |
||
195 | 195 | $args = func_get_args(); |
196 | 196 | $name = $this->make_element_name($args, 1); |
197 | 197 | |
198 | - if(!$name) { |
|
198 | + if (!$name) { |
|
199 | 199 | return NULL; |
200 | 200 | } |
201 | 201 | |
202 | - if($this->$name[0] === NULL) { |
|
203 | - for($i = count($name) - 1; $i > 0; $i--) { |
|
202 | + if ($this->$name[0] === NULL) { |
|
203 | + for ($i = count($name) - 1; $i > 0; $i--) { |
|
204 | 204 | $cName = "{$name[$i]}_COUNT"; |
205 | - $cName1 = "{$name[$i-1]}_COUNT"; |
|
206 | - if($this->$cName1 == NULL || $i == 1) { |
|
205 | + $cName1 = "{$name[$i - 1]}_COUNT"; |
|
206 | + if ($this->$cName1 == NULL || $i == 1) { |
|
207 | 207 | $this->$cName++; |
208 | 208 | } |
209 | 209 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | |
216 | 216 | public function array_get() { |
217 | 217 | $name = $this->make_element_name(func_get_args()); |
218 | - if(!$name) { |
|
218 | + if (!$name) { |
|
219 | 219 | return NULL; |
220 | 220 | } |
221 | 221 | return $this->$name[0]; |
@@ -223,12 +223,12 @@ discard block |
||
223 | 223 | |
224 | 224 | public function array_count() { |
225 | 225 | $name = $this->make_element_name(func_get_args()); |
226 | - if(!$name) { |
|
226 | + if (!$name) { |
|
227 | 227 | return 0; |
228 | 228 | } |
229 | 229 | $cName = "{$name[0]}_COUNT"; |
230 | 230 | $retVal = $this->$cName; |
231 | - if(!$retVal) { |
|
231 | + if (!$retVal) { |
|
232 | 232 | $retVal = NULL; |
233 | 233 | } |
234 | 234 | return $retVal; |
@@ -237,18 +237,18 @@ discard block |
||
237 | 237 | public function array_unset() { |
238 | 238 | $name = $this->make_element_name(func_get_args()); |
239 | 239 | |
240 | - if(!$name) { |
|
240 | + if (!$name) { |
|
241 | 241 | return false; |
242 | 242 | } |
243 | 243 | $this->unset_by_prefix($name[0]); |
244 | 244 | |
245 | - for($i = 1; $i < count($name); $i++) { |
|
245 | + for ($i = 1; $i < count($name); $i++) { |
|
246 | 246 | $cName = "{$name[$i]}_COUNT"; |
247 | - $cName1 = "{$name[$i-1]}_COUNT"; |
|
247 | + $cName1 = "{$name[$i - 1]}_COUNT"; |
|
248 | 248 | |
249 | - if($i == 1 || $this->$cName1 === NULL) { |
|
249 | + if ($i == 1 || $this->$cName1 === NULL) { |
|
250 | 250 | $this->$cName--; |
251 | - if($this->$cName <= 0) { |
|
251 | + if ($this->$cName <= 0) { |
|
252 | 252 | unset($this->$cName); |
253 | 253 | } |
254 | 254 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | public function unset_by_prefix($prefix_unset = '') { |
151 | 151 | static $array_clear; |
152 | 152 | !$array_clear ? $array_clear = function(&$v,$k,$p) { |
153 | - strpos($k, $p) === 0 ? $v = NULL : false; |
|
153 | + strpos($k, $p) === 0 ? $v = null : false; |
|
154 | 154 | } : false; |
155 | 155 | |
156 | 156 | switch (self::$mode) { |
@@ -196,14 +196,14 @@ discard block |
||
196 | 196 | $name = $this->make_element_name($args, 1); |
197 | 197 | |
198 | 198 | if(!$name) { |
199 | - return NULL; |
|
199 | + return null; |
|
200 | 200 | } |
201 | 201 | |
202 | - if($this->$name[0] === NULL) { |
|
202 | + if($this->$name[0] === null) { |
|
203 | 203 | for($i = count($name) - 1; $i > 0; $i--) { |
204 | 204 | $cName = "{$name[$i]}_COUNT"; |
205 | 205 | $cName1 = "{$name[$i-1]}_COUNT"; |
206 | - if($this->$cName1 == NULL || $i == 1) { |
|
206 | + if($this->$cName1 == null || $i == 1) { |
|
207 | 207 | $this->$cName++; |
208 | 208 | } |
209 | 209 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | public function array_get() { |
217 | 217 | $name = $this->make_element_name(func_get_args()); |
218 | 218 | if(!$name) { |
219 | - return NULL; |
|
219 | + return null; |
|
220 | 220 | } |
221 | 221 | return $this->$name[0]; |
222 | 222 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $cName = "{$name[0]}_COUNT"; |
230 | 230 | $retVal = $this->$cName; |
231 | 231 | if(!$retVal) { |
232 | - $retVal = NULL; |
|
232 | + $retVal = null; |
|
233 | 233 | } |
234 | 234 | return $retVal; |
235 | 235 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | $cName = "{$name[$i]}_COUNT"; |
247 | 247 | $cName1 = "{$name[$i-1]}_COUNT"; |
248 | 248 | |
249 | - if($i == 1 || $this->$cName1 === NULL) { |
|
249 | + if($i == 1 || $this->$cName1 === null) { |
|
250 | 250 | $this->$cName--; |
251 | 251 | if($this->$cName <= 0) { |
252 | 252 | unset($this->$cName); |
@@ -173,6 +173,9 @@ |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | |
176 | + /** |
|
177 | + * @param string $path |
|
178 | + */ |
|
176 | 179 | protected function lng_try_filepath($path, $file_path_relative) { |
177 | 180 | $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative; |
178 | 181 | return file_exists($file_path) ? $file_path : false; |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | |
29 | 29 | $this->container = array(); |
30 | 30 | |
31 | - if(classSupernova::$cache->_MODE != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) { |
|
31 | + if (classSupernova::$cache->_MODE != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) { |
|
32 | 32 | $this->cache = classSupernova::$cache; |
33 | 33 | classSupernova::log_file('locale.__constructor: Cache is present'); |
34 | 34 | //$this->cache->unset_by_prefix($this->cache_prefix); // TODO - remove? 'cause debug! |
35 | 35 | } |
36 | 36 | |
37 | - if($enable_stat_usage && empty($this->stat_usage)) { |
|
37 | + if ($enable_stat_usage && empty($this->stat_usage)) { |
|
38 | 38 | $this->enable_stat_usage = $enable_stat_usage; |
39 | 39 | $this->usage_stat_load(); |
40 | 40 | // TODO shutdown function |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | unset($fallback[$this->active]); |
61 | 61 | |
62 | 62 | // Проходим по оставшимся локалям |
63 | - foreach($fallback as $try_language) { |
|
63 | + foreach ($fallback as $try_language) { |
|
64 | 64 | // Если нет такой строки - пытаемся вытащить из кэша |
65 | - if(!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
65 | + if (!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
66 | 66 | $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix . $try_language . '_' . $offset); |
67 | 67 | // Записываем результат работы кэша |
68 | 68 | $locale_cache_statistic['queries']++; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | // Если мы как-то где-то нашли строку... |
74 | - if(isset($this->container[$try_language][$offset])) { |
|
74 | + if (isset($this->container[$try_language][$offset])) { |
|
75 | 75 | // ...значит она получена в результате фоллбэка и записываем её в кэш и контейнер |
76 | 76 | $this[$offset] = $this->container[$try_language][$offset]; |
77 | 77 | $locale_cache_statistic['fallbacks']++; |
@@ -85,15 +85,15 @@ discard block |
||
85 | 85 | $this->container[$this->active][] = $value; |
86 | 86 | } else { |
87 | 87 | $this->container[$this->active][$offset] = $value; |
88 | - if($this->cache) { |
|
88 | + if ($this->cache) { |
|
89 | 89 | $this->cache->__set($this->cache_prefix_lang . $offset, $value); |
90 | 90 | } |
91 | 91 | } |
92 | 92 | } |
93 | 93 | public function offsetExists($offset) { |
94 | 94 | // Шорткат если у нас уже есть строка в памяти PHP |
95 | - if(!isset($this->container[$this->active][$offset])) { |
|
96 | - if(!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) { |
|
95 | + if (!isset($this->container[$this->active][$offset])) { |
|
96 | + if (!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) { |
|
97 | 97 | // Если нету такой строки - делаем фоллбэк |
98 | 98 | $this->locale_string_fallback($offset); |
99 | 99 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | public function offsetGet($offset) { |
109 | 109 | $value = $this->offsetExists($offset) ? $this->container[$this->active][$offset] : null; |
110 | - if($this->enable_stat_usage) { |
|
110 | + if ($this->enable_stat_usage) { |
|
111 | 111 | $this->usage_stat_log($offset, $value); |
112 | 112 | } |
113 | 113 | return $value; |
@@ -124,24 +124,24 @@ discard block |
||
124 | 124 | public function usage_stat_load() { |
125 | 125 | global $sn_cache; |
126 | 126 | |
127 | - $this->stat_usage = $sn_cache->lng_stat_usage = array(); // TODO for debug |
|
128 | - if(empty($this->stat_usage)) { |
|
127 | + $this->stat_usage = $sn_cache->lng_stat_usage = array(); // TODO for debug |
|
128 | + if (empty($this->stat_usage)) { |
|
129 | 129 | $query = doquery("SELECT * FROM {{lng_usage_stat}}"); |
130 | - while($row = db_fetch($query)) { |
|
130 | + while ($row = db_fetch($query)) { |
|
131 | 131 | $this->stat_usage[$row['lang_code'] . ':' . $row['string_id'] . ':' . $row['file'] . ':' . $row['line']] = $row['is_empty']; |
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
135 | 135 | public function usage_stat_save() { |
136 | - if(!empty($this->stat_usage_new)) { |
|
136 | + if (!empty($this->stat_usage_new)) { |
|
137 | 137 | global $sn_cache; |
138 | 138 | $sn_cache->lng_stat_usage = $this->stat_usage; |
139 | 139 | doquery("SELECT 1 FROM {{lng_usage_stat}} LIMIT 1"); |
140 | - foreach($this->stat_usage_new as &$value) { |
|
141 | - foreach($value as &$value2) { |
|
140 | + foreach ($this->stat_usage_new as &$value) { |
|
141 | + foreach ($value as &$value2) { |
|
142 | 142 | $value2 = '"' . db_escape($value2) . '"'; |
143 | 143 | } |
144 | - $value = '(' . implode(',', $value) .')'; |
|
144 | + $value = '(' . implode(',', $value) . ')'; |
|
145 | 145 | } |
146 | 146 | doquery("REPLACE INTO {{lng_usage_stat}} (lang_code,string_id,`file`,line,is_empty,locale) VALUES " . implode(',', $this->stat_usage_new)); |
147 | 147 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $file = str_replace('\\', '/', substr($trace[1]['file'], strlen(SN_ROOT_PHYSICAL) - 1)); |
155 | 155 | |
156 | 156 | $string_id = $this->active . ':' . $offset . ':' . $file . ':' . $trace[1]['line']; |
157 | - if(!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != $empty) { |
|
157 | + if (!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != $empty) { |
|
158 | 158 | $this->stat_usage[$string_id] = empty($value); |
159 | 159 | $this->stat_usage_new[] = array( |
160 | 160 | 'lang_code' => $this->active, |
@@ -194,11 +194,11 @@ discard block |
||
194 | 194 | $cache_file_key = $this->cache_prefix_lang . '__' . $filename; |
195 | 195 | |
196 | 196 | // Подключен ли внешний кэш? |
197 | - if($this->cache) { |
|
197 | + if ($this->cache) { |
|
198 | 198 | // Загружен ли уже данный файл? |
199 | 199 | $cache_file_status = $this->cache->__get($cache_file_key); |
200 | 200 | classSupernova::log_file("locale.include: Cache - '{$filename}' has key '{$cache_file_key}' and is " . ($cache_file_status ? 'already loaded - EXIT' : 'EMPTY'), $cache_file_status ? -1 : 0); |
201 | - if($cache_file_status) { |
|
201 | + if ($cache_file_status) { |
|
202 | 202 | // Если да - повторять загрузку нет смысла |
203 | 203 | return null; |
204 | 204 | } |
@@ -212,35 +212,35 @@ discard block |
||
212 | 212 | $this->make_fallback($language); |
213 | 213 | |
214 | 214 | $file_path = ''; |
215 | - foreach($this->fallback as $lang_try) { |
|
216 | - if(!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
215 | + foreach ($this->fallback as $lang_try) { |
|
216 | + if (!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
217 | 217 | continue; |
218 | 218 | } |
219 | 219 | |
220 | - if($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
220 | + if ($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
221 | 221 | break; |
222 | 222 | } |
223 | 223 | |
224 | - if($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
224 | + if ($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
225 | 225 | break; |
226 | 226 | } |
227 | 227 | |
228 | 228 | $file_path = ''; |
229 | 229 | } |
230 | 230 | |
231 | - if($file_path) { |
|
231 | + if ($file_path) { |
|
232 | 232 | include($file_path); |
233 | 233 | |
234 | - if(!empty($a_lang_array)) { |
|
234 | + if (!empty($a_lang_array)) { |
|
235 | 235 | $this->merge($a_lang_array); |
236 | 236 | |
237 | 237 | // Загрузка данных из файла в кэш |
238 | - if($this->cache) { |
|
238 | + if ($this->cache) { |
|
239 | 239 | classSupernova::log_file("Locale: loading '{$filename}' into cache"); |
240 | - foreach($a_lang_array as $key => $value) { |
|
240 | + foreach ($a_lang_array as $key => $value) { |
|
241 | 241 | $value_cache_key = $this->cache_prefix_lang . $key; |
242 | - if($this->cache->__isset($value_cache_key)) { |
|
243 | - if(is_array($value)) { |
|
242 | + if ($this->cache->__isset($value_cache_key)) { |
|
243 | + if (is_array($value)) { |
|
244 | 244 | $alt_value = $this->cache->__get($value_cache_key); |
245 | 245 | $value = array_replace_recursive($alt_value, $value); |
246 | 246 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | - if($this->cache) { |
|
253 | + if ($this->cache) { |
|
254 | 254 | $this->cache->__set($cache_file_key, true); |
255 | 255 | } |
256 | 256 | |
@@ -263,14 +263,14 @@ discard block |
||
263 | 263 | } |
264 | 264 | |
265 | 265 | public function lng_load_i18n($i18n) { |
266 | - if(!isset($i18n)) { |
|
266 | + if (!isset($i18n)) { |
|
267 | 267 | return; |
268 | 268 | } |
269 | 269 | |
270 | - foreach($i18n as $i18n_data) { |
|
271 | - if(is_string($i18n_data)) { |
|
270 | + foreach ($i18n as $i18n_data) { |
|
271 | + if (is_string($i18n_data)) { |
|
272 | 272 | $this->lng_include($i18n_data); |
273 | - } elseif(is_array($i18n_data)) { |
|
273 | + } elseif (is_array($i18n_data)) { |
|
274 | 274 | $this->lng_include($i18n_data['file'], $i18n_data['path']); |
275 | 275 | } |
276 | 276 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | |
289 | 289 | classSupernova::log_file("locale.switch: Trying to switch language to '{$language_new}'"); |
290 | 290 | |
291 | - if($language_new == $this->active) { |
|
291 | + if ($language_new == $this->active) { |
|
292 | 292 | classSupernova::log_file("locale.switch: New language '{$language_new}' is equal to current language '{$this->active}' - EXIT", -1); |
293 | 293 | return false; |
294 | 294 | } |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | $this['LANG_INFO'] = $this->lng_get_info($this->active); |
300 | 300 | $this->make_fallback($this->active); |
301 | 301 | |
302 | - if($this->cache) { |
|
302 | + if ($this->cache) { |
|
303 | 303 | $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang . '__INIT'); |
304 | 304 | classSupernova::log_file("locale.switch: Cache for '{$this->active}' prefixed '{$this->cache_prefix_lang}' is " . ($cache_lang_init_status ? 'already loaded. Doing nothing - EXIT' : 'EMPTY'), $cache_lang_init_status ? -1 : 0); |
305 | - if($cache_lang_init_status) { |
|
305 | + if ($cache_lang_init_status) { |
|
306 | 306 | return false; |
307 | 307 | } |
308 | 308 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | // Loading global language files |
319 | 319 | $this->lng_load_i18n($sn_mvc['i18n']['']); |
320 | 320 | |
321 | - if($this->cache) { |
|
321 | + if ($this->cache) { |
|
322 | 322 | classSupernova::log_file("locale.switch: Cache - setting flag " . $this->cache_prefix_lang . '__INIT'); |
323 | 323 | $this->cache->__set($this->cache_prefix_lang . '__INIT', true); |
324 | 324 | } |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | public function lng_get_info($entry) { |
333 | 333 | $file_name = SN_ROOT_PHYSICAL . 'language/' . $entry . '/language.mo.php'; |
334 | 334 | $lang_info = array(); |
335 | - if(file_exists($file_name)) { |
|
335 | + if (file_exists($file_name)) { |
|
336 | 336 | include($file_name); |
337 | 337 | } |
338 | 338 | |
@@ -340,15 +340,15 @@ discard block |
||
340 | 340 | } |
341 | 341 | |
342 | 342 | public function lng_get_list() { |
343 | - if(empty($this->lang_list)) { |
|
343 | + if (empty($this->lang_list)) { |
|
344 | 344 | $this->lang_list = array(); |
345 | 345 | |
346 | 346 | $path = SN_ROOT_PHYSICAL . 'language/'; |
347 | 347 | $dir = dir($path); |
348 | - while(false !== ($entry = $dir->read())) { |
|
349 | - if(is_dir($path . $entry) && $entry[0] != '.') { |
|
348 | + while (false !== ($entry = $dir->read())) { |
|
349 | + if (is_dir($path . $entry) && $entry[0] != '.') { |
|
350 | 350 | $lang_info = $this->lng_get_info($entry); |
351 | - if($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
351 | + if ($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
352 | 352 | $this->lang_list[$lang_info['LANG_NAME_ISO2']] = $lang_info; |
353 | 353 | } |
354 | 354 | } |
@@ -18,6 +18,11 @@ discard block |
||
18 | 18 | |
19 | 19 | // TODO - НЕ ОБЯЗАТЕЛЬНО ОТПРАВЛЯТЬ ЧЕРЕЗ ЕМЕЙЛ! ЕСЛИ ЭТО ФЕЙСБУЧЕК ИЛИ ВКШЕЧКА - МОЖНО ЧЕРЕЗ ЛС ПИСАТЬ!! |
20 | 20 | // TODO - OK 4.6 |
21 | + |
|
22 | + /** |
|
23 | + * @param integer $confirmation_type_safe |
|
24 | + * @param string $email_unsafe |
|
25 | + */ |
|
21 | 26 | public function db_confirmation_get_latest_by_type_and_email($confirmation_type_safe, $email_unsafe) { |
22 | 27 | $email_safe = $this->db->db_escape($email_unsafe); |
23 | 28 | |
@@ -26,12 +31,21 @@ discard block |
||
26 | 31 | `type` = {$confirmation_type_safe} AND `email` = '{$email_safe}' ORDER BY create_time DESC LIMIT 1;", true); |
27 | 32 | } |
28 | 33 | // TODO - OK 4.6 |
34 | + |
|
35 | + /** |
|
36 | + * @param integer $confirmation_type_safe |
|
37 | + */ |
|
29 | 38 | public function db_confirmation_delete_by_type_and_email($confirmation_type_safe, $email_unsafe) { |
30 | 39 | $email_safe = $this->db->db_escape($email_unsafe); |
31 | 40 | |
32 | 41 | return $this->db->doquery("DELETE FROM {{confirmations}} WHERE `type` = {$confirmation_type_safe} AND `email` = '{$email_safe}'"); |
33 | 42 | } |
34 | 43 | // TODO - OK 4.6 |
44 | + |
|
45 | + /** |
|
46 | + * @param integer $confirmation_type_safe |
|
47 | + * @param string $email_unsafe |
|
48 | + */ |
|
35 | 49 | public function db_confirmation_get_unique_code_by_type_and_email($confirmation_type_safe, $email_unsafe) { |
36 | 50 | $email_safe = $this->db->db_escape($email_unsafe); |
37 | 51 | |
@@ -50,6 +64,11 @@ discard block |
||
50 | 64 | return $confirm_code_unsafe; |
51 | 65 | } |
52 | 66 | // TODO - OK 4.6 |
67 | + |
|
68 | + /** |
|
69 | + * @param integer $confirmation_type_safe |
|
70 | + * @param string $confirmation_code_unsafe |
|
71 | + */ |
|
53 | 72 | public function db_confirmation_get_by_type_and_code($confirmation_type_safe, $confirmation_code_unsafe) { |
54 | 73 | $confirmation_code_safe = $this->db->db_escape($confirmation_code_unsafe); |
55 | 74 |
@@ -41,7 +41,7 @@ |
||
41 | 41 | // $query = static::$db->doquery("SELECT `id` FROM {{confirmations}} WHERE `code` = '{$confirm_code_safe}' AND `type` = {$confirmation_type_safe} FOR UPDATE", true); |
42 | 42 | // Тип не нужен для проверки - код подтверждения должен быть уникален от слова "совсем" |
43 | 43 | $query = $this->db->doquery("SELECT `id` FROM {{confirmations}} WHERE `code` = '{$confirm_code_safe}' FOR UPDATE", true); |
44 | - } while($query); |
|
44 | + } while ($query); |
|
45 | 45 | |
46 | 46 | $this->db->doquery( |
47 | 47 | "REPLACE INTO {{confirmations}} |