/
download.php
65 lines (57 loc) · 1.62 KB
/
download.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/*
--------------------------------------------------------------------------------
File: download.php
Module: DOWNLOAD
Author: Quoc Viet [aFeLiOn]
Begin: 2006-03-12
Comment:
--------------------------------------------------------------------------------
*/
define('EPS_ROOT', './');
require EPS_ROOT.'include/common.php';
// No Guest
if ($eps_user['is_guest'])
return;
$down = (!empty($_GET['down'])) ? $_GET['down'] : '';
$id = (!empty($_GET['id']) && intval($_GET['id']) >= 1) ? intval($_GET['id']) : '';
if (empty($id))
return;
if ($down == 'share')
{
$result = $epsclass->db->vselect(TBL_SHARE, array('url','size','mimetype'), $id);
if (!$epsclass->db->num_rows($result))
{
$smarty->assign('tpl_eps_title', $eps_lang['Error']);
$smarty->assign('tpl_eps_main', gen_alert($eps_lang['Bad_request']));
$smarty->display('main.tpl');
return;
}
else
{
$this_share = $epsclass->db->fetch_assoc($result);
$epsclass->db->free_result($result);
$this_share['full_url'] = EPS_SHARE_DIR.$this_share['url'];
if (!is_file($this_share['full_url']))
{
alert($eps_lang['Bad_request']);
return;
}
else
{
// Send Header
//header('Content-Type: '.$this_share['mimetype']);
header('Content-type: application/force-download');
header('Content-Disposition: attachment; filename="'.basename($this_share['url']).'"');
if($this_share['size'] != 0)
header('Content-Length: '.$this_share['size']);
header('Content-Transfer-Encoding: binary');
header('Pragma: no-cache');
header('Expires: 0');
header('Connection: close');
readfile($this_share['full_url']);
exit();
}
}
}
?>