$UserUtil = new UserUtil($DB);
 $BuildingUtil = new BuildingUtil($DB);
 $user = new User(null, 'example', '*****@*****.**');
 $user->setPassword('a-password');
 $user = $UserUtil->create($user);
 if ($user != null) {
     echo '<strong>UserUtil->create()</strong>';
     echo '<pre>';
     print_r($user);
     echo '</pre>';
 } else {
     echo "A problem ocurred while trying to create the user";
 }
 if ($user != null) {
     $id = $user->getId();
     $user2 = $UserUtil->getUserById($id);
     if ($user2 != null) {
         echo '<strong>UserUtil->getUserById()</strong>';
         echo '<pre>';
         print_r($user2);
         echo '</pre>';
     } else {
         echo "A problem ocurred while trying to get a user by ID";
     }
 }
 if ($user != null) {
     if ($UserUtil->removeUser($user)) {
         echo '<strong>UserUtil->remove()</strong>';
         echo '<br />OK';
     } else {
         echo "A problem ocurred while trying to remove the user from the database";
// Include class definitions before calling session_start()
require_once '../../server/classes/class.dbutil.php';
require_once '../../server/classes/class.users.php';
require_once '../../server/classes/class.buildings.php';
require_once '../../server/classes/class.operations.php';
require_once '../../server/classes/class.user.php';
require_once '../../server/config.php';
session_start();
if (count($_GET) != 0 && isset($_SESSION['userSession'])) {
    // Check that all parameters have valid values
    if (!is_numeric($_GET['x']) || !is_numeric($_GET['y']) || intval($_GET['x']) < 0 || intval($_GET['y']) < 0 || intval($_GET['x']) > GRID_X || intval($_GET['y']) > GRID_Y) {
        die('ERROR');
    }
    $DB = new DBUtil(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
    // DB name
    if ($DB) {
        $UserUtil = new UserUtil($DB);
        $OperUtil = new OperationsUtil($DB);
        $user = $UserUtil->getUserById($_SESSION['userSession']->getId());
        // Is there anything in that coordinate?
        $inst = $OperUtil->findBuildingInstanceByXY($user->getId(), $_GET['x'], $_GET['y']);
        if ($inst) {
            $OperUtil->removeInstance($inst);
            die('OK');
        } else {
            die('ERROR');
        }
    }
} else {
    die('ERROR');
}