Microweber\Utils\Backup::delete PHP Method

delete() public method

public delete ( $params )
    public function delete($params)
    {
        if (!is_admin()) {
            error('must be admin');
        }
        $id = $params['id'];
        if ($id == null) {
            return array('error' => 'You have not provided filename to be deleted.');
        }
        $here = $this->get_bakup_location();
        $filename = $here . $id;
        $id = str_replace('..', '', $id);
        $filename = str_replace('..', '', $filename);
        $ext = get_file_extension(strtolower($filename));
        if ($ext != 'zip' and $ext != 'sql') {
            return array('error' => "You are now allowed to delete {$ext} files.");
        }
        if (is_file($filename)) {
            unlink($filename);
            return array('success' => "{$id} was deleted!");
        } else {
            $filename = $here . $id . '.sql';
            if (is_file($filename)) {
                unlink($filename);
                return array('success' => "{$id} was deleted!");
            }
        }
    }