|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Created by Gorlum 17.04.2015 6:37 |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
use Vector\Vector; |
|
8
|
|
|
|
|
9
|
|
|
function sys_user_vacation($user) { |
|
10
|
|
|
if(sys_get_param_str('vacation') == 'leave') { |
|
11
|
|
|
if ($user['vacation'] < SN_TIME_NOW) { |
|
12
|
|
|
$user['vacation'] = 0; |
|
13
|
|
|
$user['vacation_next'] = SN_TIME_NOW + classSupernova::$config->player_vacation_timeout; |
|
14
|
|
|
DBStaticUser::db_user_set_by_id_DEPRECATED($user['id'], "`vacation` = {$user['vacation']}, `vacation_next` = {$user['vacation_next']}"); |
|
|
|
|
|
|
15
|
|
|
} |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
if($user['vacation']) { |
|
19
|
|
|
// sn_sys_logout(false, true); |
|
|
|
|
|
|
20
|
|
|
// core_auth::logout(false, true); |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
$template = gettemplate('vacation', true); |
|
23
|
|
|
|
|
24
|
|
|
$template->assign_vars(array( |
|
25
|
|
|
'NAME' => $user['username'], |
|
26
|
|
|
'VACATION_END' => date(FMT_DATE_TIME, $user['vacation']), |
|
27
|
|
|
'CAN_LEAVE' => $user['vacation'] <= SN_TIME_NOW, |
|
28
|
|
|
'RANDOM' => mt_rand(1, 2), |
|
29
|
|
|
)); |
|
30
|
|
|
|
|
31
|
|
|
display(parsetemplate($template), '', false, '', false, false); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
return false; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
function sys_is_multiaccount($user1, $user2) { |
|
38
|
|
|
return $user1['id'] != $user2['id'] && $user1['user_lastip'] == $user2['user_lastip'] && !classSupernova::$config->game_multiaccount_enabled; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param $UserID |
|
43
|
|
|
*/ |
|
44
|
|
|
function DeleteSelectedUser($UserID) { |
|
45
|
|
|
// TODO: Full rewrite |
|
46
|
|
|
sn_db_transaction_start(); |
|
47
|
|
|
$TheUser = DBStaticUser::db_user_by_id($UserID); |
|
48
|
|
|
if ( $TheUser['ally_id'] != 0 ) { |
|
49
|
|
|
$TheAlly = classSupernova::$db->doSelectFetch("SELECT * FROM `{{alliance}}` WHERE `id` = '" . $TheUser['ally_id'] . "';"); |
|
50
|
|
|
$TheAlly['ally_members'] -= 1; |
|
51
|
|
|
if ( $TheAlly['ally_members'] > 0 ) { |
|
52
|
|
|
classSupernova::$db->doUpdateRowSet( |
|
53
|
|
|
TABLE_ALLIANCE, |
|
54
|
|
|
array( |
|
55
|
|
|
'ally_members' => $TheAlly['ally_members'], |
|
56
|
|
|
), |
|
57
|
|
|
array( |
|
58
|
|
|
'id' => $TheAlly['id'], |
|
59
|
|
|
) |
|
60
|
|
|
); |
|
61
|
|
|
} else { |
|
62
|
|
|
classSupernova::$gc->db->doDeleteRowWhere(TABLE_ALLIANCE, array('id' => $TheAlly['id'],)); |
|
|
|
|
|
|
63
|
|
|
classSupernova::$gc->db->doDeleteWhere(TABLE_STAT_POINTS, array('stat_type' => STAT_TYPE_ALLY, 'id_owner' => $TheAlly['id'],)); |
|
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
classSupernova::$gc->db->doDeleteWhere(TABLE_STAT_POINTS, array('stat_type' => STAT_TYPE_USER, 'id_owner' => $UserID,)); |
|
67
|
|
|
|
|
68
|
|
|
DBStaticPlanet::db_planet_list_delete_by_owner($UserID); |
|
69
|
|
|
|
|
70
|
|
|
classSupernova::$gc->db->doDeleteWhere(TABLE_MESSAGES, array('message_owner' => $UserID,)); |
|
71
|
|
|
classSupernova::$gc->db->doDeleteWhere(TABLE_MESSAGES, array('message_sender' => $UserID,)); |
|
72
|
|
|
classSupernova::$gc->db->doDeleteWhere(TABLE_NOTES, array('owner' => $UserID ,)); |
|
73
|
|
|
FleetList::db_fleet_list_delete_by_owner($UserID); |
|
74
|
|
|
classSupernova::$gc->db->doDeleteWhere(TABLE_BUDDY, array('BUDDY_SENDER_ID' => $UserID ,)); |
|
75
|
|
|
classSupernova::$gc->db->doDeleteWhere(TABLE_BUDDY, array('BUDDY_OWNER_ID' => $UserID ,)); |
|
76
|
|
|
|
|
77
|
|
|
|
|
78
|
|
|
classSupernova::$gc->cacheOperator->db_del_record_by_id(LOC_USER, $UserID); |
|
|
|
|
|
|
79
|
|
|
classSupernova::$db->doDeleteWhere(TABLE_REFERRALS, array('id' => $UserID)); |
|
80
|
|
|
classSupernova::$db->doDeleteWhere(TABLE_REFERRALS, array('id_partner' => $UserID)); |
|
81
|
|
|
classSupernova::$config->db_saveItem('users_amount', classSupernova::$config->db_loadItem('users_amount') - 1); |
|
82
|
|
|
sn_db_transaction_commit(); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @param $banner |
|
87
|
|
|
* @param $banned |
|
88
|
|
|
* @param $term |
|
89
|
|
|
* @param bool $is_vacation |
|
90
|
|
|
* @param string $reason_unsafe |
|
91
|
|
|
*/ |
|
92
|
|
|
function sys_admin_player_ban($banner, $banned, $term, $is_vacation = true, $reason_unsafe = '') { |
|
93
|
|
|
$ban_current = DBStaticUser::db_user_by_id($banned['id'], false, 'banaday'); |
|
94
|
|
|
$ban_until = ($ban_current['banaday'] ? $ban_current['banaday'] : SN_TIME_NOW) + $term; |
|
95
|
|
|
|
|
96
|
|
|
DBStaticUser::db_user_set_by_id_DEPRECATED($banned['id'], "`banaday` = {$ban_until} " . ($is_vacation ? ", `vacation` = '{$ban_until}' " : '')); |
|
|
|
|
|
|
97
|
|
|
|
|
98
|
|
|
classSupernova::$db->doInsertSet(TABLE_BANNED, array( |
|
99
|
|
|
'ban_user_id' => $banned['id'], |
|
100
|
|
|
'ban_user_name' => $banned['username'], |
|
101
|
|
|
'ban_reason' => $reason_unsafe, |
|
102
|
|
|
'ban_time' => SN_TIME_NOW, |
|
103
|
|
|
'ban_until' => $ban_until, |
|
104
|
|
|
'ban_issuer_id' => $banner['id'], |
|
105
|
|
|
'ban_issuer_name' => $banner['username'], |
|
106
|
|
|
'ban_issuer_email' => $banner['email'], |
|
107
|
|
|
)); |
|
108
|
|
|
|
|
109
|
|
|
DBStaticPlanet::db_planet_set_by_owner( |
|
110
|
|
|
$banned['id'], |
|
111
|
|
|
array( |
|
112
|
|
|
'metal_mine_porcent' => 0, |
|
113
|
|
|
'crystal_mine_porcent' => 0, |
|
114
|
|
|
'deuterium_sintetizer_porcent' => 0, |
|
115
|
|
|
'solar_plant_porcent' => 0, |
|
116
|
|
|
'fusion_plant_porcent' => 0, |
|
117
|
|
|
'solar_satelit_porcent' => 0, |
|
118
|
|
|
'ship_sattelite_sloth_porcent' => 0, |
|
119
|
|
|
) |
|
120
|
|
|
); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* @param $banner |
|
125
|
|
|
* @param $banned |
|
126
|
|
|
* @param string $reasonUnsafe |
|
127
|
|
|
*/ |
|
128
|
|
|
function sys_admin_player_ban_unset($banner, $banned, $reasonUnsafe = '') { |
|
129
|
|
|
DBStaticUser::db_user_set_by_id_DEPRECATED($banned['id'], "`banaday` = 0, `vacation` = " . SN_TIME_NOW . ""); |
|
|
|
|
|
|
130
|
|
|
|
|
131
|
|
|
return classSupernova::$db->doInsertSet(TABLE_BANNED, array( |
|
132
|
|
|
'ban_user_id' => $banned['id'], |
|
133
|
|
|
'ban_user_name' => $banned['username'], |
|
134
|
|
|
'ban_reason' => $reasonUnsafe, |
|
135
|
|
|
'ban_time' => 0, |
|
136
|
|
|
'ban_until' => SN_TIME_NOW, |
|
137
|
|
|
'ban_issuer_id' => $banner['id'], |
|
138
|
|
|
'ban_issuer_name' => $banner['username'], |
|
139
|
|
|
'ban_issuer_email' => $banner['email'], |
|
140
|
|
|
)); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
function player_create($username_unsafe, $email_unsafe, $options) { |
|
144
|
|
|
sn_db_transaction_check(true); |
|
145
|
|
|
|
|
146
|
|
|
static $player_options_string = 'opt_mnl_spy^1|opt_email_mnl_spy^0|opt_email_mnl_joueur^0|opt_email_mnl_alliance^0|opt_mnl_attaque^1|opt_email_mnl_attaque^0|opt_mnl_exploit^1|opt_email_mnl_exploit^0|opt_mnl_transport^1|opt_email_mnl_transport^0|opt_email_msg_admin^1|opt_mnl_expedition^1|opt_email_mnl_expedition^0|opt_mnl_buildlist^1|opt_email_mnl_buildlist^0|opt_int_navbar_resource_force^1|'; |
|
147
|
|
|
|
|
148
|
|
|
empty($options['planet_options']) ? $options['planet_options'] = array() : false; |
|
149
|
|
|
|
|
150
|
|
|
$field_set = array( |
|
151
|
|
|
'server_name' => SN_ROOT_VIRTUAL, |
|
152
|
|
|
'register_time' => SN_TIME_NOW, |
|
153
|
|
|
'user_bot' => $options['user_bot'] = empty($options['user_bot']) ? USER_BOT_PLAYER : $options['total_points'], |
|
154
|
|
|
|
|
155
|
|
|
'username' => $username_unsafe, |
|
156
|
|
|
'email' => $email_unsafe, |
|
157
|
|
|
'email_2' => $email_unsafe, |
|
158
|
|
|
|
|
159
|
|
|
'lang' => $options['language_iso'] ? $options['language_iso'] : DEFAULT_LANG, |
|
160
|
|
|
'dpath' => DEFAULT_SKINPATH, |
|
161
|
|
|
|
|
162
|
|
|
'total_points' => $options['total_points'] = empty($options['total_points']) ? 0 : $options['total_points'], |
|
163
|
|
|
|
|
164
|
|
|
'options' => (empty($options['options']) ? $player_options_string : $options['options']) . (empty($options['options_extra']) ? '' : $options['options_extra']), |
|
165
|
|
|
|
|
166
|
|
|
'galaxy' => $options['galaxy'] = intval($options['galaxy'] ? $options['galaxy'] : 0), |
|
167
|
|
|
'system' => $options['system'] = intval($options['system'] ? $options['system'] : 0), |
|
168
|
|
|
'planet' => $options['planet'] = intval($options['planet'] ? $options['planet'] : 0), |
|
169
|
|
|
); |
|
170
|
|
|
|
|
171
|
|
|
!empty($options['salt']) ? $field_set['salt'] = $options['salt'] : false; |
|
172
|
|
|
!empty($options['password_encoded_unsafe']) ? $field_set['password'] = $options['password_encoded_unsafe'] : false; |
|
173
|
|
|
|
|
174
|
|
|
$user_new = classSupernova::$gc->cacheOperator->db_ins_field_set(LOC_USER, $field_set); |
|
|
|
|
|
|
175
|
|
|
if(!($options['galaxy'] && $options['system'] && $options['planet'])) { |
|
176
|
|
|
$options['galaxy'] = classSupernova::$config->LastSettedGalaxyPos; |
|
177
|
|
|
$options['system'] = classSupernova::$config->LastSettedSystemPos; |
|
178
|
|
|
$segment_size = floor(Vector::$knownPlanets/ 3); |
|
179
|
|
|
$segment = floor(classSupernova::$config->LastSettedPlanetPos / $segment_size); |
|
180
|
|
|
$segment++; |
|
181
|
|
|
$options['planet'] = mt_rand(1 + $segment * $segment_size, ($segment + 1) * $segment_size); |
|
182
|
|
|
|
|
183
|
|
|
// $new_planet_id = 0; |
|
|
|
|
|
|
184
|
|
|
while(true) { |
|
185
|
|
|
if($options['planet'] > Vector::$knownPlanets) { |
|
186
|
|
|
$options['planet'] = mt_rand(0, $segment_size - 1) + 1; |
|
187
|
|
|
$options['system']++; |
|
188
|
|
|
} |
|
189
|
|
|
if($options['system'] > Vector::$knownSystems) { |
|
190
|
|
|
$options['system'] = 1; |
|
191
|
|
|
$options['galaxy']++; |
|
192
|
|
|
} |
|
193
|
|
|
$options['galaxy'] > Vector::$knownGalaxies? $options['galaxy'] = 1 : false; |
|
194
|
|
|
|
|
195
|
|
|
$galaxy_row = DBStaticPlanet::db_planet_by_gspt($options['galaxy'], $options['system'], $options['planet'], PT_PLANET, true, 'id'); |
|
196
|
|
|
if(!$galaxy_row['id']) { |
|
197
|
|
|
classSupernova::$config->db_saveItem(array( |
|
198
|
|
|
'LastSettedGalaxyPos' => $options['galaxy'], |
|
199
|
|
|
'LastSettedSystemPos' => $options['system'], |
|
200
|
|
|
'LastSettedPlanetPos' => $options['planet'], |
|
201
|
|
|
)); |
|
202
|
|
|
break; |
|
203
|
|
|
} |
|
204
|
|
|
$options['planet'] += 3; |
|
205
|
|
|
} |
|
206
|
|
|
} |
|
207
|
|
|
$new_planet_id = uni_create_planet($options['galaxy'], $options['system'], $options['planet'], $user_new['id'], classLocale::$lang['sys_capital'], true, $options['planet_options']); |
|
208
|
|
|
|
|
209
|
|
|
DBStaticUser::db_user_set_by_id_DEPRECATED($user_new['id'], |
|
|
|
|
|
|
210
|
|
|
"`id_planet` = '{$new_planet_id}', `current_planet` = '{$new_planet_id}', |
|
211
|
|
|
`galaxy` = '{$options['galaxy']}', `system` = '{$options['system']}', `planet` = '{$options['planet']}'" |
|
212
|
|
|
); |
|
213
|
|
|
|
|
214
|
|
|
classSupernova::$config->db_saveItem('users_amount', classSupernova::$config->users_amount + 1); |
|
215
|
|
|
|
|
216
|
|
|
db_player_name_history_replace($user_new['id'], $username_unsafe); |
|
217
|
|
|
|
|
218
|
|
|
if(!empty($options['partner_id']) && ($referral_row = DBStaticUser::db_user_by_id($options['partner_id'], true))) { |
|
219
|
|
|
db_referral_insert($options['partner_id'], $user_new['id']); |
|
220
|
|
|
} |
|
221
|
|
|
|
|
222
|
|
|
sys_player_new_adjust($user_new['id'], $new_planet_id); |
|
223
|
|
|
|
|
224
|
|
|
return $result = DBStaticUser::db_user_by_id($user_new['id']); |
|
|
|
|
|
|
225
|
|
|
} |
|
226
|
|
|
|
This method has been deprecated.