Translation update done using Pootle.
[phpmyadmin.git] / bs_disp_as_mime_type.php
blob5284e553fad3997ee73faf30136300b1ee6ccad9
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 PMA_download_header(basename($filename), $c_type, $f_size);
48 $pos = 0;
49 $content = "";
51 while (!feof($fHnd)) {
52 $content .= fread($fHnd, $f_size);
53 $pos = strlen($content);
55 if ($pos >= $f_size) {
56 break;
60 echo $content;
61 flush();
63 fclose($fHnd);