tiki-webmail_download_attachment.php 1.47 KB
Newer Older
1
<?php
changi67's avatar
changi67 committed
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright 2002-2015 by authors of the Tiki Wiki CMS Groupware Project
changi67's avatar
changi67 committed
6
// 
7 8
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
changi67's avatar
changi67 committed
9
// $Id$
10

redflo's avatar
redflo committed
11
require_once ('tiki-setup.php');
12

13 14
$access->check_feature('feature_webmail');
$access->check_permission('tiki_p_use_webmail');
15

16
require_once ('lib/webmail/webmaillib.php');
lrargerich's avatar
lrargerich committed
17 18

require ("lib/webmail/mimeDecode.php");
19 20
//require ("lib/webmail/pop3.php");
require ("lib/webmail/net_pop3.php");
lrargerich's avatar
lrargerich committed
21

22
$current = $webmaillib->get_current_webmail_account($user);
23 24 25 26 27
//$pop3 = new POP3($current["pop"], $current["username"], $current["pass"]);
//$pop3->Open();
$pop3->connect($current["pop"]);
$pop3->login($current["username"], $current["pass"]);
$full = $pop3->getMsg($_REQUEST["msgid"]);
28
$smarty->assign('msgid', $_REQUEST["msgid"]);
29
$pop3->disconnect();
lrargerich's avatar
lrargerich committed
30
$params = array(
31 32 33 34 35 36
	'input' => $full,
	'crlf' => "\r\n",
	'include_bodies' => TRUE,
	'decode_headers' => TRUE,
	'decode_bodies' => TRUE
);
lrargerich's avatar
lrargerich committed
37 38 39 40 41

$output = Mail_mimeDecode::decode($params);
$part = $output->parts[$_REQUEST["getpart"]];
$type = $part->headers["content-type"];
$content = $part->body;
42 43
$names = explode(';', $part->headers["content-disposition"]);
$names = explode('=', $names[1]);
44
$file = $names[1];
lrargerich's avatar
lrargerich committed
45

46
header("Content-type: $type");
47
//header( "Content-Disposition: attachment; filename=$file" );
48
header("Content-Disposition: inline; filename=$file");
49
echo "$content";