<?php
/*
This file is part of Thomas Bley's moregroupware webmail2/calendar2/admin2 module. (tb-mgw)

More information:
-----------------

Simple Groupware Solutions Thomas Bley
Fichtenstr. 23
Germany, 85640 Putzbrunn

Contact:
--------

info@simple-groupware.de

http://www.simple-groupware.de


Copyright 2002-2003 Thomas Bley
tb-mgw is distributed under the terms of the GNU General Public License 

tb-mgw 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.

tb-mgw 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 tb-mgw; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

// Attachments
// Moregroupware.org

$myEnv["module"] = "webmail2";
$myEnv["stdsmenu"] = false;
$myEnv["output"] = "html";

include("../../config.inc.php");
include(INCLUDEPATH . "container.inc.php");

error_reporting  (E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

checkdir(CACHE_FOLDER."sendmail/",true);

$sendmail_array = array();

$myvars = array("to","cc","bcc","subject","signit","sendplain","notification","msgbody","replyto","inreplyto","slcsil","forward","von","priority","showhtml","import","editmail");
foreach ($myvars as $thevar) {
  if (!isset($_GET[$thevar]) and !isset($_POST[$thevar])) {
    ${$thevar} = "<empty>";
  } else {
    ${$thevar} = stripslashes(myquote((isset($_GET[$thevar])) ? $_GET[$thevar] : (isset($_POST[$thevar]) ? $_POST[$thevar] : "")));
  }
}

if ($signit=="" or $signit=="<empty>") { $signit = "notchecked"; }
if ($notification=="" or $notification=="<empty>") { $notification = "notchecked"; }
if ($sendplain=="" or $sendplain=="<empty>") { $sendplain = "notchecked"; }

$MGW = $_SESSION["MGW"];
$username = $MGW->username;

if ($import=="" or $import=="<empty>") {
  $mysession_vars = array("msgbody","subject","von","to","cc","bcc","priority","replyto","inreplyto","signit","sendplain","notification","forward","editmail","showhtml");
  foreach ($mysession_vars as $thevar) {
    if (${$thevar}!="<empty>") {
      $sendmail_array[$thevar] = htmlspecialchars(${$thevar});
    }
  }
  $_SESSION["webmail2_compose_array"] = $sendmail_array;
}

$attaches = array();
$handle=opendir(CACHE_FOLDER."sendmail/");
while ($file = readdir($handle)) {
  if (strstr($file,session_id())) {
    $attaches[] = "<option value='".$file."'>".urldecode(substr(strstr($file,"######"),6))." (".ceil(filesize(CACHE_FOLDER."sendmail/" . $file) / 1024)." K)</option>\n";
  }
}
closedir($handle);


$smarty->assign("attaches", $attaches);
$smarty->assign("username", ucfirst($username));

$smarty->display("attachments.tpl");
?>