@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Защита от двойного инита |
4 | -if(defined('INIT')) { |
|
4 | +if (defined('INIT')) { |
|
5 | 5 | return; |
6 | 6 | } |
7 | 7 | |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | version_compare(PHP_VERSION, '5.3.2') < 0 ? die('FATAL ERROR: SuperNova REQUIRE PHP version > 5.3.2') : false; |
21 | 21 | |
22 | 22 | // Бенчмарк |
23 | -register_shutdown_function(function () { |
|
24 | - if(defined('IN_AJAX')) { |
|
23 | +register_shutdown_function(function() { |
|
24 | + if (defined('IN_AJAX')) { |
|
25 | 25 | return; |
26 | 26 | } |
27 | 27 | |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | (!empty($locale_cache_statistic['misses']) ? ', LOCALE MISSED' : '') . |
32 | 32 | (class_exists('classSupernova') && is_object(classSupernova::$db) ? ', DB time: ' . classSupernova::$db->time_mysql_total . 'ms' : '') . |
33 | 33 | '</div>'); |
34 | - if($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL . 'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL . 'badqrys.txt') > 0) { |
|
34 | + if ($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL . 'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL . 'badqrys.txt') > 0) { |
|
35 | 35 | echo '<a href="badqrys.txt" target="_blank" style="color:red">', 'HACK ALERT!', '</a>'; |
36 | 36 | } |
37 | 37 | |
38 | - if(!empty($locale_cache_statistic['misses'])) { |
|
38 | + if (!empty($locale_cache_statistic['misses'])) { |
|
39 | 39 | print('<!--'); |
40 | 40 | pdump($locale_cache_statistic); |
41 | 41 | print('-->'); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | define('SN_TIME_NOW_GMT_STRING', gmdate(DATE_ATOM, SN_TIME_NOW)); |
57 | 57 | |
58 | -if(strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) { |
|
58 | +if (strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) { |
|
59 | 59 | define('SN_GOOGLE', true); |
60 | 60 | } |
61 | 61 | |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | $debug = new debug(); |
106 | 106 | classSupernova::debug_set_handler($debug); |
107 | 107 | |
108 | -spl_autoload_register(function ($class) { |
|
109 | - if(file_exists(SN_ROOT_PHYSICAL . 'includes/classes/' . $class . '.php')) { |
|
108 | +spl_autoload_register(function($class) { |
|
109 | + if (file_exists(SN_ROOT_PHYSICAL . 'includes/classes/' . $class . '.php')) { |
|
110 | 110 | require_once SN_ROOT_PHYSICAL . 'includes/classes/' . $class . '.php'; |
111 | 111 | } |
112 | 112 | }); |
113 | 113 | |
114 | -spl_autoload_register(function ($class) { |
|
115 | - if(file_exists(SN_ROOT_PHYSICAL . 'includes/classes/UBE/' . $class . '.php')) { |
|
114 | +spl_autoload_register(function($class) { |
|
115 | + if (file_exists(SN_ROOT_PHYSICAL . 'includes/classes/UBE/' . $class . '.php')) { |
|
116 | 116 | require_once SN_ROOT_PHYSICAL . 'includes/classes/UBE/' . $class . '.php'; |
117 | 117 | } |
118 | 118 | }); |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | |
178 | 178 | sn_sys_load_php_files(SN_ROOT_PHYSICAL . "includes/functions/", PHP_EX); |
179 | 179 | |
180 | -spl_autoload_register(function ($class) { |
|
181 | - if(file_exists('includes/classes/' . $class . '.php')) { |
|
180 | +spl_autoload_register(function($class) { |
|
181 | + if (file_exists('includes/classes/' . $class . '.php')) { |
|
182 | 182 | require_once 'includes/classes/' . $class . '.php'; |
183 | - } elseif(file_exists('includes/classes/UBE/' . $class . '.php')) { |
|
183 | + } elseif (file_exists('includes/classes/UBE/' . $class . '.php')) { |
|
184 | 184 | require_once 'includes/classes/UBE/' . $class . '.php'; |
185 | 185 | } else { |
186 | 186 | // die("Can't find {$class} class"); |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | // Но нужно, пока у нас есть не MVC-страницы |
215 | 215 | $sn_page_data = $sn_data['pages'][$sn_page_name]; |
216 | 216 | $sn_page_name_file = 'includes/pages/' . $sn_page_data['filename'] . DOT_PHP_EX; |
217 | -if($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) { |
|
217 | +if ($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) { |
|
218 | 218 | require_once($sn_page_name_file); |
219 | - if(is_array($sn_page_data['options'])) { |
|
219 | + if (is_array($sn_page_data['options'])) { |
|
220 | 220 | $supernova->options = array_merge($supernova->options, $sn_page_data['options']); |
221 | 221 | } |
222 | 222 | } |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | $load_order = array(); |
232 | 232 | $sn_req = array(); |
233 | 233 | |
234 | -foreach(sn_module::$sn_module as $loaded_module_name => $module_data) { |
|
234 | +foreach (sn_module::$sn_module as $loaded_module_name => $module_data) { |
|
235 | 235 | $load_order[$loaded_module_name] = isset($module_data->manifest['load_order']) && !empty($module_data->manifest['load_order']) ? $module_data->manifest['load_order'] : 100000; |
236 | - if(isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) { |
|
237 | - foreach($module_data->manifest['require'] as $require_name) { |
|
236 | + if (isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) { |
|
237 | + foreach ($module_data->manifest['require'] as $require_name) { |
|
238 | 238 | $sn_req[$loaded_module_name][$require_name] = 0; |
239 | 239 | } |
240 | 240 | } |
@@ -247,10 +247,10 @@ discard block |
||
247 | 247 | do { |
248 | 248 | $prev_order = $load_order; |
249 | 249 | |
250 | - foreach($sn_req as $loaded_module_name => &$req_data) { |
|
250 | + foreach ($sn_req as $loaded_module_name => &$req_data) { |
|
251 | 251 | $level = 1; |
252 | - foreach($req_data as $req_name => &$req_level) { |
|
253 | - if($load_order[$req_name] == -1 || !isset($load_order[$req_name])) { |
|
252 | + foreach ($req_data as $req_name => &$req_level) { |
|
253 | + if ($load_order[$req_name] == -1 || !isset($load_order[$req_name])) { |
|
254 | 254 | $level = $req_level = -1; |
255 | 255 | break; |
256 | 256 | } else { |
@@ -258,20 +258,20 @@ discard block |
||
258 | 258 | } |
259 | 259 | $req_level = $load_order[$req_name]; |
260 | 260 | } |
261 | - if($level > $load_order[$loaded_module_name] || $level == -1) { |
|
261 | + if ($level > $load_order[$loaded_module_name] || $level == -1) { |
|
262 | 262 | $load_order[$loaded_module_name] = $level; |
263 | 263 | } |
264 | 264 | } |
265 | -} while($prev_order != $load_order); |
|
265 | +} while ($prev_order != $load_order); |
|
266 | 266 | |
267 | 267 | asort($load_order); |
268 | 268 | |
269 | 269 | // Инициализируем модули |
270 | 270 | // По нормальным делам это должна быть загрузка модулей и лишь затем инициализация - что бы минимизировать размер процесса в памяти |
271 | -foreach($load_order as $loaded_module_name => $load_order_order) { |
|
272 | - if($load_order_order >= 0) { |
|
271 | +foreach ($load_order as $loaded_module_name => $load_order_order) { |
|
272 | + if ($load_order_order >= 0) { |
|
273 | 273 | sn_module::$sn_module[$loaded_module_name]->check_status(); |
274 | - if(!sn_module::$sn_module[$loaded_module_name]->manifest['active']) { |
|
274 | + if (!sn_module::$sn_module[$loaded_module_name]->manifest['active']) { |
|
275 | 275 | unset(sn_module::$sn_module[$loaded_module_name]); |
276 | 276 | continue; |
277 | 277 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | unset($sn_req); |
289 | 289 | |
290 | 290 | // А теперь проверяем - поддерживают ли у нас загруженный код такую страницу |
291 | -if(!isset($sn_data['pages'][$sn_page_name])) { |
|
291 | +if (!isset($sn_data['pages'][$sn_page_name])) { |
|
292 | 292 | $sn_page_name = ''; |
293 | 293 | } |
294 | 294 | |
@@ -296,6 +296,6 @@ discard block |
||
296 | 296 | $lang = new classLocale($config->server_locale_log_usage); |
297 | 297 | $lang->lng_switch(sys_get_param_str('lang')); |
298 | 298 | |
299 | -if(!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) { |
|
299 | +if (!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) { |
|
300 | 300 | require_once "init_secondary.php"; |
301 | 301 | } |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | |
19 | 19 | $sensorLevel = mrc_get_level($user, $planetrow, STRUC_MOON_PHALANX); |
20 | 20 | if (!intval($sensorLevel)) { |
21 | - message (classLocale::$lang['phalanx_nosensoravailable'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
21 | + message(classLocale::$lang['phalanx_nosensoravailable'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | if ($planetrow['planet_type'] != PT_MOON) { |
25 | - message (classLocale::$lang['phalanx_onlyformoons'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
25 | + message(classLocale::$lang['phalanx_onlyformoons'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | $scan_galaxy = sys_get_param_int('galaxy'); |
29 | 29 | $scan_system = sys_get_param_int('system'); |
30 | 30 | $scan_planet = sys_get_param_int('planet'); |
31 | -$scan_planet_type = 1; // sys_get_param_int('planettype'); |
|
31 | +$scan_planet_type = 1; // sys_get_param_int('planettype'); |
|
32 | 32 | $id = sys_get_param_id('id'); |
33 | 33 | |
34 | 34 | $source_galaxy = $planetrow['galaxy']; |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | $sensorRange = GetPhalanxRange($sensorLevel); |
39 | 39 | |
40 | 40 | $system_distance = abs($source_system - $scan_system); |
41 | -if($system_distance > $sensorRange || $scan_galaxy != $source_galaxy) |
|
41 | +if ($system_distance > $sensorRange || $scan_galaxy != $source_galaxy) |
|
42 | 42 | { |
43 | - message (classLocale::$lang['phalanx_rangeerror'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
43 | + message(classLocale::$lang['phalanx_rangeerror'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | $cost = $sensorLevel * 1000; |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | $planet_scanned = db_planet_by_gspt($scan_galaxy, $scan_system, $scan_planet, $scan_planet_type); |
54 | -if(!$planet_scanned['id']) |
|
54 | +if (!$planet_scanned['id']) |
|
55 | 55 | { |
56 | 56 | message(classLocale::$lang['phalanx_planet_not_exists'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
57 | 57 | } |
58 | 58 | |
59 | -if($planet_scanned['destruyed']) |
|
59 | +if ($planet_scanned['destruyed']) |
|
60 | 60 | { |
61 | - message (classLocale::$lang['phalanx_planet_destroyed'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
61 | + message(classLocale::$lang['phalanx_planet_destroyed'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | db_planet_set_by_id($user['current_planet'], "deuterium = deuterium - {$cost}"); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -define('INSIDE' , true); |
|
4 | -define('INSTALL' , false); |
|
3 | +define('INSIDE', true); |
|
4 | +define('INSTALL', false); |
|
5 | 5 | define('IN_ADMIN', true); |
6 | 6 | |
7 | 7 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | global $config, $lang, $user; |
10 | 10 | |
11 | 11 | // if($user['authlevel'] < 1) |
12 | -if($user['authlevel'] < 3) { |
|
12 | +if ($user['authlevel'] < 3) { |
|
13 | 13 | AdminMessage(classLocale::$lang['adm_err_denied']); |
14 | 14 | } |
15 | 15 | |
16 | 16 | $planet_active = sys_get_param_int('planet_active'); |
17 | -if(!$planet_active) { |
|
17 | +if (!$planet_active) { |
|
18 | 18 | $planet_type = sys_get_param_int('planet_type', 1); |
19 | 19 | $planet_type = $planet_type == 3 ? 3 : 1; |
20 | 20 | } else { |
@@ -43,8 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | $page_title = |
45 | 45 | classLocale::$lang['adm_planet_list_title'] . ': ' . |
46 | - ($planet_active ? classLocale::$lang['adm_planet_active'] : |
|
47 | - ($planet_type ? ($planet_type == 3 ? classLocale::$lang['sys_moons'] : classLocale::$lang['sys_planets']) : '') |
|
46 | + ($planet_active ? classLocale::$lang['adm_planet_active'] : ($planet_type ? ($planet_type == 3 ? classLocale::$lang['sys_moons'] : classLocale::$lang['sys_planets']) : '') |
|
48 | 47 | ); |
49 | 48 | $template->assign_vars(array( |
50 | 49 | 'PAGE_TITLE' => $page_title, |
@@ -15,34 +15,34 @@ discard block |
||
15 | 15 | $template = gettemplate('notes', true); |
16 | 16 | |
17 | 17 | $result = array(); |
18 | -if(($result_message = sys_get_param_str('MESSAGE')) && isset(classLocale::$lang[$result_message])) { |
|
18 | +if (($result_message = sys_get_param_str('MESSAGE')) && isset(classLocale::$lang[$result_message])) { |
|
19 | 19 | $result[] = array('STATUS' => sys_get_param_int('STATUS'), 'MESSAGE' => classLocale::$lang[$result_message]); |
20 | 20 | } |
21 | 21 | |
22 | 22 | $note_id_edit = sys_get_param_id('note_id_edit'); |
23 | -if(sys_get_param('note_delete')) { |
|
23 | +if (sys_get_param('note_delete')) { |
|
24 | 24 | try { |
25 | 25 | $not = ''; |
26 | 26 | $query_where = ''; |
27 | - switch(sys_get_param_str('note_delete_range')) { |
|
27 | + switch (sys_get_param_str('note_delete_range')) { |
|
28 | 28 | case 'all': |
29 | 29 | break; |
30 | 30 | |
31 | 31 | case 'marked_not': |
32 | 32 | $not = 'NOT'; |
33 | 33 | case 'marked': |
34 | - if(!is_array($notes_marked = sys_get_param('note'))) { |
|
34 | + if (!is_array($notes_marked = sys_get_param('note'))) { |
|
35 | 35 | throw new Exception('note_err_none_selected', ERR_WARNING); |
36 | 36 | } |
37 | 37 | |
38 | 38 | $notes_marked_filtered = array(); |
39 | - foreach($notes_marked as $note_id => $note_select) { |
|
40 | - if($note_select == 'on' && $note_id = idval($note_id)) { |
|
39 | + foreach ($notes_marked as $note_id => $note_select) { |
|
40 | + if ($note_select == 'on' && $note_id = idval($note_id)) { |
|
41 | 41 | $notes_marked_filtered[] = $note_id; |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | - if(empty($notes_marked_filtered)) { |
|
45 | + if (empty($notes_marked_filtered)) { |
|
46 | 46 | throw new Exception('note_err_none_selected', ERR_WARNING); |
47 | 47 | } |
48 | 48 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | db_note_list_delete($user, $query_where); |
60 | 60 | sn_db_transaction_commit(); |
61 | 61 | throw new Exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE); |
62 | - } catch(Exception $e) { |
|
62 | + } catch (Exception $e) { |
|
63 | 63 | $note_id_edit = 0; |
64 | 64 | sn_db_transaction_rollback(); |
65 | 65 | $result[] = array( |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | 'MESSAGE' => classLocale::$lang[$e->getMessage()], |
68 | 68 | ); |
69 | 69 | } |
70 | -} elseif(($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) { |
|
70 | +} elseif (($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) { |
|
71 | 71 | $note_title == db_escape(classLocale::$lang['note_new_title']) ? $note_title = '' : false; |
72 | 72 | ($note_text = sys_get_param_str('note_text')) == db_escape(classLocale::$lang['note_new_text']) ? $note_text = '' : false; |
73 | 73 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $note_system = max(0, min(sys_get_param_id('note_system'), $config->game_maxSystem)); |
77 | 77 | $note_planet = max(0, min(sys_get_param_id('note_planet'), $config->game_maxPlanet + 1)); |
78 | 78 | |
79 | - if(!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) { |
|
79 | + if (!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) { |
|
80 | 80 | throw new exception('note_err_note_empty', ERR_WARNING); |
81 | 81 | } |
82 | 82 | |
@@ -85,15 +85,15 @@ discard block |
||
85 | 85 | $note_sticky = intval(sys_get_param_id('note_sticky')) ? 1 : 0; |
86 | 86 | |
87 | 87 | sn_db_transaction_start(); |
88 | - if($note_id_edit) { |
|
88 | + if ($note_id_edit) { |
|
89 | 89 | $check_note_id = db_note_get_id_and_owner($note_id_edit); |
90 | - if(!$check_note_id) { |
|
90 | + if (!$check_note_id) { |
|
91 | 91 | throw new Exception('note_err_note_not_found', ERR_ERROR); |
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | - if($note_id_edit) { |
|
96 | - if($check_note_id['owner'] != $user['id']) { |
|
95 | + if ($note_id_edit) { |
|
96 | + if ($check_note_id['owner'] != $user['id']) { |
|
97 | 97 | throw new Exception('note_err_owner_wrong', ERR_ERROR); |
98 | 98 | } |
99 | 99 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | sn_db_transaction_commit(); |
106 | 106 | sys_redirect('notes.php?STATUS=' . ERR_NONE . '&MESSAGE=' . ($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added')); |
107 | 107 | // throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE); |
108 | - } catch(Exception $e) { |
|
108 | + } catch (Exception $e) { |
|
109 | 109 | $note_id_edit = 0; |
110 | 110 | sn_db_transaction_rollback(); |
111 | 111 | $result[] = array( |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | -if(!$note_id_edit) { |
|
118 | +if (!$note_id_edit) { |
|
119 | 119 | note_assign($template, array( |
120 | 120 | 'id' => 0, |
121 | 121 | 'time' => SN_TIME_NOW, |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | |
129 | 129 | $note_exist = false; |
130 | 130 | $notes_query = db_note_list_by_owner($user['id']); |
131 | -while($note_row = db_fetch($notes_query)) { |
|
131 | +while ($note_row = db_fetch($notes_query)) { |
|
132 | 132 | note_assign($template, $note_row); |
133 | 133 | $note_exist = $note_exist || $note_row['id'] == $note_id_edit; |
134 | 134 | } |
135 | 135 | $note_id_edit = $note_exist ? $note_id_edit : 0; |
136 | 136 | |
137 | -foreach($note_priority_classes as $note_priority_id => $note_priority_class) { |
|
137 | +foreach ($note_priority_classes as $note_priority_id => $note_priority_class) { |
|
138 | 138 | $template->assign_block_vars('note_priority', array( |
139 | 139 | 'ID' => $note_priority_id, |
140 | 140 | 'CLASS' => $note_priority_classes[$note_priority_id], |
@@ -142,14 +142,14 @@ discard block |
||
142 | 142 | )); |
143 | 143 | } |
144 | 144 | |
145 | -foreach(classLocale::$lang['sys_planet_type'] as $planet_type_id => $planet_type_string) { |
|
145 | +foreach (classLocale::$lang['sys_planet_type'] as $planet_type_id => $planet_type_string) { |
|
146 | 146 | $template->assign_block_vars('planet_type', array( |
147 | 147 | 'ID' => $planet_type_id, |
148 | 148 | 'TEXT' => $planet_type_string, |
149 | 149 | )); |
150 | 150 | } |
151 | 151 | |
152 | -foreach($result as $result_data) { |
|
152 | +foreach ($result as $result_data) { |
|
153 | 153 | $template->assign_block_vars('result', $result_data); |
154 | 154 | } |
155 | 155 |
@@ -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 | } |
@@ -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 = db_payment_get($payment_id); |
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(classLocale::$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(classLocale::$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(classLocale::$lang['pay_msg_mm_purchase_test']), |
98 | 98 | 'STATUS' => -1, |
@@ -107,28 +107,28 @@ 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 | |
114 | 114 | $payment_methods_available = array_combine(array_keys(sn_module_payment::$payment_methods), array_fill(0, count(sn_module_payment::$payment_methods), null)); |
115 | -array_walk($payment_methods_available, function (&$value, $index) { |
|
115 | +array_walk($payment_methods_available, function(&$value, $index) { |
|
116 | 116 | $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; |
117 | 117 | }); |
118 | 118 | |
119 | 119 | // pdump($payment_methods_available); |
120 | 120 | $payment_module_valid = false; |
121 | 121 | $payment_module = sys_get_param_str('payment_module'); |
122 | -foreach(sn_module::$sn_module_list['payment'] as $module_name => $module) { |
|
123 | - if(!is_object($module) || !$module->manifest['active']) { |
|
122 | +foreach (sn_module::$sn_module_list['payment'] as $module_name => $module) { |
|
123 | + if (!is_object($module) || !$module->manifest['active']) { |
|
124 | 124 | continue; |
125 | 125 | } |
126 | 126 | |
127 | 127 | lng_include($module_name, $module->manifest['root_relative']); |
128 | 128 | |
129 | - foreach(sn_module_payment::$payment_methods as $payment_type_id => $available_methods) { |
|
130 | - foreach($available_methods as $payment_method => $payment_currency) { |
|
131 | - if(isset($module->manifest['payment_method'][$payment_method])) { |
|
129 | + foreach (sn_module_payment::$payment_methods as $payment_type_id => $available_methods) { |
|
130 | + foreach ($available_methods as $payment_method => $payment_currency) { |
|
131 | + if (isset($module->manifest['payment_method'][$payment_method])) { |
|
132 | 132 | $payment_methods_available[$payment_type_id][$payment_method][$module_name] = $module->manifest['payment_method'][$payment_method]; |
133 | 133 | } |
134 | 134 | } |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | |
140 | 140 | global $template_result; |
141 | 141 | // Доступные платежные методы |
142 | -foreach($payment_methods_available as $payment_type_id => $payment_methods) { |
|
143 | - if(empty($payment_methods)) { |
|
142 | +foreach ($payment_methods_available as $payment_type_id => $payment_methods) { |
|
143 | + if (empty($payment_methods)) { |
|
144 | 144 | continue; |
145 | 145 | } |
146 | 146 | |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | 'ID' => $payment_type_id, |
149 | 149 | 'NAME' => classLocale::$lang['pay_methods'][$payment_type_id], |
150 | 150 | ); |
151 | - foreach($payment_methods as $payment_method_id => $module_list) { |
|
152 | - if(empty($module_list)) { |
|
151 | + foreach ($payment_methods as $payment_method_id => $module_list) { |
|
152 | + if (empty($module_list)) { |
|
153 | 153 | continue; |
154 | 154 | } |
155 | 155 | $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id] = array( |
@@ -160,14 +160,14 @@ discard block |
||
160 | 160 | 'NAME_FORCE' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['name']), |
161 | 161 | 'BUTTON' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['button']), |
162 | 162 | ); |
163 | - foreach($module_list as $payment_module_name => $payment_module_method_details) { |
|
163 | + foreach ($module_list as $payment_module_name => $payment_module_method_details) { |
|
164 | 164 | $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id]['.']['module'][] = array( |
165 | 165 | 'MODULE' => $payment_module_name, |
166 | 166 | ); |
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
170 | - if(empty($template_result['.']['payment'][$payment_type_id]['.'])) { |
|
170 | + if (empty($template_result['.']['payment'][$payment_type_id]['.'])) { |
|
171 | 171 | unset($template_result['.']['payment'][$payment_type_id]); |
172 | 172 | } |
173 | 173 | } |
@@ -180,19 +180,19 @@ discard block |
||
180 | 180 | $payment_module_valid = $payment_module_valid && (!$payment_method_selected || isset($payment_methods_available[$payment_type_selected][$payment_method_selected][$module_name])); |
181 | 181 | |
182 | 182 | // If payment_module invalid - making it empty OR if there is only one payment_module - selecting it |
183 | -if($payment_module_valid) { |
|
183 | +if ($payment_module_valid) { |
|
184 | 184 | // $payment_module = $payment_module; // Really - do nothing |
185 | -} elseif($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) { |
|
185 | +} elseif ($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) { |
|
186 | 186 | reset($payment_methods_available[$payment_type_selected][$payment_method_selected]); |
187 | 187 | $payment_module = key($payment_methods_available[$payment_type_selected][$payment_method_selected]); |
188 | -} elseif(count(sn_module::$sn_module_list['payment']) == 1) { |
|
188 | +} elseif (count(sn_module::$sn_module_list['payment']) == 1) { |
|
189 | 189 | $payment_module = $module_name; |
190 | 190 | } else { |
191 | 191 | $payment_module = ''; |
192 | 192 | } |
193 | 193 | |
194 | -if($payment_type_selected && $payment_method_selected) { |
|
195 | - foreach($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) { |
|
194 | +if ($payment_type_selected && $payment_method_selected) { |
|
195 | + foreach ($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) { |
|
196 | 196 | $template->assign_block_vars('payment_module', array( |
197 | 197 | 'ID' => $module_name, |
198 | 198 | 'NAME' => classLocale::$lang["module_{$module_name}_name"], |
@@ -201,10 +201,10 @@ discard block |
||
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | -foreach(classLocale::$lang['pay_currency_list'] as $key => $value) { |
|
204 | +foreach (classLocale::$lang['pay_currency_list'] as $key => $value) { |
|
205 | 205 | $course = get_exchange_rate($key); |
206 | 206 | // if(!$course || $key == $config->payment_currency_default) { |
207 | - if(!$course) { |
|
207 | + if (!$course) { |
|
208 | 208 | continue; |
209 | 209 | } |
210 | 210 | $template->assign_block_vars('exchange', array( |
@@ -219,17 +219,17 @@ discard block |
||
219 | 219 | )); |
220 | 220 | } |
221 | 221 | |
222 | -if($request['metamatter'] && $payment_module) { |
|
222 | +if ($request['metamatter'] && $payment_module) { |
|
223 | 223 | try { |
224 | 224 | // Any possible errors about generating paylink should be raised in module! |
225 | 225 | $pay_link = sn_module::$sn_module[$payment_module]->compile_request($request); |
226 | 226 | |
227 | 227 | // Поддержка дополнительной информации |
228 | - if(is_array($pay_link['RENDER'])) { |
|
229 | - foreach($pay_link['RENDER'] as $html_data) { |
|
228 | + if (is_array($pay_link['RENDER'])) { |
|
229 | + foreach ($pay_link['RENDER'] as $html_data) { |
|
230 | 230 | $template->assign_block_vars('render', $html_data); |
231 | - if(isset($html_data['VALUE']) && is_array($html_data['VALUE'])) { |
|
232 | - foreach($html_data['VALUE'] as $value_id => $value_value) { |
|
231 | + if (isset($html_data['VALUE']) && is_array($html_data['VALUE'])) { |
|
232 | + foreach ($html_data['VALUE'] as $value_id => $value_value) { |
|
233 | 233 | $template->assign_block_vars('render.value', array( |
234 | 234 | 'FIELD' => $value_id, |
235 | 235 | 'VALUE' => $value_value, |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | } |
241 | 241 | |
242 | 242 | // Поддержка передачи данных для многошаговых платежных систем |
243 | - if(is_array($pay_link['DATA'])) { |
|
244 | - foreach($pay_link['DATA'] as $key => $value) { |
|
243 | + if (is_array($pay_link['DATA'])) { |
|
244 | + foreach ($pay_link['DATA'] as $key => $value) { |
|
245 | 245 | $template->assign_block_vars('pay_link_data', array( |
246 | 246 | 'FIELD' => $key, |
247 | 247 | 'VALUE' => $value, |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
252 | - if(is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) { |
|
252 | + if (is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) { |
|
253 | 253 | // TODO Переделать это под assign_vars_recursive и возвращать пустые строки если нет платежного метода - для унификации формы в темплейте |
254 | 254 | $template->assign_vars(array( |
255 | 255 | 'PAY_LINK_METHOD' => $pay_link['PAY_LINK_METHOD'], |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | } else { |
259 | 259 | throw new exception(classLocale::$lang['pay_msg_request_paylink_unsupported'], ERR_ERROR); |
260 | 260 | } |
261 | - } catch(exception $e) { |
|
261 | + } catch (exception $e) { |
|
262 | 262 | $template->assign_block_vars('result', $response = array( |
263 | 263 | 'STATUS' => $e->getCode(), |
264 | 264 | 'MESSAGE' => $e->getMessage(), |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | } |
269 | 269 | |
270 | 270 | // Прегенерированные пакеты |
271 | -foreach($unit_available_amount_list as $unit_amount => $discount) { |
|
271 | +foreach ($unit_available_amount_list as $unit_amount => $discount) { |
|
272 | 272 | $temp = sn_module_payment::currency_convert($unit_amount, 'MM_', $player_currency); |
273 | 273 | $template->assign_block_vars('mm_amount', array( |
274 | 274 | 'VALUE' => $unit_amount, |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | 'PLAYER_CURRENCY' => $player_currency, |
304 | 304 | 'PLAYER_CURRENCY_PRICE_PER_MM' => sn_module_payment::currency_convert(1, $player_currency, 'MM_', 10), |
305 | 305 | |
306 | - 'UNIT_AMOUNT' => (float)$request['metamatter'], |
|
306 | + 'UNIT_AMOUNT' => (float) $request['metamatter'], |
|
307 | 307 | 'UNIT_AMOUNT_TEXT' => pretty_number($request['metamatter']), |
308 | 308 | 'UNIT_AMOUNT_BONUS_PERCENT' => $bonus_percent, |
309 | 309 | 'UNIT_AMOUNT_TEXT_DISCOUNTED' => $income_metamatter_text, |
@@ -48,106 +48,106 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | switch($mode) { |
51 | - case 'write': |
|
52 | - $error_list = array(); |
|
53 | - $template = gettemplate('msg_message_compose', true); |
|
51 | + case 'write': |
|
52 | + $error_list = array(); |
|
53 | + $template = gettemplate('msg_message_compose', true); |
|
54 | 54 | |
55 | - $recipient_name = sys_get_param_str_unsafe('recipient_name'); |
|
56 | - if($recipient_name) { |
|
57 | - $recipient_row = db_user_by_username($recipient_name); |
|
58 | - } |
|
55 | + $recipient_name = sys_get_param_str_unsafe('recipient_name'); |
|
56 | + if($recipient_name) { |
|
57 | + $recipient_row = db_user_by_username($recipient_name); |
|
58 | + } |
|
59 | 59 | |
60 | - if(!$recipient_row) { |
|
61 | - $recipient_id = sys_get_param_id('id'); |
|
62 | - $recipient_row = db_user_by_id($recipient_id); |
|
63 | 60 | if(!$recipient_row) { |
64 | - $recipient_id = 0; |
|
61 | + $recipient_id = sys_get_param_id('id'); |
|
62 | + $recipient_row = db_user_by_id($recipient_id); |
|
63 | + if(!$recipient_row) { |
|
64 | + $recipient_id = 0; |
|
65 | + } |
|
65 | 66 | } |
66 | - } |
|
67 | - |
|
68 | - if($recipient_row) { |
|
69 | - $recipient_id = $recipient_row['id']; |
|
70 | - $recipient_name = $recipient_row['username']; |
|
71 | - } |
|
72 | - |
|
73 | - if($recipient_id == $user['id']) { |
|
74 | - $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_self_send'], 'STATUS' => ERR_ERROR); |
|
75 | - } |
|
76 | - |
|
77 | - $re = 0; |
|
78 | - $subject = sys_get_param_str('subject'); |
|
79 | - while(strpos($subject, classLocale::$lang['msg_answer_prefix']) !== false) { |
|
80 | - $subject = substr($subject, strlen(classLocale::$lang['msg_answer_prefix'])); |
|
81 | - $re++; |
|
82 | - } |
|
83 | - $re ? $subject = classLocale::$lang['msg_answer_prefix'] . $subject : false; |
|
84 | 67 | |
85 | - if(sys_get_param_str('msg_send')) { |
|
86 | - $subject = $subject ? $subject : classLocale::$lang['msg_subject_default']; |
|
68 | + if($recipient_row) { |
|
69 | + $recipient_id = $recipient_row['id']; |
|
70 | + $recipient_name = $recipient_row['username']; |
|
71 | + } |
|
87 | 72 | |
88 | - if(!$recipient_id) { |
|
89 | - $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_player_not_found'], 'STATUS' => ERR_ERROR); |
|
73 | + if($recipient_id == $user['id']) { |
|
74 | + $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_self_send'], 'STATUS' => ERR_ERROR); |
|
90 | 75 | } |
91 | 76 | |
92 | - $text = sys_get_param_str('text'); |
|
93 | - if(!$text) { |
|
94 | - $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_no_text'], 'STATUS' => ERR_ERROR); |
|
77 | + $re = 0; |
|
78 | + $subject = sys_get_param_str('subject'); |
|
79 | + while(strpos($subject, classLocale::$lang['msg_answer_prefix']) !== false) { |
|
80 | + $subject = substr($subject, strlen(classLocale::$lang['msg_answer_prefix'])); |
|
81 | + $re++; |
|
95 | 82 | } |
83 | + $re ? $subject = classLocale::$lang['msg_answer_prefix'] . $subject : false; |
|
96 | 84 | |
97 | - if(empty($error_list)) { |
|
98 | - $error_list[] = array('MESSAGE' => classLocale::$lang['msg_not_message_sent'], 'STATUS' => ERR_NONE); |
|
85 | + if(sys_get_param_str('msg_send')) { |
|
86 | + $subject = $subject ? $subject : classLocale::$lang['msg_subject_default']; |
|
99 | 87 | |
100 | - $user_safe_name = db_escape($user['username']); |
|
101 | - $recipient_name = db_escape($recipient_name); |
|
102 | - msg_send_simple_message($recipient_id, $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, "{$user_safe_name} [{$user['galaxy']}:{$user['system']}:{$user['planet']}]", $subject, $text, true); |
|
88 | + if(!$recipient_id) { |
|
89 | + $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_player_not_found'], 'STATUS' => ERR_ERROR); |
|
90 | + } |
|
103 | 91 | |
104 | - //$recipient_id = 0; |
|
105 | - //$recipient_name = ''; |
|
106 | - //$subject = ''; |
|
107 | - $text = ''; |
|
92 | + $text = sys_get_param_str('text'); |
|
93 | + if(!$text) { |
|
94 | + $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_no_text'], 'STATUS' => ERR_ERROR); |
|
95 | + } |
|
108 | 96 | |
109 | - $msg_sent = true; |
|
110 | - } else { |
|
111 | - $subject = sys_get_param_str_unsafe('subject'); |
|
112 | - $text = sys_get_param_str_unsafe('text'); |
|
113 | - } |
|
114 | - $recipient_name = sys_get_param_str_unsafe('recipient_name'); |
|
115 | - } |
|
97 | + if(empty($error_list)) { |
|
98 | + $error_list[] = array('MESSAGE' => classLocale::$lang['msg_not_message_sent'], 'STATUS' => ERR_NONE); |
|
116 | 99 | |
117 | - $subject = $subject ? $subject : classLocale::$lang['msg_subject_default']; |
|
100 | + $user_safe_name = db_escape($user['username']); |
|
101 | + $recipient_name = db_escape($recipient_name); |
|
102 | + msg_send_simple_message($recipient_id, $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, "{$user_safe_name} [{$user['galaxy']}:{$user['system']}:{$user['planet']}]", $subject, $text, true); |
|
118 | 103 | |
119 | - $template->assign_vars(array( |
|
120 | - 'RECIPIENT_ID' => $recipient_id, |
|
121 | - 'RECIPIENT_NAME' => htmlspecialchars($recipient_name), |
|
122 | - 'SUBJECT' => htmlspecialchars($subject), |
|
123 | - 'TEXT' => htmlspecialchars($text), |
|
124 | - )); |
|
104 | + //$recipient_id = 0; |
|
105 | + //$recipient_name = ''; |
|
106 | + //$subject = ''; |
|
107 | + $text = ''; |
|
125 | 108 | |
126 | - foreach($error_list as $error_message) { |
|
127 | - $template->assign_block_vars('result', $error_message); |
|
128 | - } |
|
109 | + $msg_sent = true; |
|
110 | + } else { |
|
111 | + $subject = sys_get_param_str_unsafe('subject'); |
|
112 | + $text = sys_get_param_str_unsafe('text'); |
|
113 | + } |
|
114 | + $recipient_name = sys_get_param_str_unsafe('recipient_name'); |
|
115 | + } |
|
129 | 116 | |
130 | - $message_query = db_message_list_get_last_20($user, $recipient_id); |
|
131 | - while($message_row = db_fetch($message_query)) { |
|
132 | - $template->assign_block_vars('messages', array( |
|
133 | - 'ID' => $message_row['message_id'], |
|
134 | - 'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF), |
|
135 | - 'FROM' => htmlspecialchars($message_row['message_from']), |
|
136 | - 'SUBJ' => htmlspecialchars($message_row['message_subject']), |
|
137 | - 'TEXT' => in_array($message_row['message_type'], array(MSG_TYPE_PLAYER, MSG_TYPE_ALLIANCE)) && $message_row['message_sender'] ? nl2br(htmlspecialchars($message_row['message_text'])) : nl2br($message_row['message_text']), |
|
117 | + $subject = $subject ? $subject : classLocale::$lang['msg_subject_default']; |
|
138 | 118 | |
139 | - 'FROM_ID' => $message_row['message_sender'], |
|
119 | + $template->assign_vars(array( |
|
120 | + 'RECIPIENT_ID' => $recipient_id, |
|
121 | + 'RECIPIENT_NAME' => htmlspecialchars($recipient_name), |
|
122 | + 'SUBJECT' => htmlspecialchars($subject), |
|
123 | + 'TEXT' => htmlspecialchars($text), |
|
140 | 124 | )); |
141 | - } |
|
142 | 125 | |
143 | - break; |
|
126 | + foreach($error_list as $error_message) { |
|
127 | + $template->assign_block_vars('result', $error_message); |
|
128 | + } |
|
129 | + |
|
130 | + $message_query = db_message_list_get_last_20($user, $recipient_id); |
|
131 | + while($message_row = db_fetch($message_query)) { |
|
132 | + $template->assign_block_vars('messages', array( |
|
133 | + 'ID' => $message_row['message_id'], |
|
134 | + 'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF), |
|
135 | + 'FROM' => htmlspecialchars($message_row['message_from']), |
|
136 | + 'SUBJ' => htmlspecialchars($message_row['message_subject']), |
|
137 | + 'TEXT' => in_array($message_row['message_type'], array(MSG_TYPE_PLAYER, MSG_TYPE_ALLIANCE)) && $message_row['message_sender'] ? nl2br(htmlspecialchars($message_row['message_text'])) : nl2br($message_row['message_text']), |
|
138 | + |
|
139 | + 'FROM_ID' => $message_row['message_sender'], |
|
140 | + )); |
|
141 | + } |
|
144 | 142 | |
145 | - case 'delete': |
|
146 | - $query_add = ''; |
|
143 | + break; |
|
147 | 144 | |
148 | - $message_range = sys_get_param_str('message_range'); |
|
145 | + case 'delete': |
|
146 | + $query_add = ''; |
|
149 | 147 | |
150 | - switch($message_range) { |
|
148 | + $message_range = sys_get_param_str('message_range'); |
|
149 | + |
|
150 | + switch($message_range) { |
|
151 | 151 | case 'unchecked': |
152 | 152 | case 'checked': |
153 | 153 | $marked_message_list = sys_get_param('mark', array()); |
@@ -171,65 +171,65 @@ discard block |
||
171 | 171 | case 'all': |
172 | 172 | $query_add = $query_add ? $query_add : true; |
173 | 173 | break; |
174 | - } |
|
174 | + } |
|
175 | 175 | |
176 | 176 | if($query_add) { |
177 | 177 | $query_add = $query_add === true ? '' : $query_add; |
178 | 178 | db_message_list_delete($user, $query_add); |
179 | 179 | } |
180 | 180 | |
181 | - case 'show': |
|
182 | - if($current_class == MSG_TYPE_OUTBOX) { |
|
183 | - $message_query = db_message_list_outbox_by_user_id($user['id']); |
|
184 | - } else { |
|
185 | - if($current_class == MSG_TYPE_NEW) { |
|
186 | - $SubUpdateQry = array(); |
|
187 | - foreach($sn_message_class_list as $message_class_id => $message_class) { |
|
188 | - if($message_class_id != MSG_TYPE_OUTBOX) { |
|
189 | - $SubUpdateQry[] = "`{$message_class['name']}` = '0'"; |
|
190 | - $user[$message_class['name']] = 0; |
|
181 | + case 'show': |
|
182 | + if($current_class == MSG_TYPE_OUTBOX) { |
|
183 | + $message_query = db_message_list_outbox_by_user_id($user['id']); |
|
184 | + } else { |
|
185 | + if($current_class == MSG_TYPE_NEW) { |
|
186 | + $SubUpdateQry = array(); |
|
187 | + foreach($sn_message_class_list as $message_class_id => $message_class) { |
|
188 | + if($message_class_id != MSG_TYPE_OUTBOX) { |
|
189 | + $SubUpdateQry[] = "`{$message_class['name']}` = '0'"; |
|
190 | + $user[$message_class['name']] = 0; |
|
191 | + } |
|
191 | 192 | } |
193 | + $SubUpdateQry = implode(',', $SubUpdateQry); |
|
194 | + } else { |
|
195 | + $SubUpdateQry = "`{$sn_message_class_list[$current_class]['name']}` = '0', `{$sn_message_class_list[MSG_TYPE_NEW]['name']}` = `{$sn_message_class_list[MSG_TYPE_NEW]['name']}` - '{$user[$sn_message_class_list[$current_class]['name']]}'"; |
|
196 | + $SubSelectQry = "AND `message_type` = '{$current_class}'"; |
|
197 | + |
|
198 | + $user[$sn_message_class_list[MSG_TYPE_NEW]['name']] -= $user[$sn_message_class_list[$current_class]['name']]; |
|
199 | + $user[$sn_message_class_list[$current_class]['name']] = 0; |
|
192 | 200 | } |
193 | - $SubUpdateQry = implode(',', $SubUpdateQry); |
|
194 | - } else { |
|
195 | - $SubUpdateQry = "`{$sn_message_class_list[$current_class]['name']}` = '0', `{$sn_message_class_list[MSG_TYPE_NEW]['name']}` = `{$sn_message_class_list[MSG_TYPE_NEW]['name']}` - '{$user[$sn_message_class_list[$current_class]['name']]}'"; |
|
196 | - $SubSelectQry = "AND `message_type` = '{$current_class}'"; |
|
197 | 201 | |
198 | - $user[$sn_message_class_list[MSG_TYPE_NEW]['name']] -= $user[$sn_message_class_list[$current_class]['name']]; |
|
199 | - $user[$sn_message_class_list[$current_class]['name']] = 0; |
|
202 | + db_user_set_by_id($user['id'], $SubUpdateQry); |
|
203 | + $message_query = db_message_list_by_owner_and_string($user, $SubSelectQry); |
|
200 | 204 | } |
201 | 205 | |
202 | - db_user_set_by_id($user['id'], $SubUpdateQry); |
|
203 | - $message_query = db_message_list_by_owner_and_string($user, $SubSelectQry); |
|
204 | - } |
|
205 | - |
|
206 | - if(sys_get_param_int('return')) { |
|
207 | - header('Location: messages.php'); |
|
208 | - die(); |
|
209 | - } |
|
206 | + if(sys_get_param_int('return')) { |
|
207 | + header('Location: messages.php'); |
|
208 | + die(); |
|
209 | + } |
|
210 | 210 | |
211 | - $template = gettemplate('msg_message_list', true); |
|
212 | - while($message_row = db_fetch($message_query)) { |
|
213 | - $template->assign_block_vars('messages', array( |
|
214 | - 'ID' => $message_row['message_id'], |
|
215 | - 'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF), |
|
216 | - 'FROM' => htmlspecialchars($message_row['message_from']), |
|
217 | - 'SUBJ' => htmlspecialchars($message_row['message_subject']), |
|
218 | - 'TEXT' => in_array($message_row['message_type'], array(MSG_TYPE_PLAYER, MSG_TYPE_ALLIANCE)) && $message_row['message_sender'] ? nl2br(htmlspecialchars($message_row['message_text'])) : nl2br($message_row['message_text']), |
|
219 | - |
|
220 | - 'FROM_ID' => $message_row['message_sender'], |
|
221 | - 'SUBJ_SANITIZED' => htmlspecialchars($message_row['message_subject']), |
|
222 | - 'STYLE' => $current_class == MSG_TYPE_OUTBOX ? $sn_message_class_list[MSG_TYPE_OUTBOX]['name'] : $sn_message_class_list[$message_row['message_type']]['name'], |
|
223 | - )); |
|
224 | - } |
|
211 | + $template = gettemplate('msg_message_list', true); |
|
212 | + while($message_row = db_fetch($message_query)) { |
|
213 | + $template->assign_block_vars('messages', array( |
|
214 | + 'ID' => $message_row['message_id'], |
|
215 | + 'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF), |
|
216 | + 'FROM' => htmlspecialchars($message_row['message_from']), |
|
217 | + 'SUBJ' => htmlspecialchars($message_row['message_subject']), |
|
218 | + 'TEXT' => in_array($message_row['message_type'], array(MSG_TYPE_PLAYER, MSG_TYPE_ALLIANCE)) && $message_row['message_sender'] ? nl2br(htmlspecialchars($message_row['message_text'])) : nl2br($message_row['message_text']), |
|
219 | + |
|
220 | + 'FROM_ID' => $message_row['message_sender'], |
|
221 | + 'SUBJ_SANITIZED' => htmlspecialchars($message_row['message_subject']), |
|
222 | + 'STYLE' => $current_class == MSG_TYPE_OUTBOX ? $sn_message_class_list[MSG_TYPE_OUTBOX]['name'] : $sn_message_class_list[$message_row['message_type']]['name'], |
|
223 | + )); |
|
224 | + } |
|
225 | 225 | |
226 | - $current_class_text = classLocale::$lang['msg_class'][$current_class]; |
|
226 | + $current_class_text = classLocale::$lang['msg_class'][$current_class]; |
|
227 | 227 | |
228 | - $template->assign_vars(array( |
|
229 | - "MESSAGE_CLASS" => $current_class, |
|
230 | - "MESSAGE_CLASS_TEXT" => $current_class_text, |
|
231 | - )); |
|
232 | - break; |
|
228 | + $template->assign_vars(array( |
|
229 | + "MESSAGE_CLASS" => $current_class, |
|
230 | + "MESSAGE_CLASS_TEXT" => $current_class_text, |
|
231 | + )); |
|
232 | + break; |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | if(!$template) { |
@@ -42,59 +42,59 @@ discard block |
||
42 | 42 | |
43 | 43 | $mode = sys_get_param_str('msg_delete') ? 'delete' : sys_get_param_str('mode'); |
44 | 44 | $current_class = sys_get_param_int('message_class'); |
45 | -if(!isset($sn_message_class_list[$current_class])) { |
|
45 | +if (!isset($sn_message_class_list[$current_class])) { |
|
46 | 46 | $current_class = 0; |
47 | 47 | $mode = ''; |
48 | 48 | } |
49 | 49 | |
50 | -switch($mode) { |
|
50 | +switch ($mode) { |
|
51 | 51 | case 'write': |
52 | 52 | $error_list = array(); |
53 | 53 | $template = gettemplate('msg_message_compose', true); |
54 | 54 | |
55 | 55 | $recipient_name = sys_get_param_str_unsafe('recipient_name'); |
56 | - if($recipient_name) { |
|
56 | + if ($recipient_name) { |
|
57 | 57 | $recipient_row = db_user_by_username($recipient_name); |
58 | 58 | } |
59 | 59 | |
60 | - if(!$recipient_row) { |
|
60 | + if (!$recipient_row) { |
|
61 | 61 | $recipient_id = sys_get_param_id('id'); |
62 | 62 | $recipient_row = db_user_by_id($recipient_id); |
63 | - if(!$recipient_row) { |
|
63 | + if (!$recipient_row) { |
|
64 | 64 | $recipient_id = 0; |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - if($recipient_row) { |
|
68 | + if ($recipient_row) { |
|
69 | 69 | $recipient_id = $recipient_row['id']; |
70 | 70 | $recipient_name = $recipient_row['username']; |
71 | 71 | } |
72 | 72 | |
73 | - if($recipient_id == $user['id']) { |
|
73 | + if ($recipient_id == $user['id']) { |
|
74 | 74 | $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_self_send'], 'STATUS' => ERR_ERROR); |
75 | 75 | } |
76 | 76 | |
77 | 77 | $re = 0; |
78 | 78 | $subject = sys_get_param_str('subject'); |
79 | - while(strpos($subject, classLocale::$lang['msg_answer_prefix']) !== false) { |
|
79 | + while (strpos($subject, classLocale::$lang['msg_answer_prefix']) !== false) { |
|
80 | 80 | $subject = substr($subject, strlen(classLocale::$lang['msg_answer_prefix'])); |
81 | 81 | $re++; |
82 | 82 | } |
83 | 83 | $re ? $subject = classLocale::$lang['msg_answer_prefix'] . $subject : false; |
84 | 84 | |
85 | - if(sys_get_param_str('msg_send')) { |
|
85 | + if (sys_get_param_str('msg_send')) { |
|
86 | 86 | $subject = $subject ? $subject : classLocale::$lang['msg_subject_default']; |
87 | 87 | |
88 | - if(!$recipient_id) { |
|
88 | + if (!$recipient_id) { |
|
89 | 89 | $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_player_not_found'], 'STATUS' => ERR_ERROR); |
90 | 90 | } |
91 | 91 | |
92 | 92 | $text = sys_get_param_str('text'); |
93 | - if(!$text) { |
|
93 | + if (!$text) { |
|
94 | 94 | $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_no_text'], 'STATUS' => ERR_ERROR); |
95 | 95 | } |
96 | 96 | |
97 | - if(empty($error_list)) { |
|
97 | + if (empty($error_list)) { |
|
98 | 98 | $error_list[] = array('MESSAGE' => classLocale::$lang['msg_not_message_sent'], 'STATUS' => ERR_NONE); |
99 | 99 | |
100 | 100 | $user_safe_name = db_escape($user['username']); |
@@ -123,12 +123,12 @@ discard block |
||
123 | 123 | 'TEXT' => htmlspecialchars($text), |
124 | 124 | )); |
125 | 125 | |
126 | - foreach($error_list as $error_message) { |
|
126 | + foreach ($error_list as $error_message) { |
|
127 | 127 | $template->assign_block_vars('result', $error_message); |
128 | 128 | } |
129 | 129 | |
130 | 130 | $message_query = db_message_list_get_last_20($user, $recipient_id); |
131 | - while($message_row = db_fetch($message_query)) { |
|
131 | + while ($message_row = db_fetch($message_query)) { |
|
132 | 132 | $template->assign_block_vars('messages', array( |
133 | 133 | 'ID' => $message_row['message_id'], |
134 | 134 | 'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF), |
@@ -147,25 +147,25 @@ discard block |
||
147 | 147 | |
148 | 148 | $message_range = sys_get_param_str('message_range'); |
149 | 149 | |
150 | - switch($message_range) { |
|
150 | + switch ($message_range) { |
|
151 | 151 | case 'unchecked': |
152 | 152 | case 'checked': |
153 | 153 | $marked_message_list = sys_get_param('mark', array()); |
154 | - if($message_range == 'checked' && empty($marked_message_list)) { |
|
154 | + if ($message_range == 'checked' && empty($marked_message_list)) { |
|
155 | 155 | break; |
156 | 156 | } |
157 | 157 | |
158 | 158 | $query_add = implode(',', $marked_message_list); |
159 | - if($query_add) { |
|
159 | + if ($query_add) { |
|
160 | 160 | $query_add = "IN ({$query_add})"; |
161 | - if($message_range == 'unchecked') { |
|
161 | + if ($message_range == 'unchecked') { |
|
162 | 162 | $query_add = "NOT {$query_add}"; |
163 | 163 | } |
164 | 164 | $query_add = " AND `message_id` {$query_add}"; |
165 | 165 | } |
166 | 166 | |
167 | 167 | case 'class': |
168 | - if($current_class != MSG_TYPE_OUTBOX && $current_class != MSG_TYPE_NEW) { |
|
168 | + if ($current_class != MSG_TYPE_OUTBOX && $current_class != MSG_TYPE_NEW) { |
|
169 | 169 | $query_add .= " AND `message_type` = {$current_class}"; |
170 | 170 | } |
171 | 171 | case 'all': |
@@ -173,19 +173,19 @@ discard block |
||
173 | 173 | break; |
174 | 174 | } |
175 | 175 | |
176 | - if($query_add) { |
|
176 | + if ($query_add) { |
|
177 | 177 | $query_add = $query_add === true ? '' : $query_add; |
178 | 178 | db_message_list_delete($user, $query_add); |
179 | 179 | } |
180 | 180 | |
181 | 181 | case 'show': |
182 | - if($current_class == MSG_TYPE_OUTBOX) { |
|
182 | + if ($current_class == MSG_TYPE_OUTBOX) { |
|
183 | 183 | $message_query = db_message_list_outbox_by_user_id($user['id']); |
184 | 184 | } else { |
185 | - if($current_class == MSG_TYPE_NEW) { |
|
185 | + if ($current_class == MSG_TYPE_NEW) { |
|
186 | 186 | $SubUpdateQry = array(); |
187 | - foreach($sn_message_class_list as $message_class_id => $message_class) { |
|
188 | - if($message_class_id != MSG_TYPE_OUTBOX) { |
|
187 | + foreach ($sn_message_class_list as $message_class_id => $message_class) { |
|
188 | + if ($message_class_id != MSG_TYPE_OUTBOX) { |
|
189 | 189 | $SubUpdateQry[] = "`{$message_class['name']}` = '0'"; |
190 | 190 | $user[$message_class['name']] = 0; |
191 | 191 | } |
@@ -203,13 +203,13 @@ discard block |
||
203 | 203 | $message_query = db_message_list_by_owner_and_string($user, $SubSelectQry); |
204 | 204 | } |
205 | 205 | |
206 | - if(sys_get_param_int('return')) { |
|
206 | + if (sys_get_param_int('return')) { |
|
207 | 207 | header('Location: messages.php'); |
208 | 208 | die(); |
209 | 209 | } |
210 | 210 | |
211 | 211 | $template = gettemplate('msg_message_list', true); |
212 | - while($message_row = db_fetch($message_query)) { |
|
212 | + while ($message_row = db_fetch($message_query)) { |
|
213 | 213 | $template->assign_block_vars('messages', array( |
214 | 214 | 'ID' => $message_row['message_id'], |
215 | 215 | 'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF), |
@@ -232,18 +232,18 @@ discard block |
||
232 | 232 | break; |
233 | 233 | } |
234 | 234 | |
235 | -if(!$template) { |
|
235 | +if (!$template) { |
|
236 | 236 | $template = gettemplate('msg_message_class', true); |
237 | 237 | |
238 | 238 | $query = db_message_count_by_owner_and_type($user); |
239 | - while($message_row = db_fetch($query)) { |
|
239 | + while ($message_row = db_fetch($query)) { |
|
240 | 240 | $messages_total[$message_row['message_type']] = $message_row['message_count']; |
241 | 241 | $messages_total[MSG_TYPE_NEW] += $message_row['message_count']; |
242 | 242 | } |
243 | 243 | |
244 | 244 | $messages_total[MSG_TYPE_OUTBOX] = db_message_count_outbox($user); |
245 | 245 | |
246 | - foreach($sn_message_class_list as $message_class_id => $message_class) { |
|
246 | + foreach ($sn_message_class_list as $message_class_id => $message_class) { |
|
247 | 247 | $template->assign_block_vars('message_class', array( |
248 | 248 | 'ID' => $message_class_id, |
249 | 249 | 'STYLE' => $message_class['name'], |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | $planet = sys_get_param_int('planet', $planetrow['planet']); |
40 | 40 | |
41 | 41 | $target_mission = sys_get_param_int('target_mission'); |
42 | -if($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) { |
|
42 | +if ($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) { |
|
43 | 43 | $planet_type = PT_PLANET; |
44 | -} elseif($target_mission == MT_RECYCLE) { |
|
44 | +} elseif ($target_mission == MT_RECYCLE) { |
|
45 | 45 | $planet_type = PT_DEBRIS; |
46 | -} elseif($target_mission == MT_DESTROY) { |
|
46 | +} elseif ($target_mission == MT_DESTROY) { |
|
47 | 47 | $planet_type = PT_MOON; |
48 | 48 | } else { |
49 | 49 | $planet_type = sys_get_param_int('planet_type'); |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | |
58 | 58 | $MaxFleets = GetMaxFleets($user); |
59 | 59 | $FlyingFleets = FleetList::fleet_count_flying($user['id']); |
60 | -if($MaxFleets <= $FlyingFleets && $fleet_page && $fleet_page != 4) { |
|
60 | +if ($MaxFleets <= $FlyingFleets && $fleet_page && $fleet_page != 4) { |
|
61 | 61 | message(classLocale::$lang['fl_noslotfree'], classLocale::$lang['fl_error'], "fleet." . PHP_EX, 5); |
62 | 62 | } |
63 | 63 | |
64 | 64 | $MaxExpeditions = get_player_max_expeditons($user); |
65 | -if($MaxExpeditions) { |
|
66 | - $FlyingExpeditions = FleetList::fleet_count_flying($user['id'], MT_EXPLORE); |
|
65 | +if ($MaxExpeditions) { |
|
66 | + $FlyingExpeditions = FleetList::fleet_count_flying($user['id'], MT_EXPLORE); |
|
67 | 67 | } else { |
68 | 68 | $FlyingExpeditions = 0; |
69 | 69 | } |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | $fleetarray = unserialize(base64_decode(str_rot13(sys_get_param('usedfleet')))); |
77 | 77 | $fleetarray = is_array($fleetarray) ? $fleetarray : array(); |
78 | 78 | |
79 | - foreach($fleetarray as $ship_id => &$ship_amount) { |
|
80 | - if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) { |
|
79 | + foreach ($fleetarray as $ship_id => &$ship_amount) { |
|
80 | + if (!in_array($ship_id, sn_get_groups('fleet')) || (string) floatval($ship_amount) != $ship_amount || $ship_amount < 1) { |
|
81 | 81 | $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true)); |
82 | 82 | die(); |
83 | 83 | } |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | $target_mission = MT_COLONIZE; |
109 | 109 | $planet_type = PT_PLANET; |
110 | 110 | } else { |
111 | - message ("<font color=\"red\"><b>". classLocale::$lang['fl_no_planet_type'] ."</b></font>", classLocale::$lang['fl_error']); |
|
111 | + message("<font color=\"red\"><b>" . classLocale::$lang['fl_no_planet_type'] . "</b></font>", classLocale::$lang['fl_error']); |
|
112 | 112 | } |
113 | 113 | } else { |
114 | 114 | $recyclers = 0; |
115 | - foreach(sn_get_groups('flt_recyclers') as $recycler_id) { |
|
115 | + foreach (sn_get_groups('flt_recyclers') as $recycler_id) { |
|
116 | 116 | $recyclers += $fleetarray[$recycler_id]; |
117 | 117 | } |
118 | 118 | if ($recyclers > 0 && $planet_type == PT_DEBRIS) { |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | |
138 | 138 | $missiontype[MT_HOLD] = classLocale::$lang['type_mission'][MT_HOLD]; |
139 | 139 | |
140 | - if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) { |
|
140 | + if ($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) { |
|
141 | 141 | $missiontype[MT_DESTROY] = classLocale::$lang['type_mission'][MT_DESTROY]; |
142 | 142 | } |
143 | 143 | } |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | ); |
198 | 198 | |
199 | 199 | $is_transport_missions = false; |
200 | -if($missiontype) { |
|
200 | +if ($missiontype) { |
|
201 | 201 | $sn_group_missions = sn_get_groups('missions'); |
202 | - foreach($missiontype as $mission_data_id => $mission_data) { |
|
202 | + foreach ($missiontype as $mission_data_id => $mission_data) { |
|
203 | 203 | $is_transport_missions = $is_transport_missions || (isset($sn_group_missions[$mission_data_id]['transport']) && $sn_group_missions[$mission_data_id]['transport']); |
204 | 204 | } |
205 | 205 | } |
206 | 206 | |
207 | -switch($fleet_page) { |
|
207 | +switch ($fleet_page) { |
|
208 | 208 | case 1: |
209 | 209 | require('includes/includes/flt_page1.inc'); |
210 | 210 | break; |
@@ -69,114 +69,114 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | switch ($fleet_page) { |
72 | - case 3: |
|
72 | + case 3: |
|
73 | 73 | |
74 | - case 2: |
|
75 | - $fleet_group_mr = sys_get_param_id('fleet_group'); |
|
76 | - $fleetarray = unserialize(base64_decode(str_rot13(sys_get_param('usedfleet')))); |
|
77 | - $fleetarray = is_array($fleetarray) ? $fleetarray : array(); |
|
74 | + case 2: |
|
75 | + $fleet_group_mr = sys_get_param_id('fleet_group'); |
|
76 | + $fleetarray = unserialize(base64_decode(str_rot13(sys_get_param('usedfleet')))); |
|
77 | + $fleetarray = is_array($fleetarray) ? $fleetarray : array(); |
|
78 | 78 | |
79 | - foreach($fleetarray as $ship_id => &$ship_amount) { |
|
80 | - if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) { |
|
81 | - $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true)); |
|
82 | - die(); |
|
83 | - } |
|
84 | - $ship_amount = floatval($ship_amount); |
|
85 | - } |
|
86 | - |
|
87 | - $UsedPlanet = false; |
|
88 | - $YourPlanet = false; |
|
89 | - $missiontype = array(); |
|
90 | - if ($planet > classSupernova::$config->game_maxPlanet) { |
|
91 | - $target_mission = MT_EXPLORE; |
|
92 | - $missiontype[MT_EXPLORE] = classLocale::$lang['type_mission'][MT_EXPLORE]; |
|
93 | - } elseif ($galaxy && $system && $planet) { |
|
94 | - $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET; |
|
95 | - |
|
96 | - $TargetPlanet = db_planet_by_gspt($galaxy, $system, $planet, $check_type); |
|
97 | - |
|
98 | - if ($TargetPlanet['id_owner']) { |
|
99 | - $UsedPlanet = true; |
|
100 | - if ($TargetPlanet['id_owner'] == $user['id']) { |
|
101 | - $YourPlanet = true; |
|
79 | + foreach($fleetarray as $ship_id => &$ship_amount) { |
|
80 | + if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) { |
|
81 | + $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true)); |
|
82 | + die(); |
|
102 | 83 | } |
84 | + $ship_amount = floatval($ship_amount); |
|
103 | 85 | } |
104 | 86 | |
105 | - if (!$UsedPlanet) { |
|
106 | - if ($fleetarray[SHIP_COLONIZER]) { |
|
107 | - $missiontype[MT_COLONIZE] = classLocale::$lang['type_mission'][MT_COLONIZE]; |
|
108 | - $target_mission = MT_COLONIZE; |
|
109 | - $planet_type = PT_PLANET; |
|
110 | - } else { |
|
111 | - message ("<font color=\"red\"><b>". classLocale::$lang['fl_no_planet_type'] ."</b></font>", classLocale::$lang['fl_error']); |
|
112 | - } |
|
113 | - } else { |
|
114 | - $recyclers = 0; |
|
115 | - foreach(sn_get_groups('flt_recyclers') as $recycler_id) { |
|
116 | - $recyclers += $fleetarray[$recycler_id]; |
|
87 | + $UsedPlanet = false; |
|
88 | + $YourPlanet = false; |
|
89 | + $missiontype = array(); |
|
90 | + if ($planet > classSupernova::$config->game_maxPlanet) { |
|
91 | + $target_mission = MT_EXPLORE; |
|
92 | + $missiontype[MT_EXPLORE] = classLocale::$lang['type_mission'][MT_EXPLORE]; |
|
93 | + } elseif ($galaxy && $system && $planet) { |
|
94 | + $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET; |
|
95 | + |
|
96 | + $TargetPlanet = db_planet_by_gspt($galaxy, $system, $planet, $check_type); |
|
97 | + |
|
98 | + if ($TargetPlanet['id_owner']) { |
|
99 | + $UsedPlanet = true; |
|
100 | + if ($TargetPlanet['id_owner'] == $user['id']) { |
|
101 | + $YourPlanet = true; |
|
102 | + } |
|
117 | 103 | } |
118 | - if ($recyclers > 0 && $planet_type == PT_DEBRIS) { |
|
119 | - $target_mission = MT_RECYCLE; |
|
120 | - $missiontype[MT_RECYCLE] = classLocale::$lang['type_mission'][MT_RECYCLE]; |
|
121 | - } elseif ($planet_type == PT_PLANET || $planet_type == PT_MOON) { |
|
122 | - if ($YourPlanet) { |
|
123 | - $missiontype[MT_RELOCATE] = classLocale::$lang['type_mission'][MT_RELOCATE]; |
|
124 | - $missiontype[MT_TRANSPORT] = classLocale::$lang['type_mission'][MT_TRANSPORT]; |
|
104 | + |
|
105 | + if (!$UsedPlanet) { |
|
106 | + if ($fleetarray[SHIP_COLONIZER]) { |
|
107 | + $missiontype[MT_COLONIZE] = classLocale::$lang['type_mission'][MT_COLONIZE]; |
|
108 | + $target_mission = MT_COLONIZE; |
|
109 | + $planet_type = PT_PLANET; |
|
125 | 110 | } else { |
126 | - // Not Your Planet |
|
127 | - if ($fleetarray[SHIP_SPY]) { |
|
128 | - // Only spy missions if any spy |
|
129 | - $missiontype[MT_SPY] = classLocale::$lang['type_mission'][MT_SPY]; |
|
111 | + message ("<font color=\"red\"><b>". classLocale::$lang['fl_no_planet_type'] ."</b></font>", classLocale::$lang['fl_error']); |
|
112 | + } |
|
113 | + } else { |
|
114 | + $recyclers = 0; |
|
115 | + foreach(sn_get_groups('flt_recyclers') as $recycler_id) { |
|
116 | + $recyclers += $fleetarray[$recycler_id]; |
|
117 | + } |
|
118 | + if ($recyclers > 0 && $planet_type == PT_DEBRIS) { |
|
119 | + $target_mission = MT_RECYCLE; |
|
120 | + $missiontype[MT_RECYCLE] = classLocale::$lang['type_mission'][MT_RECYCLE]; |
|
121 | + } elseif ($planet_type == PT_PLANET || $planet_type == PT_MOON) { |
|
122 | + if ($YourPlanet) { |
|
123 | + $missiontype[MT_RELOCATE] = classLocale::$lang['type_mission'][MT_RELOCATE]; |
|
124 | + $missiontype[MT_TRANSPORT] = classLocale::$lang['type_mission'][MT_TRANSPORT]; |
|
130 | 125 | } else { |
131 | - // If no spies... |
|
132 | - if ($fleet_group_mr) { |
|
133 | - $missiontype[MT_AKS] = classLocale::$lang['type_mission'][MT_AKS]; |
|
126 | + // Not Your Planet |
|
127 | + if ($fleetarray[SHIP_SPY]) { |
|
128 | + // Only spy missions if any spy |
|
129 | + $missiontype[MT_SPY] = classLocale::$lang['type_mission'][MT_SPY]; |
|
134 | 130 | } else { |
135 | - $missiontype[MT_ATTACK] = classLocale::$lang['type_mission'][MT_ATTACK]; |
|
136 | - $missiontype[MT_TRANSPORT] = classLocale::$lang['type_mission'][MT_TRANSPORT]; |
|
137 | - |
|
138 | - $missiontype[MT_HOLD] = classLocale::$lang['type_mission'][MT_HOLD]; |
|
139 | - |
|
140 | - if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) { |
|
141 | - $missiontype[MT_DESTROY] = classLocale::$lang['type_mission'][MT_DESTROY]; |
|
131 | + // If no spies... |
|
132 | + if ($fleet_group_mr) { |
|
133 | + $missiontype[MT_AKS] = classLocale::$lang['type_mission'][MT_AKS]; |
|
134 | + } else { |
|
135 | + $missiontype[MT_ATTACK] = classLocale::$lang['type_mission'][MT_ATTACK]; |
|
136 | + $missiontype[MT_TRANSPORT] = classLocale::$lang['type_mission'][MT_TRANSPORT]; |
|
137 | + |
|
138 | + $missiontype[MT_HOLD] = classLocale::$lang['type_mission'][MT_HOLD]; |
|
139 | + |
|
140 | + if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) { |
|
141 | + $missiontype[MT_DESTROY] = classLocale::$lang['type_mission'][MT_DESTROY]; |
|
142 | + } |
|
142 | 143 | } |
143 | 144 | } |
144 | 145 | } |
145 | 146 | } |
146 | 147 | } |
147 | 148 | } |
148 | - } |
|
149 | 149 | |
150 | - if (!$target_mission && is_array($missiontype)) { |
|
151 | - $target_mission = MT_ATTACK; |
|
152 | - } |
|
150 | + if (!$target_mission && is_array($missiontype)) { |
|
151 | + $target_mission = MT_ATTACK; |
|
152 | + } |
|
153 | 153 | |
154 | - ksort($missiontype); |
|
154 | + ksort($missiontype); |
|
155 | 155 | |
156 | - $speed_percent = sys_get_param_int('speed', 10); |
|
157 | - $travel_data = flt_travel_data($user, $planetrow, array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet), $fleetarray, $speed_percent); |
|
156 | + $speed_percent = sys_get_param_int('speed', 10); |
|
157 | + $travel_data = flt_travel_data($user, $planetrow, array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet), $fleetarray, $speed_percent); |
|
158 | 158 | |
159 | - $fleet_speed = $travel_data['fleet_speed']; |
|
160 | - $distance = $travel_data['distance']; |
|
161 | - $duration = $travel_data['duration']; |
|
162 | - $consumption = $travel_data['consumption']; |
|
163 | - // No Break |
|
159 | + $fleet_speed = $travel_data['fleet_speed']; |
|
160 | + $distance = $travel_data['distance']; |
|
161 | + $duration = $travel_data['duration']; |
|
162 | + $consumption = $travel_data['consumption']; |
|
163 | + // No Break |
|
164 | 164 | |
165 | - case 1: |
|
166 | - if ($galaxy && $system && $planet) { |
|
167 | - $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET; |
|
165 | + case 1: |
|
166 | + if ($galaxy && $system && $planet) { |
|
167 | + $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET; |
|
168 | 168 | |
169 | - $TargetPlanet = db_planet_by_gspt($galaxy, $system, $planet, $check_type); |
|
170 | - } |
|
169 | + $TargetPlanet = db_planet_by_gspt($galaxy, $system, $planet, $check_type); |
|
170 | + } |
|
171 | 171 | |
172 | - case 0: |
|
173 | - $template_result += array( |
|
174 | - 'thisgalaxy' => $planetrow['galaxy'], |
|
175 | - 'thissystem' => $planetrow['system'], |
|
176 | - 'thisplanet' => $planetrow['planet'], |
|
177 | - 'thisplanet_type' => $planetrow['planet_type'], |
|
178 | - ); |
|
179 | - // no break |
|
172 | + case 0: |
|
173 | + $template_result += array( |
|
174 | + 'thisgalaxy' => $planetrow['galaxy'], |
|
175 | + 'thissystem' => $planetrow['system'], |
|
176 | + 'thisplanet' => $planetrow['planet'], |
|
177 | + 'thisplanet_type' => $planetrow['planet_type'], |
|
178 | + ); |
|
179 | + // no break |
|
180 | 180 | |
181 | 181 | } |
182 | 182 | |
@@ -198,31 +198,31 @@ discard block |
||
198 | 198 | } |
199 | 199 | |
200 | 200 | switch($fleet_page) { |
201 | - case 1: |
|
202 | - require('includes/includes/flt_page1.inc'); |
|
203 | - break; |
|
201 | + case 1: |
|
202 | + require('includes/includes/flt_page1.inc'); |
|
203 | + break; |
|
204 | 204 | |
205 | - case 2: |
|
206 | - require_once('includes/includes/flt_page2.inc'); |
|
207 | - sn_fleet_page2(); |
|
208 | - break; |
|
205 | + case 2: |
|
206 | + require_once('includes/includes/flt_page2.inc'); |
|
207 | + sn_fleet_page2(); |
|
208 | + break; |
|
209 | 209 | |
210 | - case 3: |
|
211 | - require_once('includes/includes/flt_page3.inc'); |
|
212 | - sn_fleet_page3($duration); |
|
213 | - break; |
|
210 | + case 3: |
|
211 | + require_once('includes/includes/flt_page3.inc'); |
|
212 | + sn_fleet_page3($duration); |
|
213 | + break; |
|
214 | 214 | |
215 | - case 4: |
|
216 | - require('includes/includes/flt_page4.inc'); |
|
217 | - break; |
|
215 | + case 4: |
|
216 | + require('includes/includes/flt_page4.inc'); |
|
217 | + break; |
|
218 | 218 | |
219 | - case 5: |
|
220 | - require('includes/includes/flt_page5.inc'); |
|
221 | - break; |
|
219 | + case 5: |
|
220 | + require('includes/includes/flt_page5.inc'); |
|
221 | + break; |
|
222 | 222 | |
223 | - default: |
|
224 | - define('SN_RENDER_NAVBAR_PLANET', true); |
|
223 | + default: |
|
224 | + define('SN_RENDER_NAVBAR_PLANET', true); |
|
225 | 225 | |
226 | - require('includes/includes/flt_page0.inc'); |
|
227 | - break; |
|
226 | + require('includes/includes/flt_page0.inc'); |
|
227 | + break; |
|
228 | 228 | } |
@@ -21,8 +21,8 @@ |
||
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 | } |
@@ -286,7 +286,6 @@ discard block |
||
286 | 286 | /** |
287 | 287 | * Функция пытается залогиниться по всем известным провайдерам |
288 | 288 | * |
289 | - * @param null $result |
|
290 | 289 | */ |
291 | 290 | public function login() { |
292 | 291 | if(empty(sn_module::$sn_module_list['auth'])) { |
@@ -823,10 +822,17 @@ discard block |
||
823 | 822 | |
824 | 823 | // OK v4.5 |
825 | 824 | // TODO - REMEMBER_ME |
825 | + |
|
826 | + /** |
|
827 | + * @param integer $period |
|
828 | + */ |
|
826 | 829 | protected static function cookie_set($value, $impersonate = false, $period = null) { |
827 | 830 | sn_setcookie($impersonate ? SN_COOKIE_U_I : SN_COOKIE_U, $value, $period === null ? SN_TIME_NOW + PERIOD_YEAR : $period, SN_ROOT_RELATIVE); |
828 | 831 | } |
829 | 832 | |
833 | + /** |
|
834 | + * @param string $message |
|
835 | + */ |
|
830 | 836 | protected static function flog($message, $die = false) { |
831 | 837 | if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
832 | 838 | return; |
@@ -199,18 +199,18 @@ discard block |
||
199 | 199 | // TODO Хотя тут может получится вечный цикл - ПОДУМАТЬ |
200 | 200 | // TODO Тут же можно пробовать провести попытку слияния аккаунтов - хотя это и очень небезопасно |
201 | 201 | |
202 | - if(sys_get_param('login_player_register_logout')) { |
|
202 | + if (sys_get_param('login_player_register_logout')) { |
|
203 | 203 | $this->logout(); |
204 | 204 | } |
205 | 205 | |
206 | 206 | $original_suggest = ''; |
207 | 207 | // Смотрим - есть ли у нас данные от пользователя |
208 | - if(($player_name_submitted = sys_get_param('submit_player_name'))) { |
|
208 | + if (($player_name_submitted = sys_get_param('submit_player_name'))) { |
|
209 | 209 | // Попытка регистрации нового игрока из данных, введенных пользователем |
210 | 210 | $this->player_suggested_name = sys_get_param_str_unsafe('player_suggested_name'); |
211 | 211 | } else { |
212 | - foreach($this->providers_authorised as $provider) { |
|
213 | - if($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5 |
|
212 | + foreach ($this->providers_authorised as $provider) { |
|
213 | + if ($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5 |
|
214 | 214 | $original_suggest = $provider->player_name_suggest(); |
215 | 215 | break; |
216 | 216 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | } |
219 | 219 | |
220 | 220 | // Если у нас провайдеры не дают имени и пользователь не дал свой вариант - это у нас первый логин в игру |
221 | - if(!$this->player_suggested_name) { |
|
221 | + if (!$this->player_suggested_name) { |
|
222 | 222 | $max_user_id = db_player_get_max_id(); // 4.5 |
223 | 223 | // TODO - предлагать имя игрока по локали |
224 | 224 | |
@@ -227,15 +227,15 @@ discard block |
||
227 | 227 | sn_db_transaction_rollback(); |
228 | 228 | $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000); |
229 | 229 | sn_db_transaction_start(); |
230 | - } while(db_player_name_exists($this->player_suggested_name)); |
|
230 | + } while (db_player_name_exists($this->player_suggested_name)); |
|
231 | 231 | |
232 | 232 | } |
233 | 233 | |
234 | - if($player_name_submitted) { |
|
234 | + if ($player_name_submitted) { |
|
235 | 235 | $this->register_player_db_create($this->player_suggested_name); // OK 4.5 |
236 | - if($this->register_status == LOGIN_SUCCESS) { |
|
236 | + if ($this->register_status == LOGIN_SUCCESS) { |
|
237 | 237 | sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
238 | - } elseif($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
|
238 | + } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
|
239 | 239 | // self::$player_suggested_name .= ' ' . $this->account->account_id; |
240 | 240 | } |
241 | 241 | // if(self::$login_status != LOGIN_SUCCESS) { |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | : false |
260 | 260 | ); |
261 | 261 | |
262 | - if($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
262 | + if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
263 | 263 | $prohibited_characters = array_map(function($value) { |
264 | 264 | return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
265 | 265 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
@@ -289,27 +289,27 @@ discard block |
||
289 | 289 | * @param null $result |
290 | 290 | */ |
291 | 291 | public function login() { |
292 | - if(empty(sn_module::$sn_module_list['auth'])) { |
|
292 | + if (empty(sn_module::$sn_module_list['auth'])) { |
|
293 | 293 | die('{Не обнаружено ни одного провайдера авторизации в core_auth::login()!}'); |
294 | 294 | } |
295 | 295 | |
296 | 296 | !empty($_POST) ? self::flog(dump($_POST, '$_POST')) : false; |
297 | 297 | !empty($_GET) ? self::flog(dump($_GET, '$_GET')) : false; |
298 | - !empty($_COOKIE) ? self::flog(dump($_COOKIE,'$_COOKIE')) : false; |
|
298 | + !empty($_COOKIE) ? self::flog(dump($_COOKIE, '$_COOKIE')) : false; |
|
299 | 299 | |
300 | 300 | $this->auth_reset(); // OK v4.5 |
301 | 301 | |
302 | 302 | $this->providers = array(); |
303 | - foreach(sn_module::$sn_module_list['auth'] as $module_name => $module) { |
|
303 | + foreach (sn_module::$sn_module_list['auth'] as $module_name => $module) { |
|
304 | 304 | $this->providers[$module->provider_id] = $module; |
305 | 305 | } |
306 | 306 | |
307 | 307 | // $this->providers = array_reverse($this->providers, true); // НИНАДА! СН-аккаунт должен всегда авторизироваться первым! |
308 | 308 | |
309 | - foreach($this->providers as $provider_id => $provider) { |
|
309 | + foreach ($this->providers as $provider_id => $provider) { |
|
310 | 310 | $login_status = $provider->login(); // OK v4.5 |
311 | 311 | self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); |
312 | - if($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
|
312 | + if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
|
313 | 313 | $this->providers_authorised[$provider_id] = &$this->providers[$provider_id]; |
314 | 314 | |
315 | 315 | $this->user_id_to_provider = array_replace_recursive( |
@@ -317,15 +317,15 @@ discard block |
||
317 | 317 | // static::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5 |
318 | 318 | PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5 |
319 | 319 | ); |
320 | - } elseif($login_status != LOGIN_UNDEFINED) { |
|
320 | + } elseif ($login_status != LOGIN_UNDEFINED) { |
|
321 | 321 | $this->provider_error_list[$provider_id] = $login_status; |
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
325 | - if(empty($this->providers_authorised)) { |
|
325 | + if (empty($this->providers_authorised)) { |
|
326 | 326 | // Ни один аккаунт не авторизирован |
327 | 327 | // Проверяем - есть ли у нас ошибки в аккаунтах? |
328 | - if(!empty($this->provider_error_list)) { |
|
328 | + if (!empty($this->provider_error_list)) { |
|
329 | 329 | // Если есть - выводим их |
330 | 330 | self::$login_status = reset($this->provider_error_list); |
331 | 331 | } |
@@ -340,12 +340,12 @@ discard block |
||
340 | 340 | // В self::$accessible_user_row_list - список доступных игроков для данных аккаунтов с соответствующими записями из таблицы `users` |
341 | 341 | |
342 | 342 | // Остались ли у нас в списке доступные игроки? |
343 | - if(empty($this->accessible_user_row_list)) { |
|
343 | + if (empty($this->accessible_user_row_list)) { |
|
344 | 344 | // Нет ни одного игрока ни на одном авторизированном аккаунте |
345 | 345 | // Надо регать нового игрока |
346 | 346 | |
347 | 347 | // Сейчас происходит процесс регистрации игрока? |
348 | - if(!$this->is_player_register) { |
|
348 | + if (!$this->is_player_register) { |
|
349 | 349 | // Нет - отправляем на процесс регистрации |
350 | 350 | $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id')); |
351 | 351 | sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : '')); |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | // Да, есть доступные игроки, которые так же прописаны в базе |
355 | 355 | $this->get_active_user(); // 4.5 |
356 | 356 | |
357 | - if($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) { |
|
357 | + if ($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) { |
|
358 | 358 | $a_user = db_user_by_id($this->is_impersonating); |
359 | 359 | $this->impersonator_username = $a_user['username']; |
360 | 360 | } |
@@ -362,9 +362,9 @@ discard block |
||
362 | 362 | |
363 | 363 | //Прописываем текущего игрока на все авторизированные аккаунты |
364 | 364 | // TODO - ИЛИ ВСЕХ ИГРОКОВ?? |
365 | - if(empty($this->is_impersonating)) { |
|
366 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
367 | - if(empty($this->user_id_to_provider[self::$user['id']][$provider_id])) { |
|
365 | + if (empty($this->is_impersonating)) { |
|
366 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
367 | + if (empty($this->user_id_to_provider[self::$user['id']][$provider_id])) { |
|
368 | 368 | // self::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']); |
369 | 369 | PlayerToAccountTranslate::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']); |
370 | 370 | $this->user_id_to_provider[self::$user['id']][$provider_id][$provider->account->account_id] = true; |
@@ -374,9 +374,9 @@ discard block |
||
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
377 | - if(empty(self::$user['id'])) { |
|
377 | + if (empty(self::$user['id'])) { |
|
378 | 378 | self::cookie_set(''); // OK 4.5 |
379 | - } elseif(self::$user['id'] != $_COOKIE[SN_COOKIE_U]) { |
|
379 | + } elseif (self::$user['id'] != $_COOKIE[SN_COOKIE_U]) { |
|
380 | 380 | self::cookie_set(self::$user['id']); // OK 4.5 |
381 | 381 | } |
382 | 382 | |
@@ -395,21 +395,21 @@ discard block |
||
395 | 395 | */ |
396 | 396 | // OK v4.7 |
397 | 397 | public function logout($redirect = true) { |
398 | - if(!empty($_COOKIE[SN_COOKIE_U_I])) { |
|
398 | + if (!empty($_COOKIE[SN_COOKIE_U_I])) { |
|
399 | 399 | self::cookie_set($_COOKIE[SN_COOKIE_U_I]); |
400 | 400 | self::cookie_set(0, true); |
401 | 401 | self::$main_provider->logout(); |
402 | 402 | } else { |
403 | - foreach($this->providers as $provider_name => $provider) { |
|
403 | + foreach ($this->providers as $provider_name => $provider) { |
|
404 | 404 | $provider->logout(); |
405 | 405 | } |
406 | 406 | |
407 | 407 | self::cookie_set(0); |
408 | 408 | } |
409 | 409 | |
410 | - if($redirect === true) { |
|
410 | + if ($redirect === true) { |
|
411 | 411 | sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); |
412 | - } elseif($redirect !== false) { |
|
412 | + } elseif ($redirect !== false) { |
|
413 | 413 | sys_redirect($redirect); |
414 | 414 | } |
415 | 415 | } |
@@ -420,15 +420,15 @@ discard block |
||
420 | 420 | * @param $user_selected |
421 | 421 | */ |
422 | 422 | public function impersonate($user_selected) { |
423 | - if($_COOKIE[SN_COOKIE_U_I]) { |
|
423 | + if ($_COOKIE[SN_COOKIE_U_I]) { |
|
424 | 424 | die('You already impersonating someone. Go back to living other\'s life! Or clear your cookies and try again'); // TODO: Log it |
425 | 425 | } |
426 | 426 | |
427 | - if($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) { |
|
427 | + if ($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) { |
|
428 | 428 | die('You can\'t impersonate - too low level'); // TODO: Log it |
429 | 429 | } |
430 | 430 | |
431 | - if($this->auth_level_max_local <= $user_selected['authlevel']) { |
|
431 | + if ($this->auth_level_max_local <= $user_selected['authlevel']) { |
|
432 | 432 | die('You can\'t impersonate this account - level is greater or equal to yours'); // TODO: Log it |
433 | 433 | } |
434 | 434 | |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | $account_translate = reset($account_translate[$user_selected['id']][self::$main_provider->provider_id]); |
437 | 437 | $account_to_impersonate = new Account(self::$main_provider->db); |
438 | 438 | $account_to_impersonate->db_get_by_id($account_translate['provider_account_id']); |
439 | - if(!$account_to_impersonate->is_exists) { |
|
439 | + if (!$account_to_impersonate->is_exists) { |
|
440 | 440 | die('Какая-то ошибка - не могу найти аккаунт для имперсонации'); // TODO: Log it |
441 | 441 | } |
442 | 442 | self::$main_provider->impersonate($account_to_impersonate); |
@@ -462,12 +462,12 @@ discard block |
||
462 | 462 | public function password_check($password_unsafe) { |
463 | 463 | $result = false; |
464 | 464 | |
465 | - if(empty($this->providers_authorised)) { |
|
465 | + if (empty($this->providers_authorised)) { |
|
466 | 466 | // TODO - такого быть не может! |
467 | 467 | self::flog("password_check: Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true); |
468 | 468 | } else { |
469 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
470 | - if($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) { |
|
469 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
470 | + if ($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) { |
|
471 | 471 | $result = $result || $provider->password_check($password_unsafe); |
472 | 472 | } |
473 | 473 | } |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | */ |
487 | 487 | // OK v4.6 |
488 | 488 | public function password_change($old_password_unsafe, $new_password_unsafe) { |
489 | - if(empty($this->providers_authorised)) { |
|
489 | + if (empty($this->providers_authorised)) { |
|
490 | 490 | // TODO - такого быть не может! |
491 | 491 | self::flog("Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true); |
492 | 492 | return false; |
@@ -499,8 +499,8 @@ discard block |
||
499 | 499 | $salt_unsafe = self::password_salt_generate(); |
500 | 500 | |
501 | 501 | $providers_changed_password = array(); |
502 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
503 | - if( |
|
502 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
503 | + if ( |
|
504 | 504 | !$provider->is_feature_supported(AUTH_FEATURE_PASSWORD_CHANGE) |
505 | 505 | || !$provider->password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe) |
506 | 506 | ) { |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id); |
513 | 513 | |
514 | 514 | // Рассылаем уведомления о смене пароля в ЛС |
515 | - foreach($account_translation as $user_id => $provider_info) { |
|
515 | + foreach ($account_translation as $user_id => $provider_info) { |
|
516 | 516 | // TODO - УКазывать тип аккаунта, на котором сменён пароль |
517 | 517 | msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN, |
518 | 518 | classLocale::$lang['sys_administration'], classLocale::$lang['sys_login_register_message_title'], |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | sn_db_transaction_start(); |
560 | 560 | // Проверить наличие такого имени в истории имён |
561 | 561 | |
562 | - if(db_player_name_exists($player_name_unsafe)) { |
|
562 | + if (db_player_name_exists($player_name_unsafe)) { |
|
563 | 563 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_EXISTS, ERR_ERROR); |
564 | 564 | } |
565 | 565 | |
@@ -567,11 +567,11 @@ discard block |
||
567 | 567 | $player_language = ''; |
568 | 568 | $player_email = ''; |
569 | 569 | // TODO - порнография - работа должна происходить над списком аккаунтов, а не только на одном аккаунте... |
570 | - foreach($this->providers_authorised as $provider) { |
|
571 | - if(!$player_language && $provider->account->account_language) { |
|
570 | + foreach ($this->providers_authorised as $provider) { |
|
571 | + if (!$player_language && $provider->account->account_language) { |
|
572 | 572 | $player_language = $provider->account->account_language; |
573 | 573 | } |
574 | - if(!$player_email && $provider->account->account_email) { |
|
574 | + if (!$player_email && $provider->account->account_email) { |
|
575 | 575 | $player_email = $provider->account->account_email; |
576 | 576 | } |
577 | 577 | } |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | )); |
588 | 588 | // Зарегестрировать на него аккаунты из self::$accounts_authorised |
589 | 589 | $a_user = self::$user; |
590 | - foreach($this->providers_authorised as $provider) { |
|
590 | + foreach ($this->providers_authorised as $provider) { |
|
591 | 591 | // TODO - порнография. Должен быть отдельный класс трансляторов - в т.ч. и кэширующий транслятор |
592 | 592 | // TODO - ну и работа должна происходить над списком аккаунтов, а не только на одном аккаунте... |
593 | 593 | // self::db_translate_register_user($provider->provider_id, $provider->account->account_id, $a_user['id']); |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | |
600 | 600 | sn_db_transaction_commit(); |
601 | 601 | $this->register_status = LOGIN_SUCCESS; |
602 | - } catch(Exception $e) { |
|
602 | + } catch (Exception $e) { |
|
603 | 603 | sn_db_transaction_rollback(); |
604 | 604 | |
605 | 605 | // Если старое имя занято |
@@ -618,10 +618,10 @@ discard block |
||
618 | 618 | // Пробиваем все ИД игроков по базе - есть ли вообще такие записи |
619 | 619 | // Вообще-то это не особо нужно - у нас по определению стоят констраинты |
620 | 620 | // Зато так мы узнаем максимальный authlevel, проверим права имперсонейта и вытащим все записи юзеров |
621 | - foreach($this->user_id_to_provider as $user_id => $cork) { |
|
621 | + foreach ($this->user_id_to_provider as $user_id => $cork) { |
|
622 | 622 | $user = db_user_by_id($user_id); |
623 | 623 | // Если записи игрока в БД не существует? |
624 | - if(empty($user['id'])) { |
|
624 | + if (empty($user['id'])) { |
|
625 | 625 | // Удаляем этого и переходим к следующему |
626 | 626 | unset($this->user_id_to_provider[$user_id]); |
627 | 627 | // Де-регистрируем игрока из таблицы трансляции игроков |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | // OK v4.5 |
643 | 643 | protected function get_active_user() { |
644 | 644 | // Проверяем куку "текущего игрока" из браузера |
645 | - if( |
|
645 | + if ( |
|
646 | 646 | // Кука не пустая |
647 | 647 | ($_COOKIE[SN_COOKIE_U] = trim($_COOKIE[SN_COOKIE_U])) && !empty($_COOKIE[SN_COOKIE_U]) |
648 | 648 | // И в куке находится ID |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | } |
668 | 668 | |
669 | 669 | // В куке нет валидного ИД записи игрока, доступной с текущих аккаунтов |
670 | - if(empty(self::$user['id'])) { |
|
670 | + if (empty(self::$user['id'])) { |
|
671 | 671 | // Берем первого из доступных |
672 | 672 | // TODO - default_user |
673 | 673 | self::$user = reset($this->accessible_user_row_list); |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | |
690 | 690 | $result = array(); |
691 | 691 | |
692 | - if($user_id && empty($this->is_impersonating)) { |
|
692 | + if ($user_id && empty($this->is_impersonating)) { |
|
693 | 693 | // self::db_counter_insert(); |
694 | 694 | self::$device->db_counter_insert($user_id); |
695 | 695 | |
@@ -697,12 +697,12 @@ discard block |
||
697 | 697 | |
698 | 698 | sys_user_options_unpack($user); |
699 | 699 | |
700 | - if($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) { |
|
700 | + if ($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) { |
|
701 | 701 | $user['banaday'] = 0; |
702 | 702 | $user['vacation'] = SN_TIME_NOW; |
703 | 703 | } |
704 | 704 | |
705 | - $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip']; |
|
705 | + $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip']; |
|
706 | 706 | $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain']; |
707 | 707 | |
708 | 708 | $result[F_BANNED_STATUS] = $user['banaday']; |
@@ -716,9 +716,9 @@ discard block |
||
716 | 716 | ); |
717 | 717 | } |
718 | 718 | |
719 | - if($extra = classSupernova::$config->security_ban_extra) { |
|
719 | + if ($extra = classSupernova::$config->security_ban_extra) { |
|
720 | 720 | $extra = explode(',', $extra); |
721 | - array_walk($extra,'trim'); |
|
721 | + array_walk($extra, 'trim'); |
|
722 | 722 | in_array(self::$device->device_id, $extra) and die(); |
723 | 723 | } |
724 | 724 | |
@@ -754,21 +754,21 @@ discard block |
||
754 | 754 | protected function register_player_name_validate($player_name_unsafe) { |
755 | 755 | // TODO - переделать под RAW-строки |
756 | 756 | // Если имя игрока пустое - NO GO! |
757 | - if(trim($player_name_unsafe) == '') { |
|
757 | + if (trim($player_name_unsafe) == '') { |
|
758 | 758 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_EMPTY, ERR_ERROR); |
759 | 759 | } |
760 | 760 | // Проверяем, что бы в начале и конце не было пустых символов |
761 | - if($player_name_unsafe != trim($player_name_unsafe)) { |
|
761 | + if ($player_name_unsafe != trim($player_name_unsafe)) { |
|
762 | 762 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_TRIMMED, ERR_ERROR); |
763 | 763 | } |
764 | 764 | // Если логин имеет запрещенные символы - NO GO! |
765 | - if(strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
765 | + if (strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
766 | 766 | // TODO - выдавать в сообщение об ошибке список запрещенных символов |
767 | 767 | // TODO - заранее извещать игрока, какие символы являются запрещенными |
768 | 768 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_RESTRICTED_CHARACTERS, ERR_ERROR); |
769 | 769 | } |
770 | 770 | // Если логин меньше минимальной длины - NO GO! |
771 | - if(strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) { |
|
771 | + if (strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) { |
|
772 | 772 | // TODO - выдавать в сообщение об ошибке минимальную длину имени игрока |
773 | 773 | // TODO - заранее извещать игрока, какая минимальная и максимальная длина имени |
774 | 774 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_SHORT, ERR_ERROR); |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | } |
827 | 827 | |
828 | 828 | protected static function flog($message, $die = false) { |
829 | - if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
829 | + if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
830 | 830 | return; |
831 | 831 | } |
832 | 832 | list($called, $caller) = debug_backtrace(false); |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
840 | 840 | |
841 | 841 | classSupernova::log_file("$message - $caller_name"); |
842 | - if($die) { |
|
842 | + if ($die) { |
|
843 | 843 | // pdump($caller); |
844 | 844 | // pdump(debug_backtrace(false)); |
845 | 845 | $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |