@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | function sys_user_vacation($user) { |
10 | 10 | global $config; |
11 | 11 | |
12 | - if(sys_get_param_str('vacation') == 'leave') { |
|
12 | + if (sys_get_param_str('vacation') == 'leave') { |
|
13 | 13 | if ($user['vacation'] < SN_TIME_NOW) { |
14 | 14 | $user['vacation'] = 0; |
15 | 15 | $user['vacation_next'] = SN_TIME_NOW + $config->player_vacation_timeout; |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | - if($user['vacation']) { |
|
20 | + if ($user['vacation']) { |
|
21 | 21 | // sn_sys_logout(false, true); |
22 | 22 | // core_auth::logout(false, true); |
23 | 23 | |
@@ -52,33 +52,33 @@ discard block |
||
52 | 52 | // TODO: Full rewrite |
53 | 53 | sn_db_transaction_start(); |
54 | 54 | $TheUser = db_user_by_id($UserID); |
55 | - if ( $TheUser['ally_id'] != 0 ) { |
|
56 | - $TheAlly = doquery ( "SELECT * FROM `{{alliance}}` WHERE `id` = '" . $TheUser['ally_id'] . "';", '', true ); |
|
55 | + if ($TheUser['ally_id'] != 0) { |
|
56 | + $TheAlly = doquery("SELECT * FROM `{{alliance}}` WHERE `id` = '" . $TheUser['ally_id'] . "';", '', true); |
|
57 | 57 | $TheAlly['ally_members'] -= 1; |
58 | - if ( $TheAlly['ally_members'] > 0 ) { |
|
59 | - doquery ( "UPDATE `{{alliance}}` SET `ally_members` = '" . $TheAlly['ally_members'] . "' WHERE `id` = '" . $TheAlly['id'] . "';"); |
|
58 | + if ($TheAlly['ally_members'] > 0) { |
|
59 | + doquery("UPDATE `{{alliance}}` SET `ally_members` = '" . $TheAlly['ally_members'] . "' WHERE `id` = '" . $TheAlly['id'] . "';"); |
|
60 | 60 | } else { |
61 | - doquery ( "DELETE FROM `{{alliance}}` WHERE `id` = '" . $TheAlly['id'] . "';"); |
|
62 | - doquery ( "DELETE FROM `{{statpoints}}` WHERE `stat_type` = '2' AND `id_owner` = '" . $TheAlly['id'] . "';"); |
|
61 | + doquery("DELETE FROM `{{alliance}}` WHERE `id` = '" . $TheAlly['id'] . "';"); |
|
62 | + doquery("DELETE FROM `{{statpoints}}` WHERE `stat_type` = '2' AND `id_owner` = '" . $TheAlly['id'] . "';"); |
|
63 | 63 | } |
64 | 64 | } |
65 | - doquery ( "DELETE FROM `{{statpoints}}` WHERE `stat_type` = '1' AND `id_owner` = '" . $UserID . "';"); |
|
65 | + doquery("DELETE FROM `{{statpoints}}` WHERE `stat_type` = '1' AND `id_owner` = '" . $UserID . "';"); |
|
66 | 66 | |
67 | 67 | DBStaticPlanet::db_planet_list_delete_by_owner($UserID); |
68 | 68 | |
69 | - doquery ( "DELETE FROM `{{messages}}` WHERE `message_sender` = '" . $UserID . "';"); |
|
70 | - doquery ( "DELETE FROM `{{messages}}` WHERE `message_owner` = '" . $UserID . "';"); |
|
71 | - doquery ( "DELETE FROM `{{notes}}` WHERE `owner` = '" . $UserID . "';"); |
|
69 | + doquery("DELETE FROM `{{messages}}` WHERE `message_sender` = '" . $UserID . "';"); |
|
70 | + doquery("DELETE FROM `{{messages}}` WHERE `message_owner` = '" . $UserID . "';"); |
|
71 | + doquery("DELETE FROM `{{notes}}` WHERE `owner` = '" . $UserID . "';"); |
|
72 | 72 | db_fleet_list_delete_by_owner($UserID); |
73 | 73 | // doquery ( "DELETE FROM `{{rw}}` WHERE `id_owner1` = '" . $UserID . "';"); |
74 | 74 | // doquery ( "DELETE FROM `{{rw}}` WHERE `id_owner2` = '" . $UserID . "';"); |
75 | - doquery ( "DELETE FROM `{{buddy}}` WHERE `BUDDY_SENDER_ID` = '" . $UserID . "';"); |
|
76 | - doquery ( "DELETE FROM `{{buddy}}` WHERE `BUDDY_OWNER_ID` = '" . $UserID . "';"); |
|
77 | - doquery ( "DELETE FROM `{{annonce}}` WHERE `user` = '" . $UserID . "';"); |
|
75 | + doquery("DELETE FROM `{{buddy}}` WHERE `BUDDY_SENDER_ID` = '" . $UserID . "';"); |
|
76 | + doquery("DELETE FROM `{{buddy}}` WHERE `BUDDY_OWNER_ID` = '" . $UserID . "';"); |
|
77 | + doquery("DELETE FROM `{{annonce}}` WHERE `user` = '" . $UserID . "';"); |
|
78 | 78 | |
79 | 79 | |
80 | 80 | classSupernova::db_del_record_by_id(LOC_USER, $UserID); |
81 | - doquery ( "DELETE FROM `{{referrals}}` WHERE (`id` = '{$UserID}') OR (`id_partner` = '{$UserID}');"); |
|
81 | + doquery("DELETE FROM `{{referrals}}` WHERE (`id` = '{$UserID}') OR (`id_partner` = '{$UserID}');"); |
|
82 | 82 | global $config; |
83 | 83 | $config->db_saveItem('users_amount', $config->db_loadItem('users_amount') - 1); |
84 | 84 | sn_db_transaction_commit(); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | \DBAL\DbQuery::build()->setTable('users')->setValues($field_set)->doInsert(); |
181 | 181 | $user_new = db_user_by_id(db_insert_id()); |
182 | 182 | |
183 | - if(!($options['galaxy'] && $options['system'] && $options['planet'])) { |
|
183 | + if (!($options['galaxy'] && $options['system'] && $options['planet'])) { |
|
184 | 184 | $options['galaxy'] = $config->LastSettedGalaxyPos; |
185 | 185 | $options['system'] = $config->LastSettedSystemPos; |
186 | 186 | $segment_size = floor($config->game_maxPlanet / 3); |
@@ -188,19 +188,19 @@ discard block |
||
188 | 188 | $segment++; |
189 | 189 | $options['planet'] = mt_rand(1 + $segment * $segment_size, ($segment + 1) * $segment_size); |
190 | 190 | |
191 | - while(true) { |
|
192 | - if($options['planet'] > $config->game_maxPlanet) { |
|
191 | + while (true) { |
|
192 | + if ($options['planet'] > $config->game_maxPlanet) { |
|
193 | 193 | $options['planet'] = mt_rand(0, $segment_size - 1) + 1; |
194 | 194 | $options['system']++; |
195 | 195 | } |
196 | - if($options['system'] > $config->game_maxSystem) { |
|
196 | + if ($options['system'] > $config->game_maxSystem) { |
|
197 | 197 | $options['system'] = 1; |
198 | 198 | $options['galaxy']++; |
199 | 199 | } |
200 | 200 | $options['galaxy'] > $config->game_maxGalaxy ? $options['galaxy'] = 1 : false; |
201 | 201 | |
202 | 202 | $galaxy_row = DBStaticPlanet::db_planet_by_gspt($options['galaxy'], $options['system'], $options['planet'], PT_PLANET, true, 'id'); |
203 | - if(!$galaxy_row['id']) { |
|
203 | + if (!$galaxy_row['id']) { |
|
204 | 204 | $config->db_saveItem(array( |
205 | 205 | 'LastSettedGalaxyPos' => $options['galaxy'], |
206 | 206 | 'LastSettedSystemPos' => $options['system'], |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | $username_safe = db_escape($username_unsafe); |
224 | 224 | doquery("REPLACE INTO {{player_name_history}} SET `player_id` = {$user_new['id']}, `player_name` = '{$username_safe}'"); |
225 | 225 | |
226 | - if(!empty($options['partner_id']) && ($referral_row = db_user_by_id($options['partner_id'], true))) { |
|
226 | + if (!empty($options['partner_id']) && ($referral_row = db_user_by_id($options['partner_id'], true))) { |
|
227 | 227 | doquery("INSERT INTO {{referrals}} SET `id` = {$user_new['id']}, `id_partner` = {$options['partner_id']}"); |
228 | 228 | } |
229 | 229 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | $user_auth_level = isset($user['authlevel']) ? $user['authlevel'] : AUTH_LEVEL_ANONYMOUS; |
15 | 15 | |
16 | 16 | $mode = sys_get_param_int('mode'); |
17 | - switch($mode) |
|
17 | + switch ($mode) |
|
18 | 18 | { |
19 | 19 | case CHAT_MODE_ALLY: |
20 | 20 | $template_result['ALLY'] = intval($user['ally_id']); |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | } |
29 | 29 | |
30 | 30 | $template_result['.']['smiles'] = array(); |
31 | - foreach(classSupernova::$gc->design->getSmilesList() as $auth_level => $replaces) { |
|
32 | - if($auth_level > $user_auth_level) { |
|
31 | + foreach (classSupernova::$gc->design->getSmilesList() as $auth_level => $replaces) { |
|
32 | + if ($auth_level > $user_auth_level) { |
|
33 | 33 | continue; |
34 | 34 | } |
35 | 35 | |
36 | - foreach($replaces as $bbcode => $filename) |
|
36 | + foreach ($replaces as $bbcode => $filename) |
|
37 | 37 | { |
38 | 38 | $template_result['.']['smiles'][] = array( |
39 | 39 | 'BBCODE' => $bbcode, |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | |
58 | 58 | define('IN_AJAX', true); |
59 | 59 | |
60 | - if($config->getMode() != classCache::CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) |
|
60 | + if ($config->getMode() != classCache::CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) |
|
61 | 61 | { |
62 | 62 | die(); |
63 | 63 | } |
64 | 64 | |
65 | - if(($message = sys_get_param_str('message')) && $user['username']) |
|
65 | + if (($message = sys_get_param_str('message')) && $user['username']) |
|
66 | 66 | { |
67 | 67 | $ally_id = sys_get_param('ally') && $user['ally_id'] ? $user['ally_id'] : 0; |
68 | 68 | $nick = db_escape(player_nick_compact(player_nick_render_current_to_array($user, array('color' => true, 'icons' => true, 'ally' => !$ally_id)))); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | define('IN_AJAX', true); |
84 | 84 | |
85 | 85 | $history = sys_get_param_str('history'); |
86 | - if(!$history) |
|
86 | + if (!$history) |
|
87 | 87 | { |
88 | 88 | $config->array_set('users', $user['id'], 'chat_last_refresh', SN_TIME_MICRO); |
89 | 89 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $last_message = ''; |
93 | 93 | $alliance = 0; |
94 | 94 | $template_result['.']['chat'] = array(); |
95 | - if(!$history && $config->getMode() != classCache::CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) |
|
95 | + if (!$history && $config->getMode() != classCache::CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) |
|
96 | 96 | { |
97 | 97 | $result['disable'] = true; |
98 | 98 | $template_result['.']['chat'][] = array( |
@@ -108,12 +108,12 @@ discard block |
||
108 | 108 | |
109 | 109 | $where_add = ''; |
110 | 110 | $last_message = 0; |
111 | - if($history) |
|
111 | + if ($history) |
|
112 | 112 | { |
113 | 113 | $rows = doquery("SELECT count(1) AS CNT FROM {{chat}} WHERE ally_id = '{$alliance}';", true); |
114 | 114 | $page_count = ceil($rows['CNT'] / $page_limit); |
115 | 115 | |
116 | - for($i = 0; $i < $page_count; $i++) |
|
116 | + for ($i = 0; $i < $page_count; $i++) |
|
117 | 117 | { |
118 | 118 | $template_result['.']['page'][] = array( |
119 | 119 | 'NUMBER' => $i |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | {{chat}} AS c |
136 | 136 | LEFT JOIN {{users}} AS u ON u.id = c.chat_message_sender_id |
137 | 137 | WHERE c.chat_message_recipient_id IS NULL AND c.ally_id = '{$alliance}' {$where_add} ORDER BY messageid DESC LIMIT {$start_row}, {$page_limit};"); |
138 | - while($chat_row = db_fetch($query)) |
|
138 | + while ($chat_row = db_fetch($query)) |
|
139 | 139 | { |
140 | 140 | // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick |
141 | 141 | $chat_row['user'] = player_nick_render_to_html($chat_row['user']); |
142 | 142 | $nick_stripped = htmlentities(strip_tags($chat_row['user']), ENT_QUOTES, 'utf-8'); |
143 | 143 | $nick = str_replace(strip_tags($chat_row['user']), $nick_stripped, $chat_row['user']); |
144 | - if(!$history) |
|
144 | + if (!$history) |
|
145 | 145 | { |
146 | 146 | $nick = "<span style=\"cursor: pointer;\" onclick=\"addSmiley('({$nick_stripped})');\">{$nick}</span>"; |
147 | 147 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | $template = gettemplate('chat_messages', $template); |
168 | 168 | $template->assign_recursive($template_result); |
169 | 169 | |
170 | - if($history) |
|
170 | + if ($history) |
|
171 | 171 | { |
172 | 172 | $pageTitle = "{$lang['chat_history']} - {$lang[$alliance ? 'chat_ally' : 'chat_common']}"; |
173 | 173 | display($template, $pageTitle); |
@@ -4,8 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -function sn_chat_model() |
|
8 | -{ |
|
7 | +function sn_chat_model() { |
|
9 | 8 | global $config, $user, $template_result, $lang; |
10 | 9 | |
11 | 10 | $config->array_set('users', $user['id'], 'chat_last_activity', SN_TIME_MICRO); |
@@ -44,15 +43,13 @@ discard block |
||
44 | 43 | |
45 | 44 | $template_result['PAGE_HEADER'] = $page_title; |
46 | 45 | } |
47 | -function sn_chat_view($template = null) |
|
48 | -{ |
|
46 | +function sn_chat_view($template = null) { |
|
49 | 47 | $template = gettemplate('chat_body', $template); |
50 | 48 | |
51 | 49 | return $template; |
52 | 50 | } |
53 | 51 | |
54 | -function sn_chat_add_model() |
|
55 | -{ |
|
52 | +function sn_chat_add_model() { |
|
56 | 53 | global $config, $user; |
57 | 54 | |
58 | 55 | define('IN_AJAX', true); |
@@ -76,8 +73,7 @@ discard block |
||
76 | 73 | |
77 | 74 | die(); |
78 | 75 | } |
79 | -function sn_chat_msg_view($template = null) |
|
80 | -{ |
|
76 | +function sn_chat_msg_view($template = null) { |
|
81 | 77 | global $config, $user, $lang; |
82 | 78 | |
83 | 79 | define('IN_AJAX', true); |
@@ -99,8 +95,7 @@ discard block |
||
99 | 95 | 'TIME' => date(FMT_DATE_TIME, htmlentities(SN_CLIENT_TIME_LOCAL, ENT_QUOTES, 'utf-8')), |
100 | 96 | 'DISABLE' => true, |
101 | 97 | ); |
102 | - } |
|
103 | - else |
|
98 | + } else |
|
104 | 99 | { |
105 | 100 | $alliance = sys_get_param_str('ally') && $user['ally_id'] ? $user['ally_id'] : 0; |
106 | 101 | |
@@ -121,8 +116,7 @@ discard block |
||
121 | 116 | } |
122 | 117 | |
123 | 118 | $page = min($page_count, max(0, sys_get_param_int('sheet'))); |
124 | - } |
|
125 | - else |
|
119 | + } else |
|
126 | 120 | { |
127 | 121 | $last_message = sys_get_param_id('last_message'); |
128 | 122 | $where_add = $last_message ? "AND `messageid` > {$last_message}" : ''; |
@@ -171,8 +165,7 @@ discard block |
||
171 | 165 | { |
172 | 166 | $pageTitle = "{$lang['chat_history']} - {$lang[$alliance ? 'chat_ally' : 'chat_common']}"; |
173 | 167 | display($template, $pageTitle); |
174 | - } |
|
175 | - else |
|
168 | + } else |
|
176 | 169 | { |
177 | 170 | $result['last_message'] = $last_message; |
178 | 171 | $result['html'] = templateRenderToHtml($template); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @return array |
241 | 241 | */ |
242 | 242 | public static function parseParamStrings($array, $delimiter = '=') { |
243 | - !is_array($array) ? $array = array((string)$array) : false; |
|
243 | + !is_array($array) ? $array = array((string) $array) : false; |
|
244 | 244 | |
245 | 245 | $result = array(); |
246 | 246 | foreach ($array as $param) { |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | * @return float|null |
263 | 263 | */ |
264 | 264 | public static function maxValueByField(&$array, $fieldName) { |
265 | - return array_reduce($array, function ($carry, $item) use ($fieldName) { |
|
266 | - if(is_array($item) && isset($item[$fieldName]) && (!isset($carry) || $carry < $item[$fieldName])) { |
|
265 | + return array_reduce($array, function($carry, $item) use ($fieldName) { |
|
266 | + if (is_array($item) && isset($item[$fieldName]) && (!isset($carry) || $carry < $item[$fieldName])) { |
|
267 | 267 | $carry = $item[$fieldName]; |
268 | 268 | } |
269 | 269 | |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | |
281 | 281 | return |
282 | 282 | array_reduce($array, |
283 | - function ($carry, $item) use (&$fieldName, $maxValue) { |
|
284 | - if(is_array($item) && isset($item[$fieldName]) && $item[$fieldName] == $maxValue) { |
|
283 | + function($carry, $item) use (&$fieldName, $maxValue) { |
|
284 | + if (is_array($item) && isset($item[$fieldName]) && $item[$fieldName] == $maxValue) { |
|
285 | 285 | $carry[] = $item; |
286 | 286 | } |
287 | 287 | |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | } |
293 | 293 | |
294 | 294 | public static function intersectByKeys(array &$array1, array &$array2) { |
295 | - return array_uintersect_assoc($array1, $array2, function ($a, $b) {return 0;}); |
|
295 | + return array_uintersect_assoc($array1, $array2, function($a, $b) {return 0; }); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | } |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | |
53 | 53 | $prefix_length = strlen($this->db->db_prefix); |
54 | 54 | |
55 | - while($row = $this->db->db_fetch($query)) { |
|
56 | - foreach($row as $table_name) { |
|
55 | + while ($row = $this->db->db_fetch($query)) { |
|
56 | + foreach ($row as $table_name) { |
|
57 | 57 | $this->tablesAll[$table_name] = $table_name; |
58 | 58 | |
59 | - if(strpos($table_name, $this->db->db_prefix) === 0) { |
|
59 | + if (strpos($table_name, $this->db->db_prefix) === 0) { |
|
60 | 60 | $table_name_sn = substr($table_name, $prefix_length); |
61 | 61 | $this->tablesSn[$table_name_sn] = $table_name_sn; |
62 | 62 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return \string[] |
71 | 71 | */ |
72 | 72 | public function getAllTables() { |
73 | - if(!isset($this->tablesAll)) { |
|
73 | + if (!isset($this->tablesAll)) { |
|
74 | 74 | $this->loadTableNamesFromDb(); |
75 | 75 | } |
76 | 76 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @return string[] |
84 | 84 | */ |
85 | 85 | public function getSnTables() { |
86 | - if(!isset($this->tablesSn)) { |
|
86 | + if (!isset($this->tablesSn)) { |
|
87 | 87 | $this->loadTableNamesFromDb(); |
88 | 88 | } |
89 | 89 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @return TableSchema |
108 | 108 | */ |
109 | 109 | public function getTableSchema($tableName) { |
110 | - if(empty($this->tableSchemas[$tableName])) { |
|
110 | + if (empty($this->tableSchemas[$tableName])) { |
|
111 | 111 | $this->tableSchemas[$tableName] = new TableSchema($tableName, $this); |
112 | 112 | } |
113 | 113 |
@@ -29,7 +29,7 @@ |
||
29 | 29 | */ |
30 | 30 | protected $_repository; |
31 | 31 | |
32 | - /** |
|
32 | + /** |
|
33 | 33 | * @var ContainerPlus $_oldRepo |
34 | 34 | */ |
35 | 35 | protected $_oldRepo; |
@@ -86,7 +86,7 @@ |
||
86 | 86 | |
87 | 87 | public function get($entityClass, $id) { |
88 | 88 | $entityIndex = get_class($entityClass) . '\\' . $id; |
89 | - if(!isset($this->_repository[$entityIndex])) { |
|
89 | + if (!isset($this->_repository[$entityIndex])) { |
|
90 | 90 | |
91 | 91 | } |
92 | 92 |
@@ -11,7 +11,7 @@ |
||
11 | 11 | class SnBootstrap { |
12 | 12 | |
13 | 13 | public static function install_benchmark() { |
14 | - register_shutdown_function(function () { |
|
14 | + register_shutdown_function(function() { |
|
15 | 15 | if (defined('IN_AJAX')) { |
16 | 16 | return; |
17 | 17 | } |
@@ -58,7 +58,7 @@ |
||
58 | 58 | $config->pass()->game_disable = GAME_DISABLE_STAT; |
59 | 59 | |
60 | 60 | $statMinimalInterval = intval($config->pass()->stats_minimal_interval); |
61 | - $config->pass()->var_stat_update_end= date(FMT_DATE_TIME_SQL, SN_TIME_NOW + ($statMinimalInterval ? $statMinimalInterval : STATS_RUN_INTERVAL_MINIMUM)); |
|
61 | + $config->pass()->var_stat_update_end = date(FMT_DATE_TIME_SQL, SN_TIME_NOW + ($statMinimalInterval ? $statMinimalInterval : STATS_RUN_INTERVAL_MINIMUM)); |
|
62 | 62 | $config->pass()->var_stat_update_msg = 'Update started'; |
63 | 63 | sn_db_transaction_commit(); |
64 | 64 |
@@ -22,11 +22,11 @@ |
||
22 | 22 | |
23 | 23 | define('IN_AJAX', true); |
24 | 24 | |
25 | -if(($result = StatUpdateLauncher::scheduler_process()) && !defined('IN_ADMIN')) { |
|
25 | +if (($result = StatUpdateLauncher::scheduler_process()) && !defined('IN_ADMIN')) { |
|
26 | 26 | $result = htmlspecialchars($result, ENT_QUOTES, 'UTF-8'); |
27 | 27 | print(json_encode($result)); |
28 | 28 | } |
29 | 29 | |
30 | -if(!defined('IN_ADMIN')) { |
|
30 | +if (!defined('IN_ADMIN')) { |
|
31 | 31 | die(); |
32 | 32 | } |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | $this->prepare(); |
97 | 97 | |
98 | 98 | $this->manifest['active'] = false; |
99 | - if(!empty($this->config) && is_array($this->config['db'])) { |
|
99 | + if (!empty($this->config) && is_array($this->config['db'])) { |
|
100 | 100 | // БД, отличная от стандартной |
101 | 101 | $this->db = new db_mysql(); |
102 | 102 | |
103 | 103 | $this->db->sn_db_connect($this->config['db']); |
104 | - if($this->manifest['active'] = $this->db->connected) { |
|
104 | + if ($this->manifest['active'] = $this->db->connected) { |
|
105 | 105 | $this->provider_id = ACCOUNT_PROVIDER_CENTRAL; |
106 | 106 | |
107 | 107 | $this->domain = $this->config['domain']; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | // Fallback to local DB |
118 | - if(!$this->manifest['active']) { |
|
118 | + if (!$this->manifest['active']) { |
|
119 | 119 | $this->db = classSupernova::$db; |
120 | 120 | |
121 | 121 | $this->provider_id = ACCOUNT_PROVIDER_LOCAL; |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | */ |
170 | 170 | public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) { |
171 | 171 | $result = parent::password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe); |
172 | - if($result) { |
|
172 | + if ($result) { |
|
173 | 173 | $this->cookie_set(); |
174 | 174 | } |
175 | 175 | |
@@ -198,12 +198,12 @@ discard block |
||
198 | 198 | protected function password_reset_send_code() { |
199 | 199 | global $lang, $config; |
200 | 200 | |
201 | - if(!$this->is_password_reset) { |
|
201 | + if (!$this->is_password_reset) { |
|
202 | 202 | return $this->account_login_status; |
203 | 203 | } |
204 | 204 | |
205 | 205 | // Проверяем поддержку сброса пароля |
206 | - if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
206 | + if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
207 | 207 | return $this->account_login_status; |
208 | 208 | } |
209 | 209 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | unset($this->account); |
214 | 214 | $this->account = new Account($this->db); |
215 | 215 | |
216 | - if(!$this->account->db_get_by_email($email_unsafe)) { |
|
216 | + if (!$this->account->db_get_by_email($email_unsafe)) { |
|
217 | 217 | throw new Exception(PASSWORD_RESTORE_ERROR_EMAIL_NOT_EXISTS, ERR_ERROR); |
218 | 218 | // return $this->account_login_status; |
219 | 219 | } |
@@ -223,14 +223,14 @@ discard block |
||
223 | 223 | |
224 | 224 | // TODO - Проверять уровень доступа аккаунта! |
225 | 225 | // Аккаунты с АУТЛЕВЕЛ больше 0 - НЕ СБРАСЫВАЮТ ПАРОЛИ! |
226 | - foreach($user_list as $user_id => $user_data) { |
|
227 | - if($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) { |
|
226 | + foreach ($user_list as $user_id => $user_data) { |
|
227 | + if ($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) { |
|
228 | 228 | throw new Exception(PASSWORD_RESTORE_ERROR_ADMIN_ACCOUNT, ERR_ERROR); |
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | 232 | $confirmation = $this->confirmation->db_confirmation_get_latest_by_type_and_email(CONFIRM_PASSWORD_RESET, $email_unsafe); // OK 4.5 |
233 | - if(isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) { |
|
233 | + if (isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) { |
|
234 | 234 | throw new Exception(PASSWORD_RESTORE_ERROR_TOO_OFTEN, ERR_ERROR); |
235 | 235 | } |
236 | 236 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $confirm_code_unsafe = $this->confirmation->db_confirmation_get_unique_code_by_type_and_email(CONFIRM_PASSWORD_RESET, $email_unsafe); // OK 4.5 |
242 | 242 | sn_db_transaction_commit(); |
243 | 243 | |
244 | - if(!is_email($email_unsafe)) { |
|
244 | + if (!is_email($email_unsafe)) { |
|
245 | 245 | classSupernova::$debug->error("Email is invalid: '{$email_unsafe}'", 'Invalid email for password restoration'); |
246 | 246 | } |
247 | 247 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | ); |
252 | 252 | |
253 | 253 | $result = $result ? PASSWORD_RESTORE_SUCCESS_CODE_SENT : PASSWORD_RESTORE_ERROR_SENDING; |
254 | - } catch(Exception $e) { |
|
254 | + } catch (Exception $e) { |
|
255 | 255 | sn_db_transaction_rollback(); |
256 | 256 | $result = $e->getMessage(); |
257 | 257 | } |
@@ -266,46 +266,46 @@ discard block |
||
266 | 266 | protected function password_reset_confirm() { |
267 | 267 | global $lang, $config; |
268 | 268 | |
269 | - if(!$this->is_password_reset_confirm) { |
|
269 | + if (!$this->is_password_reset_confirm) { |
|
270 | 270 | return $this->account_login_status; |
271 | 271 | } |
272 | 272 | |
273 | - if($this->account_login_status != LOGIN_UNDEFINED) { |
|
273 | + if ($this->account_login_status != LOGIN_UNDEFINED) { |
|
274 | 274 | return $this->account_login_status; |
275 | 275 | } |
276 | 276 | |
277 | 277 | // Проверяем поддержку сброса пароля |
278 | - if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
278 | + if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
279 | 279 | return $this->account_login_status; |
280 | 280 | } |
281 | 281 | |
282 | 282 | try { |
283 | 283 | $code_unsafe = sys_get_param_str_unsafe('password_reset_code'); |
284 | - if(empty($code_unsafe)) { |
|
284 | + if (empty($code_unsafe)) { |
|
285 | 285 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_EMPTY, ERR_ERROR); |
286 | 286 | } |
287 | 287 | |
288 | 288 | sn_db_transaction_start(); |
289 | 289 | $confirmation = $this->confirmation->db_confirmation_get_by_type_and_code(CONFIRM_PASSWORD_RESET, $code_unsafe); // OK 4.5 |
290 | 290 | |
291 | - if(empty($confirmation)) { |
|
291 | + if (empty($confirmation)) { |
|
292 | 292 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_WRONG, ERR_ERROR); |
293 | 293 | } |
294 | 294 | |
295 | - if(SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) { |
|
295 | + if (SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) { |
|
296 | 296 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_TOO_OLD, ERR_ERROR); |
297 | 297 | } |
298 | 298 | |
299 | 299 | unset($this->account); |
300 | 300 | $this->account = new Account($this->db); |
301 | 301 | |
302 | - if(!$this->account->db_get_by_email($confirmation['email'])) { |
|
302 | + if (!$this->account->db_get_by_email($confirmation['email'])) { |
|
303 | 303 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_OK_BUT_NO_ACCOUNT_FOR_EMAIL, ERR_ERROR); |
304 | 304 | } |
305 | 305 | |
306 | 306 | $new_password_unsafe = $this->make_random_password(); |
307 | 307 | $salt_unsafe = $this->password_salt_generate(); |
308 | - if(!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) { |
|
308 | + if (!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) { |
|
309 | 309 | // Ошибка смены пароля |
310 | 310 | throw new Exception(AUTH_ERROR_INTERNAL_PASSWORD_CHANGE_ON_RESTORE, ERR_ERROR); |
311 | 311 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | $this->cookie_set(); |
316 | 316 | $this->login_cookie(); |
317 | 317 | |
318 | - if($this->account_login_status == LOGIN_SUCCESS) { |
|
318 | + if ($this->account_login_status == LOGIN_SUCCESS) { |
|
319 | 319 | // TODO - НЕ ОБЯЗАТЕЛЬНО ОТПРАВЛЯТЬ ЧЕРЕЗ ЕМЕЙЛ! ЕСЛИ ЭТО ФЕЙСБУЧЕК ИЛИ ВКШЕЧКА - МОЖНО ЧЕРЕЗ ЛС ПИСАТЬ!! |
320 | 320 | $message_header = sprintf($lang['log_lost_email_title'], $config->game_name); |
321 | 321 | $message = sprintf($lang['log_lost_email_pass'], $config->game_name, $this->account->account_name, $new_password_unsafe); |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | |
324 | 324 | // $users_translated = classSupernova::$auth->db_translate_get_users_from_account_list($this->provider_id, $this->account->account_id); // OK 4.5 |
325 | 325 | $users_translated = PlayerToAccountTranslate::db_translate_get_users_from_account_list($this->provider_id, $this->account->account_id); // OK 4.5 |
326 | - if(!empty($users_translated)) { |
|
326 | + if (!empty($users_translated)) { |
|
327 | 327 | // Отправляем в лички письмо о сбросе пароля |
328 | 328 | |
329 | 329 | // ПО ОПРЕДЕЛЕНИЮ в $users_translated только |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | $message = HelperString::nl2br($message) . '<br><br>'; |
336 | 336 | // msg_send_simple_message($found_provider->data[F_USER_ID], 0, SN_TIME_NOW, MSG_TYPE_ADMIN, $lang['sys_administration'], $lang['sys_login_register_message_title'], $message); |
337 | 337 | |
338 | - foreach($users_translated as $user_id => $providers_list) { |
|
338 | + foreach ($users_translated as $user_id => $providers_list) { |
|
339 | 339 | msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN, $lang['sys_administration'], $lang['sys_login_register_message_title'], $message); |
340 | 340 | } |
341 | 341 | } else { |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | $this->flog('Регистрация: начинаем. Провайдер ' . $this->provider_id); |
389 | 389 | |
390 | 390 | try { |
391 | - if(!$this->is_register) { |
|
391 | + if (!$this->is_register) { |
|
392 | 392 | $this->flog('Регистрация: не выставлен флаг регистрации - пропускаем'); |
393 | 393 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
394 | 394 | } |
@@ -400,8 +400,8 @@ discard block |
||
400 | 400 | // $this->account_check_duplicate_name_or_email($this->input_login_unsafe, $this->input_email_unsafe); |
401 | 401 | |
402 | 402 | $this->account->db_get_by_name_or_email($this->input_login_unsafe, $this->input_email_unsafe); |
403 | - if($this->account->is_exists) { |
|
404 | - if($this->account->account_email == $this->input_email_unsafe) { |
|
403 | + if ($this->account->is_exists) { |
|
404 | + if ($this->account->account_email == $this->input_email_unsafe) { |
|
405 | 405 | throw new Exception(REGISTER_ERROR_EMAIL_EXISTS, ERR_ERROR); |
406 | 406 | } else { |
407 | 407 | throw new Exception(REGISTER_ERROR_ACCOUNT_NAME_EXISTS, ERR_ERROR); |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | // А вот это пока не нужно. Трансляцией аккаунтов в юзеров и созданием новых юзеров для новозашедших аккаунтов занимается Auth |
441 | 441 | // $this->register_account(); |
442 | 442 | sn_db_transaction_commit(); |
443 | - } catch(Exception $e) { |
|
443 | + } catch (Exception $e) { |
|
444 | 444 | sn_db_transaction_rollback(); |
445 | 445 | $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false; |
446 | 446 | } |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | * @return int Результат попытки |
456 | 456 | */ |
457 | 457 | protected function login_cookie() { |
458 | - if($this->account_login_status != LOGIN_UNDEFINED) { |
|
458 | + if ($this->account_login_status != LOGIN_UNDEFINED) { |
|
459 | 459 | return $this->account_login_status; |
460 | 460 | } |
461 | 461 | |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | // $this->cookie_clear(); |
482 | 482 | // } |
483 | 483 | |
484 | - if($this->account->cookieLogin($rememberMe)) { |
|
484 | + if ($this->account->cookieLogin($rememberMe)) { |
|
485 | 485 | $this->account_login_status = LOGIN_SUCCESS; |
486 | 486 | $this->remember_me = intval($rememberMe); |
487 | 487 | } |
@@ -498,13 +498,13 @@ discard block |
||
498 | 498 | protected function login_username() { |
499 | 499 | // TODO - Логин по старым именам |
500 | 500 | try { |
501 | - if(!$this->is_login) { |
|
501 | + if (!$this->is_login) { |
|
502 | 502 | $this->flog('Логин: не выставлен флаг входа в игру - это не логин'); |
503 | 503 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
504 | 504 | } |
505 | 505 | |
506 | 506 | // TODO Пустое имя аккаунта |
507 | - if(!$this->input_login_unsafe) { |
|
507 | + if (!$this->input_login_unsafe) { |
|
508 | 508 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
509 | 509 | } |
510 | 510 | |
@@ -514,11 +514,11 @@ discard block |
||
514 | 514 | // if(empty($account)) { |
515 | 515 | // throw new Exception(LOGIN_ERROR_USERNAME, ERR_ERROR); |
516 | 516 | // } |
517 | - if(!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) { |
|
517 | + if (!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) { |
|
518 | 518 | throw new Exception(LOGIN_ERROR_USERNAME, ERR_ERROR); |
519 | 519 | } |
520 | 520 | |
521 | - if(!$this->account->password_check($this->input_login_password_raw)) { |
|
521 | + if (!$this->account->password_check($this->input_login_password_raw)) { |
|
522 | 522 | throw new Exception(LOGIN_ERROR_PASSWORD, ERR_ERROR); |
523 | 523 | } |
524 | 524 | |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | |
527 | 527 | $this->cookie_set(); |
528 | 528 | $this->account_login_status = LOGIN_SUCCESS; |
529 | - } catch(Exception $e) { |
|
529 | + } catch (Exception $e) { |
|
530 | 530 | $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false; |
531 | 531 | } |
532 | 532 | |
@@ -547,11 +547,11 @@ discard block |
||
547 | 547 | protected function cookie_set($account_to_impersonate = null) { |
548 | 548 | $this_account = is_object($account_to_impersonate) ? $account_to_impersonate : $this->account; |
549 | 549 | |
550 | - if(!is_object($this_account) || !$this_account->is_exists) { |
|
550 | + if (!is_object($this_account) || !$this_account->is_exists) { |
|
551 | 551 | throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR); |
552 | 552 | } |
553 | 553 | |
554 | - if(is_object($account_to_impersonate) && $account_to_impersonate->is_exists) { |
|
554 | + if (is_object($account_to_impersonate) && $account_to_impersonate->is_exists) { |
|
555 | 555 | sn_setcookie($this->cookie_name_impersonate, $_COOKIE[$this->cookie_name], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $this->domain); |
556 | 556 | } |
557 | 557 | |
@@ -588,10 +588,10 @@ discard block |
||
588 | 588 | protected function login_validate_input() { |
589 | 589 | // Проверяем, что бы в начале и конце не было пустых символов |
590 | 590 | // TODO - при копировании Эксель -> Опера - в конце образуются пустые места. Это не должно быть проблемой! Вынести проверку пароля в регистрацию! |
591 | - if($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
591 | + if ($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
592 | 592 | throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR); |
593 | 593 | } |
594 | - if(!$this->input_login_password_raw) { |
|
594 | + if (!$this->input_login_password_raw) { |
|
595 | 595 | throw new Exception(LOGIN_ERROR_PASSWORD_EMPTY, ERR_ERROR); |
596 | 596 | } |
597 | 597 | } |
@@ -606,37 +606,37 @@ discard block |
||
606 | 606 | $this->login_validate_input(); |
607 | 607 | |
608 | 608 | // Если нет имени пользователя - NO GO! |
609 | - if(!$this->input_login_unsafe) { |
|
609 | + if (!$this->input_login_unsafe) { |
|
610 | 610 | throw new Exception(LOGIN_ERROR_USERNAME_EMPTY, ERR_ERROR); |
611 | 611 | } |
612 | 612 | // Если логин имеет запрещенные символы - NO GO! |
613 | - if(strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
613 | + if (strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
614 | 614 | throw new Exception(LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS, ERR_ERROR); |
615 | 615 | } |
616 | 616 | // Если логин меньше минимальной длины - NO GO! |
617 | - if(strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) { |
|
617 | + if (strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) { |
|
618 | 618 | throw new Exception(REGISTER_ERROR_USERNAME_SHORT, ERR_ERROR); |
619 | 619 | } |
620 | 620 | // Если пароль меньше минимальной длины - NO GO! |
621 | - if(strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) { |
|
621 | + if (strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) { |
|
622 | 622 | throw new Exception(REGISTER_ERROR_PASSWORD_INSECURE, ERR_ERROR); |
623 | 623 | } |
624 | 624 | // Если пароль имеет пробельные символы в начале или конце - NO GO! |
625 | - if($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
625 | + if ($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
626 | 626 | throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR); |
627 | 627 | } |
628 | 628 | // Если пароль не совпадает с подтверждением - NO GO! То, что у пароля нет пробельных символов в начале/конце - мы уже проверили выше |
629 | 629 | //Если они есть у повтора - значит пароль и повтор не совпадут |
630 | - if($this->input_login_password_raw <> $this->input_login_password_raw_repeat) { |
|
630 | + if ($this->input_login_password_raw <> $this->input_login_password_raw_repeat) { |
|
631 | 631 | throw new Exception(REGISTER_ERROR_PASSWORD_DIFFERENT, ERR_ERROR); |
632 | 632 | } |
633 | 633 | // Если нет емейла - NO GO! |
634 | 634 | // TODO - регистрация без емейла |
635 | - if(!$this->input_email_unsafe) { |
|
635 | + if (!$this->input_email_unsafe) { |
|
636 | 636 | throw new Exception(REGISTER_ERROR_EMAIL_EMPTY, ERR_ERROR); |
637 | 637 | } |
638 | 638 | // Если емейл не является емейлом - NO GO! |
639 | - if(!is_email($this->input_email_unsafe)) { |
|
639 | + if (!is_email($this->input_email_unsafe)) { |
|
640 | 640 | throw new Exception(REGISTER_ERROR_EMAIL_WRONG, ERR_ERROR); |
641 | 641 | } |
642 | 642 | } |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | return core_auth::make_random_password(); |
668 | 668 | } |
669 | 669 | protected function flog($message, $die = false) { |
670 | - if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
670 | + if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
671 | 671 | return; |
672 | 672 | } |
673 | 673 | list($called, $caller) = debug_backtrace(false); |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
682 | 682 | |
683 | 683 | classSupernova::log_file("$message - $caller_name"); |
684 | - if($die) { |
|
684 | + if ($die) { |
|
685 | 685 | $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
686 | 686 | } |
687 | 687 | } |