This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/_sakura/components/Bans.php

47 lines
1.1 KiB
PHP
Raw Normal View History

2015-07-08 13:09:57 +00:00
<?php
/*
* Ban management
*/
namespace Sakura;
class Bans
{
2015-07-30 01:12:53 +00:00
// Check if a user is banned
public static function checkBan($uid)
{
2015-07-30 01:12:53 +00:00
2015-07-30 17:07:23 +00:00
// Attempt to get a ban from this user
$bans = Database::fetch('bans', true, ['uid' => [$uid, '=']]);
2015-07-30 17:07:23 +00:00
// Reverse the array so new bans are listed first
$bans = array_reverse($bans);
// Go over each ban
foreach ($bans as $ban) {
2015-07-30 17:07:23 +00:00
// Check if it hasn't expired
if ($ban['ban_end'] != 0 && $ban['ban_end'] < time()) {
2015-07-30 17:07:23 +00:00
// If it has delete the entry and continue
Database::delete('bans', ['id' => [$ban['uid'], '=']]);
2015-07-30 17:07:23 +00:00
continue;
}
// Return the ban if all checks were passed
2015-07-30 01:12:53 +00:00
return [
2015-07-30 17:07:23 +00:00
'user' => $ban['uid'],
'issuer' => $ban['mod_uid'],
'issued' => $ban['ban_begin'],
'expires' => $ban['ban_end'],
'reason' => $ban['ban_reason'],
2015-07-30 17:07:23 +00:00
2015-07-30 01:12:53 +00:00
];
2015-07-30 17:07:23 +00:00
2015-07-30 01:12:53 +00:00
}
2015-07-30 17:07:23 +00:00
// Else just return false
return false;
2015-07-30 01:12:53 +00:00
}
2015-07-08 13:09:57 +00:00
}