<?php

// attachment.php - Adding, deleting, and displaying attachments
// ------------------------------------------------------------------------
// Copyright (c) 2001, 2002 The phpBugTracker Group
// Copyright (c) 2004, 2005 David Han Sze Chuen, Denis Guinnepain for Air Liquide Medical Systems (Taema)
// Copyright (c) 2005, 2006, 2015 Denis Guinnepain
 
// ------------------------------------------------------------------------
// This file is part of Diamentis

// Diamentis is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.

// Diamentis is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with phpBugTracker; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// ------------------------------------------------------------------------
// $Id: attachment.php,v 1.1.1.3 2006/01/14 23:44:20 denis Exp $

include 'include.php';
include 'attachment_lib.php';

	

if (isset($_GET['del'])) {
	if (!$perm->have_perm('Admin')) {
		show_text($STRING['bad_permission']);
	} else {
		del_attachment($_GET['del']);
	}
} elseif (isset($_POST['submit'])) {
	$perm->check('Editbug');
	add_attachment($_POST['file_id'],	$_POST['description']);
} elseif (isset($_GET['attachid'])) {
	if (list($filename, $mimetype) = grab_attachment($_GET['attachid'])) {
		header("Content-type: $mimetype");
		@readfile($filename);
		exit;
	}
} else {
	$perm->check('Editbug');
	show_attachment_form($_GET['file_id']);
}

?>
