From e960406e5dc6513e2d0ad3ae7919c7176bd75e04 Mon Sep 17 00:00:00 2001 From: Raj Kissu Rajandran Date: Sun, 2 Nov 2008 06:54:27 +0000 Subject: [PATCH] Fixed MIME type change issue. --- bs_change_mime_type.php | 2 ++ bs_disp_as_mime_type.php | 33 ++++++++++++++++++--------------- bs_play_media.php | 9 +++++++++ js/functions.js | 4 ++-- libraries/blobstreaming.lib.php | 14 +++++++++++--- libraries/common.inc.php | 2 +- 6 files changed, 43 insertions(+), 21 deletions(-) diff --git a/bs_change_mime_type.php b/bs_change_mime_type.php index cb9599dda..d4bb98402 100644 --- a/bs_change_mime_type.php +++ b/bs_change_mime_type.php @@ -54,6 +54,8 @@ if ($data = PMA_DBI_fetch_assoc($result)) { $query = "SELECT count(*) FROM " . PMA_backquote($mybs_cust_content_type_tbl); + $query .= " WHERE Blob_url='" . PMA_sqlAddslashes($bsReference) . "'"; + $result = PMA_DBI_query($query); // if record exists diff --git a/bs_disp_as_mime_type.php b/bs_disp_as_mime_type.php index f1e2e44fe..921f5d885 100644 --- a/bs_disp_as_mime_type.php +++ b/bs_disp_as_mime_type.php @@ -8,8 +8,8 @@ set_time_limit(0); -$filename = isset($_REQUEST['bs_ref']) : $_REQUEST['bs_ref'] : NULL; -$c_type = isset($_REQUEST['c_type']) : $_REQUEST['c_type'] : NULL; +$filename = isset($_REQUEST['file_path']) ? $_REQUEST['file_path'] : NULL; +$c_type = isset($_REQUEST['c_type']) ? $_REQUEST['c_type'] : NULL; if (isset($filename) && isset($c_type)) { @@ -29,21 +29,24 @@ if (isset($filename) && isset($c_type)) $fHnd = fopen($filename, "rb"); - $pos = 0; - $content = ""; - - while (!feof($fHnd)) + if ($fHnd) { - $content .= fread($fHnd, $f_size); - $pos = strlen($content); + $pos = 0; + $content = ""; - if ($pos >= $f_size) - break; + while (!feof($fHnd)) + { + $content .= fread($fHnd, $f_size); + $pos = strlen($content); + + if ($pos >= $f_size) + break; + } + + echo $content; + flush(); + + fclose($fHnd); } - - echo $content; - flush(); - - fclose($fHnd); } ?> diff --git a/bs_play_media.php b/bs_play_media.php index cf80832ed..42eb06cc4 100644 --- a/bs_play_media.php +++ b/bs_play_media.php @@ -12,6 +12,11 @@ */ $mediaType = isset($_REQUEST['media_type']) ? $_REQUEST['media_type'] : NULL; + /* + * @var string indicates whether media type is of custom type + */ + $customType = isset($_REQUEST['custom_type']) ? $_REQUEST['custom_type'] : false; + /* * @var string contains BLOB reference */ @@ -29,6 +34,10 @@ // retrieve BS server variables from PMA configuration $bs_server = $PMA_Config->get('BLOBSTREAMING_SERVER'); $bs_file_path = "http://" . $bs_server . '/' . $bsReference; + + if (isset($customType) && $customType) + $bs_file_path = "bs_disp_as_mime_type.php?file_path=" . urlencode($bs_file_path) . "&c_type=" . urlencode($mediaType); + ?> diff --git a/js/functions.js b/js/functions.js index 54ef9a931..bf1b5913c 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1250,7 +1250,7 @@ function pdfPaperSize(format, axis) { * @param var w_width width of popup window * @param var w_height height of popup window */ -function popupBSMedia(url_params, bs_ref, m_type, w_width, w_height) +function popupBSMedia(url_params, bs_ref, m_type, is_cust_type, w_width, w_height) { // if width not specified, use default if (w_width == undefined) @@ -1261,7 +1261,7 @@ function popupBSMedia(url_params, bs_ref, m_type, w_width, w_height) w_height = 480; // open popup window (for displaying video/playing audio) - var mediaWin = window.open('bs_play_media.php?' + url_params + '&bs_reference=' + bs_ref + '&media_type=' + m_type, 'viewBSMedia', 'width=' + w_width + ', height=' + w_height + ', resizable=1, scrollbars=1, status=0'); + var mediaWin = window.open('bs_play_media.php?' + url_params + '&bs_reference=' + bs_ref + '&media_type=' + m_type + '&custom_type=' + is_cust_type, 'viewBSMedia', 'width=' + w_width + ', height=' + w_height + ', resizable=1, scrollbars=1, status=0'); } /** diff --git a/libraries/blobstreaming.lib.php b/libraries/blobstreaming.lib.php index 0b39fe843..d8616e9ff 100644 --- a/libraries/blobstreaming.lib.php +++ b/libraries/blobstreaming.lib.php @@ -673,7 +673,15 @@ function PMA_BS_CreateReferenceLink($bs_reference, $db_name) if ($data = @PMA_DBI_fetch_assoc($result)) { // determine content-type for BS repository file (original or custom) - $content_type = isset($data['Custom_type']) ? $data['Custom_type'] : $data['Content_type']; + $is_custom_type = false; + + if (isset($data['Custom_type'])) + { + $content_type = $data['Custom_type']; + $is_custom_type = true; + } + else + $content_type = $data['Content_type']; if (!$content_type) $content_type = NULL; @@ -694,12 +702,12 @@ function PMA_BS_CreateReferenceLink($bs_reference, $db_name) break; // audio content case 'audio/mpeg': - $output .= ' (' . $GLOBALS['strPlayAudio']. ')'; + $output .= ' (' . $GLOBALS['strPlayAudio']. ')'; break; // video content case 'application/x-flash-video': case 'video/mpeg': - $output .= ' (' . $GLOBALS['strViewVideo'] . ')'; + $output .= ' (' . $GLOBALS['strViewVideo'] . ')'; break; // unsupported content. specify download default: diff --git a/libraries/common.inc.php b/libraries/common.inc.php index cc69413e4..2d4c64775 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -411,7 +411,7 @@ if (! PMA_isValid($_REQUEST['token']) || $_SESSION[' PMA_token '] != $_REQUEST[' /* Possible login form */ 'pma_servername', 'pma_username', 'pma_password', /* rajk - for playing blobstreamable media */ - 'media_type', 'bs_reference', + 'media_type', 'custom_type', 'bs_reference', /* rajk - for changing BLOB repository file MIME type */ 'bs_db', 'bs_table', 'bs_ref', 'bs_new_mime_type' );