tiki-download_userfile.php 1.3 KB
Newer Older
awcolley's avatar
awcolley committed
1
<?php
2

3
// $Id: /cvsroot/tikiwiki/tiki/tiki-download_userfile.php,v 1.12.2.1 2008-03-01 17:12:54 leyan Exp $
4

5
// Copyright (c) 2002-2007, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
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.

awcolley's avatar
awcolley committed
9
// Initialization
10
$force_no_compression = true;
11
require_once ('tiki-setup.php');
awcolley's avatar
awcolley committed
12

13
include_once ('lib/userfiles/userfileslib.php');
awcolley's avatar
awcolley committed
14

15 16
if (!isset($_REQUEST["fileId"])) {
	die;
awcolley's avatar
awcolley committed
17
}
18

19 20 21 22 23 24 25
if ($prefs['feature_userfiles'] != 'y') {
	$smarty->assign('msg', tra("This feature is disabled").": feature_userfiles");

	$smarty->display("error.tpl");
	die;
}

26
$info = $userfileslib->get_userfile($user, $_REQUEST["fileId"]);
27 28 29 30
if ( empty($info['filetype']) || $info['filetype'] == 'application/x-octetstream' || $info['filetype'] == 'application/octet-stream' ) {
	include_once('lib/mime/mimelib.php');
	$info['filetype'] = tiki_get_mime($info['filename'], 'application/octet-stream');
}
31 32 33 34
$type = &$info["filetype"];
$file = &$info["filename"];
$content = &$info["data"];

35
session_write_close();
36
header ("Content-type: $type");
37
header ("Content-Disposition: inline; filename=\"$file\"");
38 39

if ($info["path"]) {
40
	readfile ($prefs['uf_use_dir'] . $info["path"]);
awcolley's avatar
awcolley committed
41
} else {
42
	echo "$content";
awcolley's avatar
awcolley committed
43
}