hajime/public/manage/func.php

64 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2023-08-11 22:16:32 +00:00
<?php
if($_SERVER['PHP_SELF'] == '/func.php') {
header('Location: ./');
exit;
}
function getBans() {
global $flashii, $database;
$bans = $database->query('SELECT * FROM `flashii_bans`;')->fetch_all(MYSQLI_ASSOC);
return $bans;
}
function getUsers() {
global $flashii, $database;
$users = $database->query('SELECT * FROM `flashii_users`;')->fetch_all(MYSQLI_ASSOC);
return $users;
}
function banUser($id, $ip, $type, $perma, $for, $mid, $mip, $reason) {
global $flashii, $database;
$id = $flashii->cleanString($id);
$ip = $flashii->cleanString($ip);
$mid = $flashii->cleanString($mid);
$mip = $flashii->cleanString($mip);
$reason = $flashii->cleanString($reason);
$perma = $perma ? '1' : '0';
$date = time();
$until = $date + $for;
switch($type) {
case 'uip':
$type = 2;
break;
case 'ip':
$type = 1;
break;
case 'user':
default:
$type = 0;
}
$database->query("INSERT INTO `flashii_bans` (`uid`, `ip`, `type`, `perma`, `bannedtill`, `timestamp`, `mid`, `mip`, `reason`) VALUES ('". $id ."', '". $ip ."', '". $type ."', '". $perma ."', '". $until ."', '". $date ."', '". $mid ."', '". $mip ."', '". $reason ."');");
}
function unbanUser($id) {
global $flashii, $database;
$id = $flashii->cleanString($id);
$database->query("DELETE FROM `flashii_bans` WHERE `id`='". $id ."';");
}