mirror of
https://github.com/slawkens/myaac.git
synced 2026-01-22 22:16:22 +01:00
Merge branch 'develop' into feature/2fa
This commit is contained in:
@@ -183,39 +183,7 @@ else if (isset($_REQUEST['search'])) {
|
||||
$account->setName($name);
|
||||
}
|
||||
|
||||
if ($hasTypeColumn) {
|
||||
$account->setCustomField('type', $group);
|
||||
} elseif ($hasGroupColumn) {
|
||||
$account->setCustomField('group_id', $group);
|
||||
}
|
||||
|
||||
if ($hasSecretColumn) {
|
||||
$account->setCustomField('secret', $secret);
|
||||
}
|
||||
|
||||
$account->setCustomField('key', $key);
|
||||
$account->setEMail($email);
|
||||
|
||||
if (HAS_ACCOUNT_COINS) {
|
||||
$account->setCustomField('coins', $t_coins);
|
||||
}
|
||||
|
||||
if (HAS_ACCOUNT_COINS_TRANSFERABLE || HAS_ACCOUNT_TRANSFERABLE_COINS) {
|
||||
$account->setCustomField(ACCOUNT_COINS_TRANSFERABLE_COLUMN, $t_coins_transferable);
|
||||
}
|
||||
|
||||
$lastDay = 0;
|
||||
if($p_days != 0 && $p_days != OTS_Account::GRATIS_PREMIUM_DAYS) {
|
||||
$lastDay = time();
|
||||
} else if ($lastDay != 0) {
|
||||
$lastDay = 0;
|
||||
}
|
||||
|
||||
$account->setPremDays($p_days);
|
||||
$account->setLastLogin($lastDay);
|
||||
if ($hasPointsColumn) {
|
||||
$account->setCustomField('premium_points', $p_points);
|
||||
}
|
||||
$account->setRLName($rl_name);
|
||||
$account->setLocation($rl_loca);
|
||||
|
||||
@@ -223,9 +191,18 @@ else if (isset($_REQUEST['search'])) {
|
||||
$account->setCountry($rl_country);
|
||||
}
|
||||
|
||||
$account->setCustomField('created', $created);
|
||||
$account->setWebFlags($web_flags);
|
||||
$account->setCustomField('web_lastlogin', $web_lastlogin);
|
||||
|
||||
if (!isCanary()) {
|
||||
$lastDay = 0;
|
||||
if($p_days != 0 && $p_days != OTS_Account::GRATIS_PREMIUM_DAYS) {
|
||||
$lastDay = time();
|
||||
}
|
||||
|
||||
$account->setLastLogin($lastDay);
|
||||
}
|
||||
|
||||
$account->setPremDays($p_days);
|
||||
|
||||
if (isset($password)) {
|
||||
if (USE_ACCOUNT_SALT) {
|
||||
@@ -239,6 +216,34 @@ else if (isset($_REQUEST['search'])) {
|
||||
}
|
||||
|
||||
$account->save();
|
||||
|
||||
if ($hasTypeColumn) {
|
||||
$account->setCustomField('type', $group);
|
||||
} elseif ($hasGroupColumn) {
|
||||
$account->setCustomField('group_id', $group);
|
||||
}
|
||||
|
||||
if ($hasSecretColumn) {
|
||||
$account->setCustomField('secret', $secret);
|
||||
}
|
||||
|
||||
$account->setCustomField('key', $key);
|
||||
|
||||
if (HAS_ACCOUNT_COINS) {
|
||||
$account->setCustomField('coins', $t_coins);
|
||||
}
|
||||
|
||||
if (HAS_ACCOUNT_COINS_TRANSFERABLE || HAS_ACCOUNT_TRANSFERABLE_COINS) {
|
||||
$account->setCustomField(ACCOUNT_COINS_TRANSFERABLE_COLUMN, $t_coins_transferable);
|
||||
}
|
||||
|
||||
if ($hasPointsColumn) {
|
||||
$account->setCustomField('premium_points', $p_points);
|
||||
}
|
||||
|
||||
$account->setCustomField('created', $created);
|
||||
$account->setCustomField('web_lastlogin', $web_lastlogin);
|
||||
|
||||
echo_success('Account saved at: ' . date('G:i'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1812,8 +1812,8 @@ function getAccountIdentityColumn(): string
|
||||
|
||||
function isCanary(): bool
|
||||
{
|
||||
$vipSystemEnabled = configLua('vipSystemEnabled');
|
||||
return isset($vipSystemEnabled);
|
||||
$dataPackDirectory = configLua('dataPackDirectory');
|
||||
return isset($dataPackDirectory);
|
||||
}
|
||||
|
||||
function getStatusUptimeReadable(int $uptime): string
|
||||
|
||||
@@ -43,7 +43,11 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
*/
|
||||
private $data = array('email' => '', 'rlname' => '','location' => '', 'country' => '','web_flags' => 0, 'lastday' => 0, 'premdays' => 0, 'created' => 0);
|
||||
|
||||
public static $cache = array();
|
||||
private array $columns = ['password', 'email', 'rlname', 'location', 'country', 'web_flags', 'created'];
|
||||
|
||||
private array $optionalColumns = ['name', 'number', 'lastday', 'premdays', 'premium_ends_at', 'premend'];
|
||||
|
||||
public static array $cache = [];
|
||||
|
||||
const GRATIS_PREMIUM_DAYS = 65535;
|
||||
/**
|
||||
@@ -328,27 +332,50 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
if( !isset($this->data['id']) )
|
||||
{
|
||||
if (!isset($this->data['id'])) {
|
||||
throw new E_OTS_NotLoaded();
|
||||
}
|
||||
|
||||
$field = 'lastday';
|
||||
if($this->db->hasColumn('accounts', 'premend')) { // othire
|
||||
$field = 'premend';
|
||||
if(!isset($this->data['premend'])) {
|
||||
$this->data['premend'] = 0;
|
||||
}
|
||||
}
|
||||
else if($this->db->hasColumn('accounts', 'premium_ends_at')) {
|
||||
$field = 'premium_ends_at';
|
||||
if(!isset($this->data['premium_ends_at'])) {
|
||||
$this->data['premium_ends_at'] = 0;
|
||||
}
|
||||
}
|
||||
$defaultValues = [
|
||||
'premium_ends_at' => 0,
|
||||
'lastday' => 0,
|
||||
'premend' => 0,
|
||||
'premdays' => 0,
|
||||
];
|
||||
|
||||
// UPDATE query on database
|
||||
$this->db->exec('UPDATE `accounts` SET ' . ($this->db->hasColumn('accounts', 'name') ? '`name` = ' . $this->db->quote($this->data['name']) . ',' : '') . '`password` = ' . $this->db->quote($this->data['password']) . ', `email` = ' . $this->db->quote($this->data['email']) . ', `rlname` = ' . $this->db->quote($this->data['rlname']) . ', `location` = ' . $this->db->quote($this->data['location']) . ', `country` = ' . $this->db->quote($this->data['country']) . ', `web_flags` = ' . (int) $this->data['web_flags'] . ', ' . ($this->db->hasColumn('accounts', 'premdays') ? '`premdays` = ' . (int) $this->data['premdays'] . ',' : '') . '`' . $field . '` = ' . (int) $this->data[$field] . ' WHERE `id` = ' . $this->data['id']);
|
||||
foreach ($defaultValues as $key => $value) {
|
||||
if (!isset($this->data[$key])) {
|
||||
$this->data[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$columns = $this->columns;
|
||||
foreach ($this->optionalColumns as $column) {
|
||||
if ($this->db->hasColumn('accounts', $column)) {
|
||||
$columns[] = $column;
|
||||
}
|
||||
}
|
||||
|
||||
$values = [];
|
||||
foreach ($columns as $column) {
|
||||
$value = $this->data[$column];
|
||||
|
||||
$values[$column] = $value;
|
||||
}
|
||||
|
||||
// updates existing player
|
||||
if( isset($this->data['id']) ) {
|
||||
AccountModel::where('id', $this->data['id'])->update($values);
|
||||
}
|
||||
// creates new player
|
||||
else {
|
||||
$values['created'] = time();
|
||||
|
||||
$account = AccountModel::create($values);
|
||||
|
||||
// ID of new player
|
||||
$this->data['id'] = $account->id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -507,11 +534,17 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
* @since 0.7.5
|
||||
* @throws E_OTS_NotLoaded If account is not loaded.
|
||||
*/
|
||||
public function setPremDays($premdays)
|
||||
public function setPremDays($premdays): void
|
||||
{
|
||||
$this->data['premdays'] = (int) $premdays;
|
||||
$this->data['premend'] = time() + ($premdays * 24 * 60 * 60);
|
||||
$this->data['premium_ends_at'] = time() + ($premdays * 24 * 60 * 60);
|
||||
|
||||
$premiumTimeInSeconds = time() + ($premdays * 24 * 60 * 60);
|
||||
$this->data['premend'] = $premiumTimeInSeconds;
|
||||
$this->data['premium_ends_at'] = $premiumTimeInSeconds;
|
||||
|
||||
if (isCanary()) {
|
||||
$this->data['lastday'] = $premiumTimeInSeconds;
|
||||
}
|
||||
}
|
||||
|
||||
public function setRLName($name)
|
||||
|
||||
@@ -192,6 +192,21 @@ if($save)
|
||||
|
||||
$new_account->setPassword(encrypt($password));
|
||||
$new_account->setEMail($email);
|
||||
|
||||
$settingAccountPremiumDays = setting('core.account_premium_days');
|
||||
if($settingAccountPremiumDays && $settingAccountPremiumDays > 0) {
|
||||
$new_account->setPremDays($settingAccountPremiumDays);
|
||||
|
||||
if (!isCanary()) {
|
||||
$lastDay = 0;
|
||||
if($settingAccountPremiumDays != 0 && $settingAccountPremiumDays != OTS_Account::GRATIS_PREMIUM_DAYS) {
|
||||
$lastDay = time();
|
||||
}
|
||||
|
||||
$new_account->setLastLogin($lastDay);
|
||||
}
|
||||
}
|
||||
|
||||
$new_account->save();
|
||||
|
||||
$hooks->trigger(HOOK_ACCOUNT_CREATE_AFTER_SAVED, ['account' => $new_account]);
|
||||
@@ -206,22 +221,6 @@ if($save)
|
||||
$new_account->setCustomField('country', $country);
|
||||
}
|
||||
|
||||
$settingAccountPremiumDays = setting('core.account_premium_days');
|
||||
if($settingAccountPremiumDays && $settingAccountPremiumDays > 0) {
|
||||
if($db->hasColumn('accounts', 'premend')) { // othire
|
||||
$new_account->setCustomField('premend', time() + $settingAccountPremiumDays * 86400);
|
||||
}
|
||||
else { // rest
|
||||
if ($db->hasColumn('accounts', 'premium_ends_at')) { // TFS 1.4+
|
||||
$new_account->setCustomField('premium_ends_at', time() + $settingAccountPremiumDays * (60 * 60 * 24));
|
||||
}
|
||||
else {
|
||||
$new_account->setCustomField('premdays', $settingAccountPremiumDays);
|
||||
$new_account->setCustomField('lastday', time());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$accountDefaultPremiumPoints = setting('core.account_premium_points');
|
||||
if($accountDefaultPremiumPoints > 0) {
|
||||
$new_account->setCustomField('premium_points', $accountDefaultPremiumPoints);
|
||||
|
||||
Reference in New Issue
Block a user