mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-28 22:55:35 +01:00
Fix the premium checks, introduced in v1.8.3
This commit is contained in:
@@ -445,16 +445,11 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
|||||||
|
|
||||||
if(isset($this->data['premium_ends_at']) || isset($this->data['premend']) ||
|
if(isset($this->data['premium_ends_at']) || isset($this->data['premend']) ||
|
||||||
(isCanary() && isset($this->data['lastday']))) {
|
(isCanary() && isset($this->data['lastday']))) {
|
||||||
$col = (isset($this->premium_ends_at) ? 'premium_ends_at' : (isset($this->data['lastday']) ? 'lastday' : 'premend'));
|
$col = (isset($this->data['premium_ends_at']) ? 'premium_ends_at' : (isset($this->data['lastday']) ? 'lastday' : 'premend'));
|
||||||
$ret = ceil(($this->data[$col] - time()) / (24 * 60 * 60));
|
$ret = ceil(($this->data[$col] - time()) / (24 * 60 * 60));
|
||||||
return max($ret, 0);
|
return max($ret, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCanary() && isset($this->data['lastday'])) {
|
|
||||||
$ret = ceil(($this->data['lastday'] - time()) / 86400);
|
|
||||||
return max($ret, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($this->data['premdays'] == 0) {
|
if($this->data['premdays'] == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -479,12 +474,14 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
|||||||
|
|
||||||
public function isPremium()
|
public function isPremium()
|
||||||
{
|
{
|
||||||
if(isset($this->data['premium_ends_at'])) {
|
if(isset($this->data['premium_ends_at']) || isset($this->data['premend']) ||
|
||||||
return $this->data['premium_ends_at'] > time();
|
(isCanary() && isset($this->data['lastday']))) {
|
||||||
|
$col = (isset($this->data['premium_ends_at']) ? 'premium_ends_at' : (isset($this->data['lastday']) ? 'lastday' : 'premend'));
|
||||||
|
return $this->data[$col] > time();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($this->data['premend'])) {
|
if($this->data['premdays'] == self::GRATIS_PREMIUM_DAYS){
|
||||||
return $this->data['premend'] > time();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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['premdays'] - (date("z", time()) + (365 * (date("Y", time()) - date("Y", $this->data['lastday']))) - date("z", $this->data['lastday'])) > 0);
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
*/
|
*/
|
||||||
class Account extends Model {
|
class Account extends Model {
|
||||||
|
|
||||||
|
const GRATIS_PREMIUM_DAYS = 65535;
|
||||||
|
|
||||||
protected $table = 'accounts';
|
protected $table = 'accounts';
|
||||||
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
@@ -34,9 +36,9 @@ class Account extends Model {
|
|||||||
public function getPremiumDaysAttribute()
|
public function getPremiumDaysAttribute()
|
||||||
{
|
{
|
||||||
if(isset($this->premium_ends_at) || isset($this->premend) ||
|
if(isset($this->premium_ends_at) || isset($this->premend) ||
|
||||||
(isCanary() && isset($this->data['lastday']))) {
|
(isCanary() && isset($this->lastday))) {
|
||||||
$col = (isset($this->premium_ends_at) ? 'premium_ends_at' : (isset($this->data['lastday']) ? 'lastday' : 'premend'));
|
$col = (isset($this->premium_ends_at) ? 'premium_ends_at' : (isset($this->lastday) ? 'lastday' : 'premend'));
|
||||||
$ret = ceil(($this->{$col}- time()) / (24 * 60 * 60));
|
$ret = ceil(($this->{$col} - time()) / (24 * 60 * 60));
|
||||||
return max($ret, 0);
|
return max($ret, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,8 +46,8 @@ class Account extends Model {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->premdays == 65535){
|
if($this->premdays == self::GRATIS_PREMIUM_DAYS){
|
||||||
return 65535;
|
return self::GRATIS_PREMIUM_DAYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = ceil($this->premdays - ((int)date("z", time()) + (365 * (date("Y", time()) - date("Y", $this->lastday))) - date("z", $this->lastday)));
|
$ret = ceil($this->premdays - ((int)date("z", time()) + (365 * (date("Y", time()) - date("Y", $this->lastday))) - date("z", $this->lastday)));
|
||||||
@@ -54,12 +56,14 @@ class Account extends Model {
|
|||||||
|
|
||||||
public function getIsPremiumAttribute()
|
public function getIsPremiumAttribute()
|
||||||
{
|
{
|
||||||
if(isset($this->premium_ends_at)) {
|
if(isset($this->premium_ends_at) || isset($this->premend) ||
|
||||||
return $this->premium_ends_at > time();
|
(isCanary() && isset($this->lastday))) {
|
||||||
|
$col = (isset($this->premium_ends_at) ? 'premium_ends_at' : (isset($this->lastday) ? 'lastday' : 'premend'));
|
||||||
|
return $this->{$col} > time();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($this->premend)) {
|
if($this->premdays == self::GRATIS_PREMIUM_DAYS){
|
||||||
return $this->premend > time();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($this->premdays - (date("z", time()) + (365 * (date("Y", time()) - date("Y", $this->lastday))) - date("z", $this->lastday)) > 0);
|
return ($this->premdays - (date("z", time()) + (365 * (date("Y", time()) - date("Y", $this->lastday))) - date("z", $this->lastday)) > 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user