<?php
include 'renderer.php';

class Deletedocument extends Renderer {

    public function render(): void {
        if ($_SESSION['userid'] === 0 && in_array($this->getScriptName() , $this->internalMenuItems, false)) {
            $this->templateName = 'login_error';
            parent::render();
            return;
        }
        $query = 'DELETE FROM `document` WHERE `title` = "' . filter_input(INPUT_POST, 'file', FILTER_SANITIZE_ADD_SLASHES) . '"';
        mysqli_query($this->dbConnection, $query);
        @unlink('/var/shared/fvajs/' . filter_input(INPUT_GET, 'ts', FILTER_SANITIZE_STRING));
        echo '';
    }
}
