예제 #1
0
        throw new InputErrorException('IP address is not valid.', 400);
    }
    $player = Player::find($req->getAPIParam('banned_by'));
    if (!$player) {
        throw new InputErrorException('The banned_by player not found.', 404);
    }
    if ($player->account->id !== $DevAAC->auth_account->id) {
        throw new InputErrorException('The banned_by player is not yours!', 406);
    }
    if ($player->group_id < 2) {
        throw new InputErrorException('The banned_by player must have group_id > 1.', 406);
    }
    $ban = new IpBan(array('ip' => $req->getAPIParam('ip'), 'reason' => $req->getAPIParam('reason'), 'banned_at' => new \DevAAC\Helpers\DateTime(), 'expires_at' => $req->getAPIParam('expires_at', 0), 'banned_by' => $player->id));
    $ban->save();
    $DevAAC->response->headers->set('Content-Type', 'application/json');
    $DevAAC->response->setBody($ban->toJson(JSON_PRETTY_PRINT));
});
/**
 * @SWG\Resource(
 *  basePath="/api/v1",
 *  resourcePath="/server",
 *  @SWG\Api(
 *    path="/server/ipBans/{ip}",
 *    description="Operations on server",
 *    @SWG\Operation(
 *      summary="Delete IP ban",
 *      notes="Need to have admin rights",
 *      method="DELETE",
 *      type="null",
 *      nickname="deleteIPBan",
 *      @SWG\Parameter( name="ip",