This repository has been archived on 2024-07-18. You can view files and clone it, but cannot push or open issues or pull requests.
lwb5/scripts/game/main/vacation/library/canSet.inc

32 lines
660 B
PHP
Raw Normal View History

2016-01-10 11:01:49 +01:00
<?php
class main_vacation_canSet {
function main_vacation_canSet($lib) {
$this->lib = $lib;
$this->db = $this->lib->game->db;
}
function run($uid) {
$q = $this->db->query("SELECT t FROM account_log WHERE account=$uid AND action='VEND'");
if (!$q) {
return false;
} elseif (dbCount($q) > 0) {
list($last) = dbFetchArray($q);
if (!(time() - $last > 604800 /* 7 * 24 * 3600 */ )) {
return false;
}
}
$q = $this->db->query("SELECT vac_credits,quit_ts FROM account WHERE id=$uid");
if (!($q && dbCount($q) == 1)) {
return false;
}
list($cred,$quit) = dbFetchArray($q);
return is_null($quit) && ($cred > 0);
}
}
?>