r4178 bugfix: PHP warnings were appearing before rackspace on SLB object page, defaul...
[racktables] / download.php
CommitLineData
e1ae3fb4 1<?php
c9538c89
DO
2ob_start();
3try {
4 require 'inc/init.php';
5 // purely for renderAccessDenied()
6 require 'inc/interface.php';
e1ae3fb4 7
c9538c89
DO
8 assertUIntArg ('file_id');
9 $pageno = 'file';
10 $tabno = 'download';
11 fixContext();
12 if (!permitted())
13 renderAccessDenied();
d9731fc4 14
c9538c89
DO
15 $asattach = (isset ($_REQUEST['asattach']) and $_REQUEST['asattach'] == 'no') ? FALSE : TRUE;
16 $file = getFile ($_REQUEST['file_id']);
17 if ($file != NULL)
18 {
19 header("Content-Type: {$file['type']}");
20 header("Content-Length: {$file['size']}");
21 if ($asattach)
22 header("Content-Disposition: attachment; filename={$file['name']}");
23 echo $file['contents'];
24 }
25 ob_end_flush();
26}
27catch (Exception $e)
e1ae3fb4 28{
c9538c89
DO
29 ob_end_clean();
30 printException($e);
e1ae3fb4
AD
31}
32?>