Esempio n. 1
0
<?php

require_once '../autoload.php';
$user = Auth::user();
$dbManager = new DatabaseManager();
if ($dbManager->isOwner($user, $_GET['scope'])) {
    $dbManager->deleteRoom($_GET['scope']);
    json_p(["success" => true]);
} else {
    json_p(["success" => false, "reason" => "You are not the owner of this room."]);
}
Esempio n. 2
0
$scope = $_GET['scope'];
$level = $_GET['level'];
if ($type !== "add" && $type !== "remove") {
    json_p(['success' => false, 'reason' => "Expected values of add or remove for parameter type."]);
}
$user = Auth::user();
if (!$user) {
    json_p(["success" => false, "This endpoint requires authentication."]);
}
$dbManager = new DatabaseManager();
if (!$dbManager->validateScope($scope)) {
    json_p("Invalid room name.");
}
switch ($level) {
    case "admin":
        if (!$dbManager->isOwner($user, $scope)) {
            json_p(['success' => false, 'reason' => "Only the room owner can appoint or demote admins."]);
        }
        json_p($dbManager->changePermission($type, $username, $scope, DatabaseManager::PERMISSION_LEVEL_ROOM_ADMIN));
        break;
    case "host":
    case "ban":
        if (!$dbManager->isOwnerOrAdmin($user, $scope)) {
            json_p(['success' => false, 'reason' => "You don't have permission to do this."]);
        }
        json_p($dbManager->changePermission($type, $username, $scope, $level === "host" ? DatabaseManager::PERMISSION_LEVEL_ROOM_HOST : DatabaseManager::PERMISSION_LEVEL_ROOM_BANNED));
        break;
    case "queue_ban":
    case "mute":
        if (!$dbManager->isHostOrAbove($user, $scope)) {
            json_p(['success' => false, 'reason' => "You don't have permission to do this."]);