remove todo, after upgrade PHPExcel
[phpmyadmin/arisferyanto.git] / libraries / blobstreaming.lib.php
blob3e3f632579cf6609982b9c05745ff32f2ba64bc9
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * @author Raj Kissu Rajandran and the team
5 * @package BLOBStreaming
6 */
8 /**
9 * checks whether the necessary plugins for BLOBStreaming exist
11 * @access public
12 * @uses PMA_Config::get()
13 * @uses PMA_Config::settings()
14 * @uses PMA_Config::set()
15 * @uses PMA_BS_SetVariables()
16 * @uses PMA_BS_GetVariables()
17 * @uses PMA_BS_SetFieldReferences()
18 * @uses PMA_cacheSet()
19 * @uses PMA_cacheGet()
20 * @return boolean
22 function checkBLOBStreamingPlugins()
24 // load PMA configuration
25 $PMA_Config = $_SESSION['PMA_Config'];
27 // return if unable to load PMA configuration
28 if (empty($PMA_Config)) {
29 return FALSE;
32 // At this point we might already know that plugins do not exist
33 // because this was recorded in the session (cache).
34 if (PMA_cacheGet('skip_blobstreaming', true)) {
35 return false;
38 // If we don't know that we can skip blobstreaming, we continue
39 // verifications; anyway, in case we won't skip blobstreaming,
40 // we still need to set some variables in non-persistent settings,
41 // which is done via $PMA_Config->set().
43 /** Retrieve current server configuration;
44 * at this point, $PMA_Config->get('Servers') contains the server parameters
45 * as explicitely defined in config.inc.php, so it cannot be used; it's
46 * better to use $GLOBALS['cfg']['Server'] which contains the explicit
47 * parameters merged with the default ones
50 $serverCfg = $GLOBALS['cfg']['Server'];
52 // return if unable to retrieve current server configuration
53 if (! $serverCfg) {
54 return FALSE;
57 // if PHP extension in use is 'mysql', specify element 'PersistentConnections'
58 if ($serverCfg['extension'] == "mysql") {
59 $serverCfg['PersistentConnections'] = $PMA_Config->settings['PersistentConnections'];
62 // if connection type is TCP, unload socket variable
63 if (strtolower($serverCfg['connect_type']) == "tcp") {
64 $serverCfg['socket'] = "";
67 $allPluginsExist = false;
68 if (PMA_MYSQL_INT_VERSION >= 50109) {
69 $PMA_Config->set('PBXT_NAME', 'pbxt');
70 $PMA_Config->set('PBMS_NAME', 'pbms');
72 $required_plugins[$PMA_Config->get('PBXT_NAME')]['Library'] = 'libpbxt.so';
73 $required_plugins[$PMA_Config->get('PBMS_NAME')]['Library'] = 'libpbms.so';
74 $number_of_required_plugins_found = 0;
76 // Retrieve MySQL plugins
77 $existing_plugins = PMA_DBI_fetch_result('SHOW PLUGINS');
79 foreach ($existing_plugins as $one_existing_plugin) {
80 // check if required plugins exist
81 foreach ($required_plugins as $one_required_plugin) {
82 if ( strtolower($one_existing_plugin['Library']) == strtolower($one_required_plugin['Library'])
83 && $one_existing_plugin['Status'] == "ACTIVE") {
84 $number_of_required_plugins_found++;
87 if (2 == $number_of_required_plugins_found) {
88 $allPluginsExist = true;
89 break;
92 unset($required_plugins, $existing_plugins, $one_required_plugin, $one_existing_plugin, $number_of_required_plugins_found);
95 // set variable indicating BS plugin existence
96 $PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', $allPluginsExist);
98 if ($allPluginsExist) {
99 // retrieve BS variables from PMA configuration
100 $bs_set_variables = array();
102 $bs_set_variables[$PMA_Config->get('PBMS_NAME') . '_garbage_threshold'] = (isset($serverCfg['bs_garbage_threshold'])) ? $serverCfg['bs_garbage_threshold'] : NULL;
103 $bs_set_variables[$PMA_Config->get('PBMS_NAME') . '_repository_threshold'] = (isset($serverCfg['bs_repository_threshold'])) ? $serverCfg['bs_repository_threshold'] : NULL;
104 $bs_set_variables[$PMA_Config->get('PBMS_NAME') . '_temp_blob_timeout'] = (isset($serverCfg['bs_temp_blob_timeout'])) ? $serverCfg['bs_temp_blob_timeout'] : NULL;
105 $bs_set_variables[$PMA_Config->get('PBMS_NAME') . '_temp_log_threshold'] = (isset($serverCfg['bs_temp_log_threshold'])) ? $serverCfg['bs_temp_log_threshold'] : NULL;
107 // set BS variables to PMA configuration defaults
108 PMA_BS_SetVariables($bs_set_variables);
110 // retrieve updated BS variables (configurable and unconfigurable)
111 $bs_variables = PMA_BS_GetVariables();
113 // if no BS variables exist, set plugin existence to false and return
114 if (count($bs_variables) <= 0) {
115 $PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', FALSE);
116 PMA_cacheSet('skip_blobstreaming', true, true);
117 return FALSE;
118 } // end if (count($bs_variables) <= 0)
120 // switch on BS field references
121 if (strtolower($bs_variables[$PMA_Config->get('PBMS_NAME') . '_field_references']) == "off") {
122 if (! PMA_BS_SetFieldReferences('ON')) {
123 PMA_cacheSet('skip_blobstreaming', true, true);
124 return FALSE;
128 // get BS server port
129 $BS_PORT = $bs_variables[$PMA_Config->get('PBMS_NAME') . '_port'];
131 // if no BS server port exists, set plugin existance to false and return
132 if (! $BS_PORT) {
133 $PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', FALSE);
134 PMA_cacheSet('skip_blobstreaming', true, true);
135 return FALSE;
136 } // end if (!$BS_PORT)
138 // add selected BS, CURL and fileinfo library variables to PMA configuration
139 $PMA_Config->set('BLOBSTREAMING_PORT', $BS_PORT);
140 $PMA_Config->set('BLOBSTREAMING_HOST', $serverCfg['host']);
141 $PMA_Config->set('BLOBSTREAMING_SERVER', $serverCfg['host'] . ':' . $BS_PORT);
142 $PMA_Config->set('CURL_EXISTS', FALSE);
143 $PMA_Config->set('FILEINFO_EXISTS', FALSE);
145 // check if CURL exists
146 if (function_exists("curl_init")) {
147 // initialize curl handler
148 $curlHnd = curl_init();
150 // CURL exists, set necessary variable and close resource
151 if (! empty($curlHnd)) {
152 $PMA_Config->set('CURL_EXISTS', TRUE);
153 curl_close($curlHnd);
154 } // end if (!empty($curlHnd))
155 } // end if (function_exists("curl_init"))
157 // check if PECL's fileinfo library exist
158 $finfo = NULL;
160 if (function_exists("finfo_open")) {
161 $finfo = finfo_open(FILEINFO_MIME);
164 // fileinfo library exists, set necessary variable and close resource
165 if (! empty($finfo)) {
166 $PMA_Config->set('FILEINFO_EXISTS', TRUE);
167 finfo_close($finfo);
168 } // end if (!empty($finfo))
169 } else {
170 PMA_cacheSet('skip_blobstreaming', true, true);
171 return FALSE;
172 } // end if ($allPluginsExist)
174 $bs_tables = array();
176 // specify table structure for BS reference table
177 $bs_tables[$PMA_Config->get('PBMS_NAME') . '_reference'] = array();
178 $bs_tables[$PMA_Config->get('PBMS_NAME') . '_reference']['struct'] = <<<EOD
179 CREATE TABLE {$PMA_Config->get('PBMS_NAME')}_reference
181 Table_name CHAR(64) COMMENT 'The name of the referencing table',
182 Blob_id BIGINT COMMENT 'The BLOB reference number - part of the BLOB URL',
183 Column_name CHAR(64) COMMENT 'The column name of the referencing field',
184 Row_condition VARCHAR(255) COMMENT 'This condition identifies the row in the table',
185 Blob_url VARCHAR(200) COMMENT 'The BLOB URL for HTTP GET access',
186 Repository_id INT COMMENT 'The repository file number of the BLOB',
187 Repo_blob_offset BIGINT COMMENT 'The offset in the repository file',
188 Blob_size BIGINT COMMENT 'The size of the BLOB in bytes',
189 Deletion_time TIMESTAMP COMMENT 'The time the BLOB was deleted',
190 Remove_in INT COMMENT 'The number of seconds before the reference/BLOB is removed perminently',
191 Temp_log_id INT COMMENT 'Temporary log number of the referencing deletion entry',
192 Temp_log_offset BIGINT COMMENT 'Temporary log offset of the referencing deletion entry'
193 ) ENGINE=PBMS;
194 EOD;
196 // specify table structure for BS repository table
197 $bs_tables[$PMA_Config->get('PBMS_NAME') . '_repository'] = array();
198 $bs_tables[$PMA_Config->get('PBMS_NAME') . '_repository']['struct'] = <<<EOD
199 CREATE TABLE {$PMA_Config->get('PBMS_NAME')}_repository
201 Repository_id INT COMMENT 'The repository file number',
202 Repo_blob_offset BIGINT COMMENT 'The offset of the BLOB in the repository file',
203 Blob_size BIGINT COMMENT 'The size of the BLOB in bytes',
204 Head_size SMALLINT UNSIGNED COMMENT 'The size of the BLOB header - proceeds the BLOB data',
205 Access_code INT COMMENT 'The 4-byte authorisation code required to access the BLOB - part of the BLOB URL',
206 Creation_time TIMESTAMP COMMENT 'The time the BLOB was created',
207 Last_ref_time TIMESTAMP COMMENT 'The last time the BLOB was referenced',
208 Last_access_time TIMESTAMP COMMENT 'The last time the BLOB was accessed (read)',
209 Content_type CHAR(128) COMMENT 'The content type of the BLOB - returned by HTTP GET calls',
210 Blob_data LONGBLOB COMMENT 'The data of this BLOB'
211 ) ENGINE=PBMS;
212 EOD;
214 // specify table structure for BS custom content type table
215 $bs_tables[$PMA_Config->get('PBMS_NAME') . '_custom_content_type'] = array();
216 $bs_tables[$PMA_Config->get('PBMS_NAME') . '_custom_content_type']['struct'] = <<<EOD
217 CREATE TABLE {$PMA_Config->get('PBMS_NAME')}_custom_content_type
219 Blob_url VARCHAR(200) COMMENT 'The BLOB URL for HTTP GET access',
220 Content_type VARCHAR(255) COMMENT 'The custom MIME type for a given BLOB reference as specified by the user',
222 PRIMARY KEY(Blob_url)
224 EOD;
226 // add BS tables to PMA configuration
227 $PMA_Config->set('BLOBSTREAMING_TABLES', $bs_tables);
229 return TRUE;
233 * checks for databases that support BLOBStreaming
235 * @access public
236 * @uses PMA_GetDatabases()
237 * @uses PMA_TablesExist()
238 * @uses PMA_Config::set()
240 function checkBLOBStreamableDatabases()
242 // load PMA configuration
243 $PMA_Config = $_SESSION['PMA_Config'];
245 $serverCfg = $GLOBALS['cfg']['Server'];
247 // retrieve BS tables from PMA configuration
248 $session_bs_tables = $PMA_Config->get('BLOBSTREAMING_TABLES');
250 $bs_databases = array();
251 $bs_tables = array();
253 // return if BS tables do not exist
254 if (!$session_bs_tables)
255 return;
257 foreach ($session_bs_tables as $table_key=>$table)
259 $bs_tables[$table_key] = array();
260 $bs_tables[$table_key]['Exists'] = FALSE;
263 // retrieve MySQL databases
264 $databases = PMA_GetDatabases();
266 // check if BS tables exist for each database
267 foreach ($databases as $db_key=>$db_name)
269 $bs_databases[$db_name] = $bs_tables;
271 PMA_TablesExist($bs_databases[$db_name], $db_name);
274 // set BS databases in PMA configuration
275 $PMA_Config->set('BLOBSTREAMABLE_DATABASES', $bs_databases);
281 * checks whether a given set of tables exist in a given database
283 * @access public
284 * @param array - list of tables to look for
285 * @param string - name of database
286 * @uses PMA_DBI_select_db()
287 * @uses PMA_DBI_query()
288 * @uses PMA_DBI_fetch_assoc()
290 function PMA_TablesExist(&$tables, $db_name)
292 // select specified database
293 PMA_DBI_select_db($db_name);
295 // run query to retrieve tables in specified database
296 $query = "SHOW TABLES";
297 $result = PMA_DBI_query($query);
299 // while there are records to parse
300 while ($data = @PMA_DBI_fetch_assoc($result))
302 $state = TRUE;
304 // check if necessary tables exist
305 foreach ($tables as $table_key=>$table)
306 if (!$table['Exists'])
307 if ($data['Tables_in_' . $db_name] == $table_key)
308 $tables[$table_key]['Exists'] = TRUE;
309 else
310 if ($state)
311 $state = FALSE;
313 // break if necessary tables are found before all records are parsed
314 if ($state)
315 break;
316 } // end while ($data = @PMA_DBI_fetch_assoc($result))
320 * returns a list of databases
322 * @access public
323 * @uses PMA_DBI_query()
324 * @uses PMA_DBI_fetch_assoc()
325 * @return array - list of databases acquired via MySQL
327 function PMA_GetDatabases()
329 // run query to retrieve databases
330 $query = "SHOW DATABASES";
331 $result = PMA_DBI_query($query);
333 $databases = array();
335 // while there are records to parse
336 while ($data = @PMA_DBI_fetch_assoc($result))
337 $databases[] = $data['Database'];
339 // return list of databases
340 return $databases;
344 * sets BLOBStreaming variables to a list of specified arguments
345 * @access public
346 * @uses PMA_DBI_query()
347 * @returns boolean - success of variables setup
350 function PMA_BS_SetVariables($bs_variables)
352 // if no variables exist in array, return false
353 if (empty($bs_variables) || count($bs_variables) == 0)
354 return FALSE;
356 // set BS variables to those specified in array
357 foreach ($bs_variables as $key=>$val)
358 if (!is_null($val) && strlen($val) > 0)
360 // set BS variable to specified value
361 $query = "SET GLOBAL $key=" . PMA_sqlAddSlashes($val);
362 $result = PMA_DBI_query($query);
364 // if query fails execution, return false
365 if (!$result)
366 return FALSE;
367 } // end if (!is_null($val) && strlen($val) > 0)
369 // return true on success
370 return TRUE;
374 * returns a list of BLOBStreaming variables used by MySQL
376 * @access public
377 * @uses PMA_Config::get()
378 * @uses PMA_DBI_query()
379 * @uses PMA_DBI_fetch_assoc()
380 * @return array - list of BLOBStreaming variables
382 function PMA_BS_GetVariables()
384 // load PMA configuration
385 $PMA_Config = $_SESSION['PMA_Config'];
387 // return if unable to load PMA configuration
388 if (empty($PMA_Config))
389 return NULL;
391 // run query to retrieve BS variables
392 $query = "SHOW VARIABLES LIKE '%" . $PMA_Config->get('PBMS_NAME') . "%'";
393 $result = PMA_DBI_query($query);
395 $BS_Variables = array();
397 // while there are records to retrieve
398 while ($data = @PMA_DBI_fetch_assoc($result))
399 $BS_Variables[$data['Variable_name']] = $data['Value'];
401 // return BS variables
402 return $BS_Variables;
406 * sets the BLOBStreaming global field references to ON/OFF
408 * @access public
409 * @param string - ON or OFF
410 * @uses PMA_Config::get()
411 * @uses PMA_sqlAddslashes()
412 * @uses PMA_DBI_query()
413 * @return boolean - success/failure of query execution
415 function PMA_BS_SetFieldReferences($val)
417 // load PMA configuration
418 $PMA_Config = $_SESSION['PMA_Config'];
420 // return if unable to load PMA configuration
421 if (empty($PMA_Config))
422 return FALSE;
424 // set field references to value specified
425 $query = "SET GLOBAL " . $PMA_Config->get('PBMS_NAME') . "_field_references=" . PMA_sqlAddslashes($val);
426 $result = PMA_DBI_try_query($query, null, 0);
428 // get last known error (if applicable)
429 PMA_DBI_getError();
431 // return success of query execution
432 if ($result && 0 == $GLOBALS['errno'])
433 return TRUE;
434 else
435 return FALSE;
439 * gets the SQL table definition for a given BLOBStreaming table
441 * @access public
442 * @param string - table name
443 * @uses PMA_Config::get()
444 * @return string - SQL table definition
446 function PMA_BS_GetTableStruct($tbl_name)
448 // retrieve table structures for BS tables
449 $bs_tables = $_SESSION['PMA_Config']->get('BLOBSTREAMING_TABLES');
451 // return if tables don't exist
452 if (!$bs_tables)
453 return;
455 // return if specified table doesn't exist in collection of BS tables
456 if (!isset($bs_tables[$tbl_name]))
457 return;
459 // return specified table's structure
460 return $bs_tables[$tbl_name]['struct'];
464 * creates the BLOBStreaming tables for a given database
466 * @access public
467 * @param string - database name
468 * @uses PMA_Config::get()
469 * @uses PMA_DBI_select_db()
470 * @uses PMA_DBI_query()
471 * @uses PMA_BS_GetTableStruct()
472 * @return boolean - success/failure of transactional query execution
474 function PMA_BS_CreateTables($db_name)
476 // retrieve BS tables
477 $bs_tables = $_SESSION['PMA_Config']->get('BLOBSTREAMING_TABLES');
479 // select specified database
480 PMA_DBI_select_db($db_name);
482 // create necessary BS tables for specified database
483 foreach ($bs_tables as $table_key=>$table)
485 $result = PMA_DBI_query(PMA_BS_GetTableStruct($table_key));
487 // return false if query execution fails
488 if (!$result)
489 return FALSE;
492 // return true on success
493 return TRUE;
497 * drops BLOBStreaming tables for a given database
499 * @access public
500 * @param string - database name
501 * @uses PMA_Config::get()
502 * @uses PMA_DBI_select_db()
503 * @uses PMA_backquote()
504 * @uses PMA_DBI_query()
505 * @return boolean - success/failure of transactional query execution
507 function PMA_BS_DropTables($db_name)
509 // load PMA configuration
510 $PMA_Config = $_SESSION['PMA_Config'];
512 // return if unable to load PMA configuration
513 if (empty($PMA_Config))
514 return FALSE;
516 // retrieve BS tables
517 $bs_tables = $PMA_Config->get('BLOBSTREAMING_TABLES');
519 // select specified database
520 PMA_DBI_select_db($db_name);
522 // drop BS tables
523 foreach ($bs_tables as $table_key=>$table)
525 $query = "DROP TABLE IF EXISTS " . PMA_backquote($table_key);
526 $result = PMA_DBI_query($query);
528 // return false if query execution fails
529 if (!$result)
530 return FALSE;
533 // return true on success
534 return TRUE;
538 * returns the field name for a primary key of a given table in a given database
540 * @access public
541 * @param string - database name
542 * @param string - table name
543 * @uses PMA_DBI_select_db()
544 * @uses PMA_backquote()
545 * @uses PMA_DBI_query()
546 * @uses PMA_DBI_fetch_assoc()
547 * @return string - field name for primary key
549 function PMA_BS_GetPrimaryField($db_name, $tbl_name)
551 // load PMA configuration
552 $PMA_Config = $_SESSION['PMA_Config'];
554 // return if unable to load PMA configuration
555 if (empty($PMA_Config))
556 return FALSE;
558 // select specified database
559 PMA_DBI_select_db($db_name);
561 // retrieve table fields
562 $query = "SHOW FULL FIELDS FROM " . PMA_backquote($tbl_name);
563 $result = PMA_DBI_query($query);
565 // while there are records to parse
566 while ($data = PMA_DBI_fetch_assoc($result))
567 if ("PRI" == $data['Key'])
568 return $data['Field'];
570 // return NULL on no primary key
571 return NULL;
575 * checks whether a BLOB reference exists in the BLOB repository
577 * @access public
578 * @param string - BLOB reference
579 * @param string - database name
580 * @uses PMA_DBI_select_db()
581 * @uses PMA_backquote()
582 * @uses PMA_Config::get()
583 * @uses PMA_sqlAddslashes()
584 * @uses PMA_DBI_query()
585 * @return boolean - existence of BLOB reference
587 function PMA_BS_ReferenceExists($bs_reference, $db_name)
589 $referenceExists = FALSE;
591 // return false on invalid BS reference
592 if (strlen ($bs_reference) < strlen ("~*$db_name/~") || "~*$db_name/~" != substr ($bs_reference, 0, strlen ($db_name) + 4))
593 return $referenceExists;
595 // load PMA configuration
596 $PMA_Config = $_SESSION['PMA_Config'];
598 // return if unable to load PMA configuration
599 if (empty($PMA_Config))
600 return $referenceExists;
602 // select specified database
603 PMA_DBI_select_db($db_name);
605 // run query on BS reference retrieval
606 $query = "SELECT * FROM " . PMA_backquote($PMA_Config->get('PBMS_NAME') . "_reference") . " WHERE Blob_url='" . PMA_sqlAddslashes($bs_reference) . "'";
607 $result = PMA_DBI_query($query);
609 // if record exists
610 if ($data = @PMA_DBI_fetch_assoc($result))
611 $referenceExists = TRUE;
613 // return reference existance
614 return $referenceExists;
618 * creates a HTTP link to a given blob reference for a given database
620 * @access public
621 * @param string - BLOB reference
622 * @param string - database name
623 * @uses PMA_Config::get()
624 * @uses PMA_DBI_select_db()
625 * @uses PMA_backquote()
626 * @uses PMA_sqlAddslashes()
627 * @uses PMA_DBI_query()
628 * @uses PMA_DBI_fetch_assoc()
629 * @return string - HTTP link or Error
631 function PMA_BS_CreateReferenceLink($bs_reference, $db_name)
633 // load PMA configuration
634 $PMA_Config = $_SESSION['PMA_Config'];
636 // return if unable to load PMA configuration
637 if (empty($PMA_Config))
638 return '';
640 // generate bs reference link
641 $bs_ref_link = 'http://' . $PMA_Config->get('BLOBSTREAMING_SERVER') . '/' . $bs_reference;
643 // select specified database
644 PMA_DBI_select_db($db_name);
646 $pbms_repo_bq = PMA_backquote($PMA_Config->get('PBMS_NAME') . "_repository");
647 $pbms_ref_bq = PMA_backquote($PMA_Config->get('PBMS_NAME') . "_reference");
648 $pbms_cust_content_bq = PMA_backquote($PMA_Config->get('PBMS_NAME') . "_custom_content_type");
650 // run query on determining specified BS reference
651 $query = "SELECT $pbms_repo_bq.Content_type, $pbms_cust_content_bq.Content_type AS Custom_type";
652 $query .= " FROM $pbms_repo_bq LEFT JOIN $pbms_ref_bq ON";
653 $query .= "$pbms_repo_bq.Repository_id=$pbms_ref_bq.Repository_id";
654 $query .= " AND $pbms_repo_bq.Blob_size=$pbms_ref_bq.Blob_size";
655 $query .= " AND $pbms_repo_bq.Repo_blob_offset=$pbms_ref_bq.Repo_blob_offset";
656 $query .= " LEFT JOIN $pbms_cust_content_bq ON $pbms_cust_content_bq.Blob_url=$pbms_ref_bq.Blob_url";
657 $query .= " WHERE $pbms_ref_bq.Blob_url='" . PMA_sqlAddslashes($bs_reference) . "'";
659 $result = PMA_DBI_query($query);
661 // if record exists
662 if ($data = @PMA_DBI_fetch_assoc($result))
664 // determine content-type for BS repository file (original or custom)
665 $is_custom_type = false;
667 if (isset($data['Custom_type']))
669 $content_type = $data['Custom_type'];
670 $is_custom_type = true;
672 else
673 $content_type = $data['Content_type'];
675 if (!$content_type)
676 $content_type = NULL;
678 $output = "<a href=\"#\" onclick=\"requestMIMETypeChange('" . urlencode($db_name) . "', '" . urlencode($GLOBALS['table']) . "', '" . urlencode($bs_reference) . "', '" . urlencode($content_type) . "')\">$content_type</a>";
680 // specify custom HTML for various content types
681 switch ($content_type)
683 // no content specified
684 case NULL:
685 $output = "NULL";
686 break;
687 // image content
688 case 'image/jpeg':
689 case 'image/png':
690 $output .= ' (<a href="' . $bs_ref_link . '" target="new">' . $GLOBALS['strViewImage'] . '</a>)';
691 break;
692 // audio content
693 case 'audio/mpeg':
694 $output .= ' (<a href="#" onclick="popupBSMedia(\'' . PMA_generate_common_url() . '\',\'' . urlencode($bs_reference) . '\', \'' . urlencode($content_type) . '\',' . ($is_custom_type ? 1 : 0) . ', 640, 120)">' . $GLOBALS['strPlayAudio']. '</a>)';
695 break;
696 // video content
697 case 'application/x-flash-video':
698 case 'video/mpeg':
699 $output .= ' (<a href="#" onclick="popupBSMedia(\'' . PMA_generate_common_url() . '\',\'' . urlencode($bs_reference) . '\', \'' . urlencode($content_type) . '\',' . ($is_custom_type ? 1 : 0) . ', 640, 480)">' . $GLOBALS['strViewVideo'] . '</a>)';
700 break;
701 // unsupported content. specify download
702 default:
703 $output .= ' (<a href="' . $bs_ref_link . '" target="new">' . $GLOBALS['strDownloadFile']. '</a>)';
706 // return HTML
707 return $output;
708 } // end if ($data = @PMA_DBI_fetch_assoc($result))
710 // return on error
711 return 'Error';