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/account/library/isLeech.inc

32 lines
664 B
PHP

<?php
class main_account_isLeech {
function __construct($lib) {
$this->lib = $lib;
$this->db = $this->lib->game->db;
}
function run($id) {
$q = $this->db->query("SELECT UNIX_TIMESTAMP(NOW())-donated FROM pp_history ORDER BY donated ASC LIMIT 1");
if (!($q && dbCount($q))) {
return true;
}
list($interval) = dbFetchArray($q);
if ($interval == 0) {
return true;
}
$days = $interval / 86400;
$q = $this->db->query("SELECT SUM(amount) FROM pp_history WHERE account=$id");
if (!($q && dbCount($q))) {
return false;
}
list($sum) = dbFetchArray($q);
$sum = is_null($sum) ? 0 : $sum;
return ($sum / $days <= 0.05);
}
}
?>