<?
//   Wouter van Wijk
//   2004
//
//   This program 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.
//
//   This program 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 this program; if not, write to the Free Software
//   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
// session check
include('settings.php');
session_start();
if (!isset($_SESSION['user']))
{
	header("Location: error.php?ec=2");
	exit;
}

	$action=trim($_GET['action']);

	switch($action) {
		case 'delete':
			$mailbox=$_GET['mailbox'];
			$er = deleteMailbox($mailbox, $idarray);
			header("Location: mailsplash.php?messagetitle=". urlencode('Folder deleted'). '&message=' . urlencode($SESSION_MAIL_SERVER).'-'.$er);
			exit;
			break;
		case 'rename':
			$oldname=$_GET['oldname'];
			$newname=$_GET['newname'];
			$er = renameMailbox($oldname, $newname);
			header("Location: mailsplash.php?messagetitle=". urlencode('Folder renamed').'&message=' . urlencode('From: '.$oldname . ',  To: ' . $newname.'-'.$er));
			exit;
			break;
		case 'create':
			$inmailbox=$_GET['inmailbox'];
			$name=$_GET['name'];
			$er = createMailbox($inmailbox, $name);
			header("Location: mailsplash.php?messagetitle=" . urlencode('Folder Created') . '&message=' . urlencode('Name: '.$name. ', In: ' . $inmailbox.'-'.$er));
			exit;
			break;
		case 'emptytrash':
			$er = emptyTrash();
			header("Location: mailsplash.php?messagetitle=" . urlencode('Trash emptied') . '&message=' .  urlencode('How sad... it was such a happy trash when it was full. Shame on you!'.'-'.$er));
			exit;
			break;
	}
?>
