+++ /dev/null
-<?php
-ob_start();
-try {
- require 'inc/init.php';
- // purely for renderAccessDenied()
- require 'inc/interface.php';
-
- assertUIntArg ('file_id');
- $pageno = 'file';
- $tabno = 'download';
- fixContext();
- if (!permitted())
- renderAccessDenied();
-
- $asattach = (isset ($_REQUEST['asattach']) and $_REQUEST['asattach'] == 'no') ? FALSE : TRUE;
- $file = getFile ($_REQUEST['file_id']);
- if ($file != NULL)
- {
- header("Content-Type: {$file['type']}");
- header("Content-Length: {$file['size']}");
- if ($asattach)
- header("Content-Disposition: attachment; filename={$file['name']}");
- echo $file['contents'];
- }
- ob_end_flush();
-}
-catch (Exception $e)
-{
- ob_end_clean();
- printException($e);
-}
-?>
echo "<tr><th width='50%' class=tdright>Size:</th><td class=tdleft>";
if (isolatedPermission ('file', 'download', $file))
{
- echo "<a href='download.php?file_id=${file_id}'>";
+ echo "<a href='?module=download&file_id=${file_id}'>";
printImageHREF ('download', 'Download file');
echo '</a> ';
}
function renderFileDownloader ($file_id)
{
- echo "<br><center><a target='_blank' href='download.php?file_id=${file_id}&asattach=1'>";
+ echo "<br><center><a target='_blank' href='?module=download&file_id=${file_id}&asattach=1'>";
printImageHREF ('DOWNLOAD');
echo '</a></center>';
}
echo '</td></tr><tr><td>';
if (isolatedPermission ('file', 'download', $cell))
{
- echo "<a href='download.php?file_id=${cell['id']}'>";
+ // FIXME: reuse renderFileDownloader()
+ echo "<a href='?module=download&file_id=${cell['id']}'>";
printImageHREF ('download', 'Download file');
echo '</a> ';
}
$resampled = TRUE;
}
if ($resampled)
- $ret .= "<a href='download.php?file_id=${file['id']}&asattach=no'>";
+ $ret .= "<a href='?module=download&file_id=${file['id']}&asattach=no'>";
$ret .= "<img width=${width} height=${height} src='render_image.php?img=preview&file_id=${file['id']}'>";
if ($resampled)
$ret .= '</a><br>(click to zoom)';
genericAssertion ('uri', 'string');
proxyStaticURI ($_REQUEST['uri']);
break;
+ case 'download':
+ $pageno = 'file';
+ $tabno = 'download';
+ fixContext();
+ if (!permitted())
+ {
+ require_once 'inc/interface.php';
+ renderAccessDenied();
+ }
+
+ $asattach = (isset ($_REQUEST['asattach']) and $_REQUEST['asattach'] == 'no') ? FALSE : TRUE;
+ $file = getFile (getBypassValue());
+ header("Content-Type: {$file['type']}");
+ header("Content-Length: {$file['size']}");
+ if ($asattach)
+ header("Content-Disposition: attachment; filename={$file['name']}");
+ echo $file['contents'];
+ break;
default:
throw new InvalidRequestArgException ('module', $_REQUEST['module']);
}
+ ob_end_flush();
exit;
}