mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-27 01:39:22 +02:00
* fiedx bug on othire with config.account_premium_days
* fixed getPremDays and isPremium functions (newest 11.x engines are bugged when it comes to PACC, its not fault of MyAAC)
This commit is contained in:
parent
efb1775aff
commit
3e49ef42a2
@ -170,7 +170,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
|||||||
public function load($id)
|
public function load($id)
|
||||||
{
|
{
|
||||||
// SELECT query on database
|
// SELECT query on database
|
||||||
$this->data = $this->db->query('SELECT `id`, ' . (fieldExist('name', 'accounts') ? '`name`,' : '') . '`password`, `email`, ' . $this->db->fieldName('blocked') . ', ' . $this->db->fieldName('rlname') . ', ' . $this->db->fieldName('location') . ', ' . $this->db->fieldName('web_flags') . ', ' . (fieldExist('premdays', 'accounts') ? $this->db->fieldName('premdays') . ',' : '') . (fieldExist('lastday', 'accounts') ? $this->db->fieldName('lastday') . ',' : (fieldExist('premend', 'accounts') ? $this->db->fieldName('premend') . ' as `lastday`,' : '')) . $this->db->fieldName('created') . ' FROM ' . $this->db->tableName('accounts') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . (int) $id)->fetch();
|
$this->data = $this->db->query('SELECT `id`, ' . (fieldExist('name', 'accounts') ? '`name`,' : '') . '`password`, `email`, ' . $this->db->fieldName('blocked') . ', ' . $this->db->fieldName('rlname') . ', ' . $this->db->fieldName('location') . ', ' . $this->db->fieldName('web_flags') . ', ' . (fieldExist('premdays', 'accounts') ? $this->db->fieldName('premdays') . ',' : '') . (fieldExist('lastday', 'accounts') ? $this->db->fieldName('lastday') . ',' : (fieldExist('premend', 'accounts') ? $this->db->fieldName('premend') . ',' : '')) . $this->db->fieldName('created') . ' FROM ' . $this->db->tableName('accounts') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . (int) $id)->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -253,8 +253,13 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
|||||||
if(fieldExist('premend', 'accounts'))
|
if(fieldExist('premend', 'accounts'))
|
||||||
$lastday = 'premend';
|
$lastday = 'premend';
|
||||||
|
|
||||||
|
$field = 'lastday';
|
||||||
|
if(isset($this->data['premend'])) { // othire
|
||||||
|
$field = 'premend';
|
||||||
|
}
|
||||||
|
|
||||||
// UPDATE query on database
|
// UPDATE query on database
|
||||||
$this->db->query('UPDATE `accounts` SET ' . (fieldExist('name', 'accounts') ? '`name` = ' . $this->db->quote($this->data['name']) . ',' : '') . '`password` = ' . $this->db->quote($this->data['password']) . ', `email` = ' . $this->db->quote($this->data['email']) . ', `blocked` = ' . (int) $this->data['blocked'] . ', `rlname` = ' . $this->db->quote($this->data['rlname']) . ', `location` = ' . $this->db->quote($this->data['location']) . ', `web_flags` = ' . (int) $this->data['web_flags'] . ', ' . (fieldExist('premdays', 'accounts') ? '`premdays` = ' . (int) $this->data['premdays'] . ',' : '') . '`' . $lastday . '` = ' . (int) $this->data['lastday'] . ' WHERE `id` = ' . $this->data['id']);
|
$this->db->query('UPDATE `accounts` SET ' . (fieldExist('name', 'accounts') ? '`name` = ' . $this->db->quote($this->data['name']) . ',' : '') . '`password` = ' . $this->db->quote($this->data['password']) . ', `email` = ' . $this->db->quote($this->data['email']) . ', `blocked` = ' . (int) $this->data['blocked'] . ', `rlname` = ' . $this->db->quote($this->data['rlname']) . ', `location` = ' . $this->db->quote($this->data['location']) . ', `web_flags` = ' . (int) $this->data['web_flags'] . ', ' . (fieldExist('premdays', 'accounts') ? '`premdays` = ' . (int) $this->data['premdays'] . ',' : '') . '`' . $field . '` = ' . (int) $this->data[$field] . ' WHERE `id` = ' . $this->data['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -329,19 +334,15 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
|||||||
|
|
||||||
public function getPremDays()
|
public function getPremDays()
|
||||||
{
|
{
|
||||||
if( !isset($this->data['lastday']) )
|
if(!isset($this->data['lastday']) && !isset($this->data['premend'])) {
|
||||||
{
|
|
||||||
throw new E_OTS_NotLoaded();
|
throw new E_OTS_NotLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fieldExist('premdays', 'accounts'))
|
if(isset($this->data['premend'])) {
|
||||||
return $this->data['premdays'];
|
return round(($this->data['premend'] - time()) / (24 * 60 * 60), 2);
|
||||||
|
}
|
||||||
|
|
||||||
if($this->data['lastday'] == 0)
|
return $this->data['premdays'] - (date("z", time()) + (365 * (date("Y", time()) - date("Y", $this->data['lastday']))) - date("z", $this->data['lastday']));
|
||||||
return 0;
|
|
||||||
|
|
||||||
return round(($this->data['lastday'] - time()) / (24 * 60 * 60), 3);
|
|
||||||
//return $this->data['premdays'] - (date("z", time()) + (365 * (date("Y", time()) - date("Y", $this->data['lastday']))) - date("z", $this->data['lastday']));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLastLogin()
|
public function getLastLogin()
|
||||||
@ -358,11 +359,12 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
|||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
if(isset($config['lua']['freePremium']) && getBoolean($config['lua']['freePremium'])) return true;
|
if(isset($config['lua']['freePremium']) && getBoolean($config['lua']['freePremium'])) return true;
|
||||||
if(fieldExist('premdays', 'accounts'))
|
|
||||||
return $this->data['premdays'] > 0;
|
|
||||||
|
|
||||||
return $this->data['lastday'] > time();
|
if(isset($this->data['premend'])) {
|
||||||
//return ($this->data['premdays'] - (date("z", time()) + (365 * (date("Y", time()) - date("Y", $this->data['lastday']))) - date("z", $this->data['lastday'])) > 0);
|
return $this->data['premend'] > time();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ($this->data['premdays'] - (date("z", time()) + (365 * (date("Y", time()) - date("Y", $this->data['lastday']))) - date("z", $this->data['lastday'])) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCreated()
|
public function getCreated()
|
||||||
|
@ -144,9 +144,14 @@ if($save)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($config['account_premium_days'] && $config['account_premium_days'] > 0) {
|
if($config['account_premium_days'] && $config['account_premium_days'] > 0) {
|
||||||
|
if(fieldExist('premend', 'accounts')) { // othire
|
||||||
|
$new_account->setCustomField('premend', time() + $config['account_premium_days'] * 86400);
|
||||||
|
}
|
||||||
|
else { // rest
|
||||||
$new_account->setCustomField('premdays', $config['account_premium_days']);
|
$new_account->setCustomField('premdays', $config['account_premium_days']);
|
||||||
$new_account->setCustomField('lastday', time());
|
$new_account->setCustomField('lastday', time());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($config['account_premium_points']) {
|
if($config['account_premium_points']) {
|
||||||
$new_account->setCustomField('premium_points', $config['account_premium_points']);
|
$new_account->setCustomField('premium_points', $config['account_premium_points']);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user