Missing jquery library which is referenced in js/functions.js
[phpmyadmin-themes.git] / bs_disp_as_mime_type.php
blob085d888236d61e324dd7ecc27f7bef4e1b14bd96
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * @package BLOBStreaming
5 */
7 /**
8 * Core library.
9 */
10 require_once './libraries/common.inc.php';
12 // Check URL parameters
13 PMA_checkParameters(array('reference', 'c_type'));
15 // Increase time limit, because fetching blob might take some time
16 set_time_limit(0);
18 $reference = $_REQUEST['reference'];
20 * FIXME: Maybe it would be better to check MIME type against whitelist as
21 * this code sems to support only few MIME types (check
22 * function PMA_BS_CreateReferenceLink in libraries/blobstreaming.lib.php).
24 $c_type = preg_replace('/[^A-Za-z0-9/_-]/', '_', $_REQUEST['c_type']);
26 // Get the blob streaming URL
27 $filename = PMA_BS_getURL($reference);
28 if (empty($filename)) {
29 die(__('No blob streaming server configured!'));
32 $hdrs = get_headers($filename, 1);
34 if ($hdrs === FALSE) {
35 die(__('Failed to fetch headers'));
38 $fHnd = fopen($filename, "rb");
40 if ($fHnd === FALSE) {
41 die(__('Failed to open remote URL'));
44 $f_size = $hdrs['Content-Length'];
46 header("Expires: 0");
47 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
48 header("Cache-Control: no-store, no-cache, must-revalidate");
49 header("Cache-Control: post-check=0, pre-check=0", false);
50 header("Pragma: no-cache");
51 header("Content-type: $c_type");
52 header('Content-length: ' . $f_size);
53 header("Content-disposition: attachment; filename=" . basename($filename));
55 $pos = 0;
56 $content = "";
58 while (!feof($fHnd)) {
59 $content .= fread($fHnd, $f_size);
60 $pos = strlen($content);
62 if ($pos >= $f_size) {
63 break;
67 echo $content;
68 flush();
70 fclose($fHnd);