BLOB streaming documentation
[phpmyadmin/crack.git] / libraries / blobstreaming.lib.php
blobd8616e9ff88a0f28926886a99009b80e75f4fdea
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * @author Raj Kissu Rajandran
5 * @version 1.0
6 * @package BLOBStreaming
7 */
9 /**
10 * checks whether the necessary plugins for BLOBStreaming exist
12 * @access public
13 * @uses PMA_Config::get()
14 * @uses PMA_Config::settings()
15 * @uses PMA_Config::set()
16 * @uses PMA_PluginsExist()
17 * @uses PMA_BS_SetVariables()
18 * @uses PMA_BS_GetVariables()
19 * @uses PMA_BS_SetFieldReferences()
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;
31 // retrieve current server configuration
32 $serverCfg = $PMA_Config->get('Servers');
33 $serverCfg = $serverCfg[$GLOBALS['server']];
35 // return if unable to retrieve current server configuration
36 if (! $serverCfg)
37 return FALSE;
39 // if PHP extension in use is 'mysql', specify element 'PersistentConnections'
40 if ($serverCfg['extension'] == "mysql")
41 $serverCfg['PersistentConnections'] = $PMA_Config->settings['PersistentConnections'];
43 // if connection type is TCP, unload socket variable
44 if (strtolower($serverCfg['connect_type']) == "tcp")
45 $serverCfg['socket'] = "";
47 // define BS Plugin variables
48 $allPluginsExist = TRUE;
50 $PMA_Config->set('PBXT_NAME', 'pbxt');
51 $PMA_Config->set('PBMS_NAME', 'pbms');
53 $plugins[$PMA_Config->get('PBXT_NAME')]['Library'] = 'libpbxt.so';
54 $plugins[$PMA_Config->get('PBXT_NAME')]['Exists'] = FALSE;
56 $plugins[$PMA_Config->get('PBMS_NAME')]['Library'] = 'libpbms.so';
57 $plugins[$PMA_Config->get('PBMS_NAME')]['Exists'] = FALSE;
59 // retrieve state of BS plugins
60 PMA_PluginsExist($plugins);
62 foreach ($plugins as $plugin_key=>$plugin)
63 if (!$plugin['Exists'])
65 $allPluginsExist = FALSE;
66 break;
67 } // end if (!$plugin['Exists'])
69 // set variable indicating BS plugin existance
70 $PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', $allPluginsExist);
72 // do the plugins exist?
73 if ($allPluginsExist)
75 // retrieve BS variables from PMA configuration
76 $bs_set_variables = array();
78 $bs_set_variables[$PMA_Config->get('PBMS_NAME') . '_garbage_threshold'] = (isset($serverCfg['bs_garbage_threshold'])) ? $server['bs_garbage_threshold'] : NULL;
79 $bs_set_variables[$PMA_Config->get('PBMS_NAME') . '_repository_threshold'] = (isset($serverCfg['bs_repository_threshold'])) ? $server['bs_repository_threshold'] : NULL;
80 $bs_set_variables[$PMA_Config->get('PBMS_NAME') . '_temp_blob_timeout'] = (isset($serverCfg['bs_temp_blob_timeout'])) ? $server['bs_temp_blob_timeout'] : NULL;
81 $bs_set_variables[$PMA_Config->get('PBMS_NAME') . '_temp_log_threshold'] = (isset($serverCfg['bs_temp_log_threshold'])) ? $server['bs_temp_log_threshold'] : NULL;
83 // set BS variables to PMA configuration defaults
84 PMA_BS_SetVariables($bs_set_variables);
86 // retrieve updated BS variables (configurable and unconfigurable)
87 $bs_variables = PMA_BS_GetVariables();
89 // if no BS variables exist, set plugin existance to false and return
90 if (count($bs_variables) <= 0)
92 $PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', FALSE);
93 return FALSE;
94 } // end if (count($bs_variables) <= 0)
96 // switch on BS field references
97 if (strtolower($bs_variables[$PMA_Config->get('PBMS_NAME') . '_field_references']) == "off")
98 PMA_BS_SetFieldReferences('ON');
100 // get BS server port
101 $BS_PORT = $bs_variables[$PMA_Config->get('PBMS_NAME') . '_port'];
103 // if no BS server port exists, set plugin existance to false and return
104 if (!$BS_PORT)
106 $PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', FALSE);
107 return FALSE;
108 } // end if (!$BS_PORT)
110 // add selected BS, CURL and fileinfo library variables to PMA configuration
111 $PMA_Config->set('BLOBSTREAMING_PORT', $BS_PORT);
112 $PMA_Config->set('BLOBSTREAMING_HOST', $serverCfg['host']);
113 $PMA_Config->set('BLOBSTREAMING_SERVER', $serverCfg['host'] . ':' . $BS_PORT);
114 $PMA_Config->set('CURL_EXISTS', FALSE);
115 $PMA_Config->set('FILEINFO_EXISTS', FALSE);
117 // check if CURL exists
118 if (function_exists("curl_init"))
120 // initialize curl handler
121 $curlHnd = curl_init();
123 // CURL exists, set necessary variable and close resource
124 if (!empty($curlHnd))
126 $PMA_Config->set('CURL_EXISTS', TRUE);
127 curl_close($curlHnd);
128 } // end if (!empty($curlHnd))
129 } // end if (function_exists("curl_init"))
131 // check if PECL's fileinfo library exist
132 $finfo = NULL;
134 if (function_exists("finfo_open"))
135 $finfo = finfo_open(FILEINFO_MIME);
137 // fileinfo library exists, set necessary variable and close resource
138 if (!empty($finfo))
140 $PMA_Config->set('FILEINFO_EXISTS', TRUE);
141 finfo_close($finfo);
142 } // end if (!empty($finfo))
143 } // end if ($allPluginsExist)
144 else
145 return FALSE;
147 $bs_tables = array();
149 // specify table structure for BS reference table
150 $bs_tables[$PMA_Config->get('PBMS_NAME') . '_reference'] = array();
151 $bs_tables[$PMA_Config->get('PBMS_NAME') . '_reference']['struct'] = <<<EOD
152 CREATE TABLE {$PMA_Config->get('PBMS_NAME')}_reference
154 Table_name CHAR(64) COMMENT 'The name of the referencing table',
155 Blob_id BIGINT COMMENT 'The BLOB reference number - part of the BLOB URL',
156 Column_name CHAR(64) COMMENT 'The column name of the referencing field',
157 Row_condition VARCHAR(255) COMMENT 'This condition identifies the row in the table',
158 Blob_url VARCHAR(200) COMMENT 'The BLOB URL for HTTP GET access',
159 Repository_id INT COMMENT 'The repository file number of the BLOB',
160 Repo_blob_offset BIGINT COMMENT 'The offset in the repository file',
161 Blob_size BIGINT COMMENT 'The size of the BLOB in bytes',
162 Deletion_time TIMESTAMP COMMENT 'The time the BLOB was deleted',
163 Remove_in INT COMMENT 'The number of seconds before the reference/BLOB is removed perminently',
164 Temp_log_id INT COMMENT 'Temporary log number of the referencing deletion entry',
165 Temp_log_offset BIGINT COMMENT 'Temporary log offset of the referencing deletion entry'
166 ) ENGINE=PBMS;
167 EOD;
169 // specify table structure for BS repository table
170 $bs_tables[$PMA_Config->get('PBMS_NAME') . '_repository'] = array();
171 $bs_tables[$PMA_Config->get('PBMS_NAME') . '_repository']['struct'] = <<<EOD
172 CREATE TABLE {$PMA_Config->get('PBMS_NAME')}_repository
174 Repository_id INT COMMENT 'The repository file number',
175 Repo_blob_offset BIGINT COMMENT 'The offset of the BLOB in the repository file',
176 Blob_size BIGINT COMMENT 'The size of the BLOB in bytes',
177 Head_size SMALLINT UNSIGNED COMMENT 'The size of the BLOB header - proceeds the BLOB data',
178 Access_code INT COMMENT 'The 4-byte authorisation code required to access the BLOB - part of the BLOB URL',
179 Creation_time TIMESTAMP COMMENT 'The time the BLOB was created',
180 Last_ref_time TIMESTAMP COMMENT 'The last time the BLOB was referenced',
181 Last_access_time TIMESTAMP COMMENT 'The last time the BLOB was accessed (read)',
182 Content_type CHAR(128) COMMENT 'The content type of the BLOB - returned by HTTP GET calls',
183 Blob_data LONGBLOB COMMENT 'The data of this BLOB'
184 ) ENGINE=PBMS;
185 EOD;
187 // specify table structure for BS custom content type table
188 $bs_tables[$PMA_Config->get('PBMS_NAME') . '_custom_content_type'] = array();
189 $bs_tables[$PMA_Config->get('PBMS_NAME') . '_custom_content_type']['struct'] = <<<EOD
190 CREATE TABLE {$PMA_Config->get('PBMS_NAME')}_custom_content_type
192 Blob_url VARCHAR(200) COMMENT 'The BLOB URL for HTTP GET access',
193 Content_type VARCHAR(255) COMMENT 'The custom MIME type for a given BLOB reference as specified by the user',
195 PRIMARY KEY(Blob_url)
197 EOD;
199 // add BS tables to PMA configuration
200 $PMA_Config->set('BLOBSTREAMING_TABLES', $bs_tables);
202 return TRUE;
206 * checks for databases that support BLOBStreaming
208 * @access public
209 * @uses PMA_GetDatabases()
210 * @uses PMA_TablesExist()
211 * @uses PMA_Config::set()
213 function checkBLOBStreamableDatabases()
215 // load PMA configuration
216 $PMA_Config = $_SESSION['PMA_Config'];
218 // return if unable to load PMA configuration
219 if (empty($PMA_Config))
220 return;
222 // retrieve BS tables from PMA configuration
223 $session_bs_tables = $PMA_Config->get('BLOBSTREAMING_TABLES');
225 $bs_databases = array();
226 $bs_tables = array();
228 // return if BS tables do not exist
229 if (!$session_bs_tables)
230 return;
232 foreach ($session_bs_tables as $table_key=>$table)
234 $bs_tables[$table_key] = array();
235 $bs_tables[$table_key]['Exists'] = FALSE;
238 // retrieve MySQL databases
239 $databases = PMA_GetDatabases();
241 // check if BS tables exist for each database
242 foreach ($databases as $db_key=>$db_name)
244 $bs_databases[$db_name] = $bs_tables;
246 PMA_TablesExist($bs_databases[$db_name], $db_name);
249 // set BS databases in PMA configuration
250 $PMA_Config->set('BLOBSTREAMABLE_DATABASES', $bs_databases);
254 * checks whether a set of plugins exist
256 * @access public
257 * @param array - a list of plugin names and accompanying library filenames to check for
258 * @uses PMA_DBI_query()
259 * @uses PMA_DBI_fetch_assoc()
261 function PMA_PluginsExist(&$plugins)
263 if (PMA_MYSQL_INT_VERSION < 50109) {
264 return;
266 // run query to retrieve MySQL plugins
267 $query = "SHOW PLUGINS";
268 $result = PMA_DBI_query($query);
270 // while there are records to parse
271 while ($data = @PMA_DBI_fetch_assoc($result))
273 // reset plugin state
274 $state = TRUE;
276 // check if required plugins exist
277 foreach ($plugins as $plugin_key=>$plugin)
278 if (!$plugin['Exists'])
279 if (
280 strtolower($data['Library']) == strtolower($plugin['Library']) &&
281 $data['Status'] == "ACTIVE"
283 $plugins[$plugin_key]['Exists'] = TRUE;
284 else
285 if ($state)
286 $state = FALSE;
288 // break if all necessary plugins are found before all records are parsed
289 if ($state)
290 break;
291 } // end while ($data = @PMA_DBI_fetch_assoc($result))
295 * checks whether a given set of tables exist in a given database
297 * @access public
298 * @param array - list of tables to look for
299 * @param string - name of database
300 * @uses PMA_DBI_select_db()
301 * @uses PMA_DBI_query()
302 * @uses PMA_DBI_fetch_assoc()
304 function PMA_TablesExist(&$tables, $db_name)
306 // select specified database
307 PMA_DBI_select_db($db_name);
309 // run query to retrieve tables in specified database
310 $query = "SHOW TABLES";
311 $result = PMA_DBI_query($query);
313 // while there are records to parse
314 while ($data = @PMA_DBI_fetch_assoc($result))
316 $state = TRUE;
318 // check if necessary tables exist
319 foreach ($tables as $table_key=>$table)
320 if (!$table['Exists'])
321 if ($data['Tables_in_' . $db_name] == $table_key)
322 $tables[$table_key]['Exists'] = TRUE;
323 else
324 if ($state)
325 $state = FALSE;
327 // break if necessary tables are found before all records are parsed
328 if ($state)
329 break;
330 } // end while ($data = @PMA_DBI_fetch_assoc($result))
334 * returns a list of databases
336 * @access public
337 * @uses PMA_DBI_query()
338 * @uses PMA_DBI_fetch_assoc()
339 * @return array - list of databases acquired via MySQL
341 function PMA_GetDatabases()
343 // run query to retrieve databases
344 $query = "SHOW DATABASES";
345 $result = PMA_DBI_query($query);
347 $databases = array();
349 // while there are records to parse
350 while ($data = @PMA_DBI_fetch_assoc($result))
351 $databases[] = $data['Database'];
353 // return list of databases
354 return $databases;
358 * sets BLOBStreaming variables to a list of specified arguments
359 * @access public
360 * @uses PMA_DBI_query()
361 * @returns boolean - success of variables setup
364 function PMA_BS_SetVariables($bs_variables)
366 // if no variables exist in array, return false
367 if (empty($bs_variables) || count($bs_variables) == 0)
368 return FALSE;
370 // set BS variables to those specified in array
371 foreach ($bs_variables as $key=>$val)
372 if (!is_null($val) && strlen($val) > 0)
374 // set BS variable to specified value
375 $query = "SET GLOBAL $key=" . PMA_sqlAddSlashes($val);
376 $result = PMA_DBI_query($query);
378 // if query fails execution, return false
379 if (!$result)
380 return FALSE;
381 } // end if (!is_null($val) && strlen($val) > 0)
383 // return true on success
384 return TRUE;
388 * returns a list of BLOBStreaming variables used by MySQL
390 * @access public
391 * @uses PMA_Config::get()
392 * @uses PMA_DBI_query()
393 * @uses PMA_DBI_fetch_assoc()
394 * @return array - list of BLOBStreaming variables
396 function PMA_BS_GetVariables()
398 // load PMA configuration
399 $PMA_Config = $_SESSION['PMA_Config'];
401 // return if unable to load PMA configuration
402 if (empty($PMA_Config))
403 return NULL;
405 // run query to retrieve BS variables
406 $query = "SHOW VARIABLES LIKE '%" . $PMA_Config->get('PBMS_NAME') . "%'";
407 $result = PMA_DBI_query($query);
409 $BS_Variables = array();
411 // while there are records to retrieve
412 while ($data = @PMA_DBI_fetch_assoc($result))
413 $BS_Variables[$data['Variable_name']] = $data['Value'];
415 // return BS variables
416 return $BS_Variables;
420 * sets the BLOBStreaming global field references to ON/OFF
422 * @access public
423 * @param string - ON or OFF
424 * @uses PMA_Config::get()
425 * @uses PMA_sqlAddslashes()
426 * @uses PMA_DBI_query()
427 * @return boolean - success/failure of query execution
429 function PMA_BS_SetFieldReferences($val)
431 // load PMA configuration
432 $PMA_Config = $_SESSION['PMA_Config'];
434 // return if unable to load PMA configuration
435 if (empty($PMA_Config))
436 return FALSE;
438 // set field references to value specified
439 $query = "SET GLOBAL " . $PMA_Config->get('PBMS_NAME') . "_field_references=" . PMA_sqlAddslashes($val);
440 $result = PMA_DBI_query($query);
442 // return success of query execution
443 if ($result)
444 return TRUE;
445 else
446 return FALSE;
450 * gets the SQL table definition for a given BLOBStreaming table
452 * @access public
453 * @param string - table name
454 * @uses PMA_Config::get()
455 * @return string - SQL table definition
457 function PMA_BS_GetTableStruct($tbl_name)
459 // retrieve table structures for BS tables
460 $bs_tables = $_SESSION['PMA_Config']->get('BLOBSTREAMING_TABLES');
462 // return if tables don't exist
463 if (!$bs_tables)
464 return;
466 // return if specified table doesn't exist in collection of BS tables
467 if (!isset($bs_tables[$tbl_name]))
468 return;
470 // return specified table's structure
471 return $bs_tables[$tbl_name]['struct'];
475 * creates the BLOBStreaming tables for a given database
477 * @access public
478 * @param string - database name
479 * @uses PMA_Config::get()
480 * @uses PMA_DBI_select_db()
481 * @uses PMA_DBI_query()
482 * @uses PMA_BS_GetTableStruct()
483 * @return boolean - success/failure of transactional query execution
485 function PMA_BS_CreateTables($db_name)
487 // retrieve BS tables
488 $bs_tables = $_SESSION['PMA_Config']->get('BLOBSTREAMING_TABLES');
490 // select specified database
491 PMA_DBI_select_db($db_name);
493 // create necessary BS tables for specified database
494 foreach ($bs_tables as $table_key=>$table)
496 $result = PMA_DBI_query(PMA_BS_GetTableStruct($table_key));
498 // return false if query execution fails
499 if (!$result)
500 return FALSE;
503 // return true on success
504 return TRUE;
508 * drops BLOBStreaming tables for a given database
510 * @access public
511 * @param string - database name
512 * @uses PMA_Config::get()
513 * @uses PMA_DBI_select_db()
514 * @uses PMA_backquote()
515 * @uses PMA_DBI_query()
516 * @return boolean - success/failure of transactional query execution
518 function PMA_BS_DropTables($db_name)
520 // load PMA configuration
521 $PMA_Config = $_SESSION['PMA_Config'];
523 // return if unable to load PMA configuration
524 if (empty($PMA_Config))
525 return FALSE;
527 // retrieve BS tables
528 $bs_tables = $PMA_Config->get('BLOBSTREAMING_TABLES');
530 // select specified database
531 PMA_DBI_select_db($db_name);
533 // drop BS tables
534 foreach ($bs_tables as $table_key=>$table)
536 $query = "DROP TABLE IF EXISTS " . PMA_backquote($table_key);
537 $result = PMA_DBI_query($query);
539 // return false if query execution fails
540 if (!$result)
541 return FALSE;
544 // return true on success
545 return TRUE;
549 * returns the field name for a primary key of a given table in a given database
551 * @access public
552 * @param string - database name
553 * @param string - table name
554 * @uses PMA_DBI_select_db()
555 * @uses PMA_backquote()
556 * @uses PMA_DBI_query()
557 * @uses PMA_DBI_fetch_assoc()
558 * @return string - field name for primary key
560 function PMA_BS_GetPrimaryField($db_name, $tbl_name)
562 // load PMA configuration
563 $PMA_Config = $_SESSION['PMA_Config'];
565 // return if unable to load PMA configuration
566 if (empty($PMA_Config))
567 return FALSE;
569 // select specified database
570 PMA_DBI_select_db($db_name);
572 // retrieve table fields
573 $query = "SHOW FULL FIELDS FROM " . PMA_backquote($tbl_name);
574 $result = PMA_DBI_query($query);
576 // while there are records to parse
577 while ($data = PMA_DBI_fetch_assoc($result))
578 if ("PRI" == $data['Key'])
579 return $data['Field'];
581 // return NULL on no primary key
582 return NULL;
586 * checks whether a BLOB reference exists in the BLOB repository
588 * @access public
589 * @param string - BLOB reference
590 * @param string - database name
591 * @uses PMA_DBI_select_db()
592 * @uses PMA_backquote()
593 * @uses PMA_Config::get()
594 * @uses PMA_sqlAddslashes()
595 * @uses PMA_DBI_query()
596 * @return boolean - existence of BLOB reference
598 function PMA_BS_ReferenceExists($bs_reference, $db_name)
600 $referenceExists = FALSE;
602 // return false on invalid BS reference
603 if (strlen ($bs_reference) < strlen ("~*$db_name/~") || "~*$db_name/~" != substr ($bs_reference, 0, strlen ($db_name) + 4))
604 return $referenceExists;
606 // load PMA configuration
607 $PMA_Config = $_SESSION['PMA_Config'];
609 // return if unable to load PMA configuration
610 if (empty($PMA_Config))
611 return $referenceExists;
613 // select specified database
614 PMA_DBI_select_db($db_name);
616 // run query on BS reference retrieval
617 $query = "SELECT * FROM " . PMA_backquote($PMA_Config->get('PBMS_NAME') . "_reference") . " WHERE Blob_url='" . PMA_sqlAddslashes($bs_reference) . "'";
618 $result = PMA_DBI_query($query);
620 // if record exists
621 if ($data = @PMA_DBI_fetch_assoc($result))
622 $referenceExists = TRUE;
624 // return reference existance
625 return $referenceExists;
629 * creates a HTTP link to a given blob reference for a given database
631 * @access public
632 * @param string - BLOB reference
633 * @param string - database name
634 * @uses PMA_Config::get()
635 * @uses PMA_DBI_select_db()
636 * @uses PMA_backquote()
637 * @uses PMA_sqlAddslashes()
638 * @uses PMA_DBI_query()
639 * @uses PMA_DBI_fetch_assoc()
640 * @return string - HTTP link or Error
642 function PMA_BS_CreateReferenceLink($bs_reference, $db_name)
644 // load PMA configuration
645 $PMA_Config = $_SESSION['PMA_Config'];
647 // return if unable to load PMA configuration
648 if (empty($PMA_Config))
649 return '';
651 // generate bs reference link
652 $bs_ref_link = 'http://' . $PMA_Config->get('BLOBSTREAMING_SERVER') . '/' . $bs_reference;
654 // select specified database
655 PMA_DBI_select_db($db_name);
657 $pbms_repo_bq = PMA_backquote($PMA_Config->get('PBMS_NAME') . "_repository");
658 $pbms_ref_bq = PMA_backquote($PMA_Config->get('PBMS_NAME') . "_reference");
659 $pbms_cust_content_bq = PMA_backquote($PMA_Config->get('PBMS_NAME') . "_custom_content_type");
661 // run query on determining specified BS reference
662 $query = "SELECT $pbms_repo_bq.Content_type, $pbms_cust_content_bq.Content_type AS Custom_type";
663 $query .= " FROM $pbms_repo_bq LEFT JOIN $pbms_ref_bq ON";
664 $query .= "$pbms_repo_bq.Repository_id=$pbms_ref_bq.Repository_id";
665 $query .= " AND $pbms_repo_bq.Blob_size=$pbms_ref_bq.Blob_size";
666 $query .= " AND $pbms_repo_bq.Repo_blob_offset=$pbms_ref_bq.Repo_blob_offset";
667 $query .= " LEFT JOIN $pbms_cust_content_bq ON $pbms_cust_content_bq.Blob_url=$pbms_ref_bq.Blob_url";
668 $query .= " WHERE $pbms_ref_bq.Blob_url='" . PMA_sqlAddslashes($bs_reference) . "'";
670 $result = PMA_DBI_query($query);
672 // if record exists
673 if ($data = @PMA_DBI_fetch_assoc($result))
675 // determine content-type for BS repository file (original or custom)
676 $is_custom_type = false;
678 if (isset($data['Custom_type']))
680 $content_type = $data['Custom_type'];
681 $is_custom_type = true;
683 else
684 $content_type = $data['Content_type'];
686 if (!$content_type)
687 $content_type = NULL;
689 $output = "<a href=\"#\" onclick=\"requestMIMETypeChange('" . urlencode($db_name) . "', '" . urlencode($GLOBALS['table']) . "', '" . urlencode($bs_reference) . "', '" . urlencode($content_type) . "')\">$content_type</a>";
691 // specify custom HTML for various content types
692 switch ($content_type)
694 // no content specified
695 case NULL:
696 $output = "NULL";
697 break;
698 // image content
699 case 'image/jpeg':
700 case 'image/png':
701 $output .= ' (<a href="' . $bs_ref_link . '" target="new">' . $GLOBALS['strViewImage'] . '</a>)';
702 break;
703 // audio content
704 case 'audio/mpeg':
705 $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>)';
706 break;
707 // video content
708 case 'application/x-flash-video':
709 case 'video/mpeg':
710 $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>)';
711 break;
712 // unsupported content. specify download
713 default:
714 $output .= ' (<a href="' . $bs_ref_link . '" target="new">' . $GLOBALS['strDownloadFile']. '</a>)';
717 // return HTML
718 return $output;
719 } // end if ($data = @PMA_DBI_fetch_assoc($result))
721 // return on error
722 return 'Error';