Clarify FAQ 5.18; put the vim modeline higher in the file so that it works
[phpmyadmin/crack.git] / libraries / blobstreaming.lib.php
blob94f2170ae1af974fbe4d30e800040802ad5396d5
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');
34 if (isset($serverCfg[$GLOBALS['server']]))
35 $serverCfg = $serverCfg[$GLOBALS['server']];
36 else
37 $serverCfg = null;
39 // return if unable to retrieve current server configuration
40 if (!isset($serverCfg))
41 return FALSE;
43 // if PHP extension in use is 'mysql', specify element 'PersistentConnections'
44 if (isset($serverCfg['extension']) && "mysql" == $serverCfg['extension'])
45 $serverCfg['PersistentConnections'] = $PMA_Config->settings['PersistentConnections'];
47 // if connection type is TCP, unload socket variable
48 if (isset($serverCfg['connect_type']) && "tcp" == strtolower($serverCfg['connect_type']))
49 $serverCfg['socket'] = "";
51 // define BS Plugin variables
52 $allPluginsExist = TRUE;
54 $PMA_Config->set('PBXT_NAME', 'pbxt');
55 $PMA_Config->set('PBMS_NAME', 'pbms');
57 $plugins[$PMA_Config->get('PBXT_NAME')]['Library'] = 'libpbxt.so';
58 $plugins[$PMA_Config->get('PBXT_NAME')]['Exists'] = FALSE;
60 $plugins[$PMA_Config->get('PBMS_NAME')]['Library'] = 'libpbms.so';
61 $plugins[$PMA_Config->get('PBMS_NAME')]['Exists'] = FALSE;
63 // retrieve state of BS plugins
64 PMA_PluginsExist($plugins);
66 foreach ($plugins as $plugin_key=>$plugin)
67 if (!$plugin['Exists'])
69 $allPluginsExist = FALSE;
70 break;
71 } // end if (!$plugin['Exists'])
73 // set variable indicating BS plugin existance
74 $PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', $allPluginsExist);
76 // do the plugins exist?
77 if ($allPluginsExist)
79 // retrieve BS variables from PMA configuration
80 $bs_set_variables = array();
82 $bs_set_variables[$PMA_Config->get('PBMS_NAME') . '_garbage_threshold'] = (isset($serverCfg['bs_garbage_threshold'])) ? $serverCfg['bs_garbage_threshold'] : NULL;
83 $bs_set_variables[$PMA_Config->get('PBMS_NAME') . '_repository_threshold'] = (isset($serverCfg['bs_repository_threshold'])) ? $serverCfg['bs_repository_threshold'] : NULL;
84 $bs_set_variables[$PMA_Config->get('PBMS_NAME') . '_temp_blob_timeout'] = (isset($serverCfg['bs_temp_blob_timeout'])) ? $serverCfg['bs_temp_blob_timeout'] : NULL;
85 $bs_set_variables[$PMA_Config->get('PBMS_NAME') . '_temp_log_threshold'] = (isset($serverCfg['bs_temp_log_threshold'])) ? $serverCfg['bs_temp_log_threshold'] : NULL;
87 // set BS variables to PMA configuration defaults
88 PMA_BS_SetVariables($bs_set_variables);
90 // retrieve updated BS variables (configurable and unconfigurable)
91 $bs_variables = PMA_BS_GetVariables();
93 // if no BS variables exist, set plugin existance to false and return
94 if (count($bs_variables) <= 0)
96 $PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', FALSE);
97 return FALSE;
98 } // end if (count($bs_variables) <= 0)
100 // switch on BS field references
101 if (strtolower($bs_variables[$PMA_Config->get('PBMS_NAME') . '_field_references']) == "off")
102 if(!PMA_BS_SetFieldReferences('ON'))
103 return FALSE;
105 // get BS server port
106 $BS_PORT = $bs_variables[$PMA_Config->get('PBMS_NAME') . '_port'];
108 // if no BS server port exists, set plugin existance to false and return
109 if (!$BS_PORT)
111 $PMA_Config->set('BLOBSTREAMING_PLUGINS_EXIST', FALSE);
112 return FALSE;
113 } // end if (!$BS_PORT)
115 // add selected BS, CURL and fileinfo library variables to PMA configuration
116 $PMA_Config->set('BLOBSTREAMING_PORT', $BS_PORT);
117 $PMA_Config->set('BLOBSTREAMING_HOST', $serverCfg['host']);
118 $PMA_Config->set('BLOBSTREAMING_SERVER', $serverCfg['host'] . ':' . $BS_PORT);
119 $PMA_Config->set('CURL_EXISTS', FALSE);
120 $PMA_Config->set('FILEINFO_EXISTS', FALSE);
122 // check if CURL exists
123 if (function_exists("curl_init"))
125 // initialize curl handler
126 $curlHnd = curl_init();
128 // CURL exists, set necessary variable and close resource
129 if (!empty($curlHnd))
131 $PMA_Config->set('CURL_EXISTS', TRUE);
132 curl_close($curlHnd);
133 } // end if (!empty($curlHnd))
134 } // end if (function_exists("curl_init"))
136 // check if PECL's fileinfo library exist
137 $finfo = NULL;
139 if (function_exists("finfo_open"))
140 $finfo = finfo_open(FILEINFO_MIME);
142 // fileinfo library exists, set necessary variable and close resource
143 if (!empty($finfo))
145 $PMA_Config->set('FILEINFO_EXISTS', TRUE);
146 finfo_close($finfo);
147 } // end if (!empty($finfo))
148 } // end if ($allPluginsExist)
149 else
150 return FALSE;
152 $bs_tables = array();
154 // specify table structure for BS reference table
155 $bs_tables[$PMA_Config->get('PBMS_NAME') . '_reference'] = array();
156 $bs_tables[$PMA_Config->get('PBMS_NAME') . '_reference']['struct'] = <<<EOD
157 CREATE TABLE {$PMA_Config->get('PBMS_NAME')}_reference
159 Table_name CHAR(64) COMMENT 'The name of the referencing table',
160 Blob_id BIGINT COMMENT 'The BLOB reference number - part of the BLOB URL',
161 Column_name CHAR(64) COMMENT 'The column name of the referencing field',
162 Row_condition VARCHAR(255) COMMENT 'This condition identifies the row in the table',
163 Blob_url VARCHAR(200) COMMENT 'The BLOB URL for HTTP GET access',
164 Repository_id INT COMMENT 'The repository file number of the BLOB',
165 Repo_blob_offset BIGINT COMMENT 'The offset in the repository file',
166 Blob_size BIGINT COMMENT 'The size of the BLOB in bytes',
167 Deletion_time TIMESTAMP COMMENT 'The time the BLOB was deleted',
168 Remove_in INT COMMENT 'The number of seconds before the reference/BLOB is removed perminently',
169 Temp_log_id INT COMMENT 'Temporary log number of the referencing deletion entry',
170 Temp_log_offset BIGINT COMMENT 'Temporary log offset of the referencing deletion entry'
171 ) ENGINE=PBMS;
172 EOD;
174 // specify table structure for BS repository table
175 $bs_tables[$PMA_Config->get('PBMS_NAME') . '_repository'] = array();
176 $bs_tables[$PMA_Config->get('PBMS_NAME') . '_repository']['struct'] = <<<EOD
177 CREATE TABLE {$PMA_Config->get('PBMS_NAME')}_repository
179 Repository_id INT COMMENT 'The repository file number',
180 Repo_blob_offset BIGINT COMMENT 'The offset of the BLOB in the repository file',
181 Blob_size BIGINT COMMENT 'The size of the BLOB in bytes',
182 Head_size SMALLINT UNSIGNED COMMENT 'The size of the BLOB header - proceeds the BLOB data',
183 Access_code INT COMMENT 'The 4-byte authorisation code required to access the BLOB - part of the BLOB URL',
184 Creation_time TIMESTAMP COMMENT 'The time the BLOB was created',
185 Last_ref_time TIMESTAMP COMMENT 'The last time the BLOB was referenced',
186 Last_access_time TIMESTAMP COMMENT 'The last time the BLOB was accessed (read)',
187 Content_type CHAR(128) COMMENT 'The content type of the BLOB - returned by HTTP GET calls',
188 Blob_data LONGBLOB COMMENT 'The data of this BLOB'
189 ) ENGINE=PBMS;
190 EOD;
192 // specify table structure for BS custom content type table
193 $bs_tables[$PMA_Config->get('PBMS_NAME') . '_custom_content_type'] = array();
194 $bs_tables[$PMA_Config->get('PBMS_NAME') . '_custom_content_type']['struct'] = <<<EOD
195 CREATE TABLE {$PMA_Config->get('PBMS_NAME')}_custom_content_type
197 Blob_url VARCHAR(200) COMMENT 'The BLOB URL for HTTP GET access',
198 Content_type VARCHAR(255) COMMENT 'The custom MIME type for a given BLOB reference as specified by the user',
200 PRIMARY KEY(Blob_url)
202 EOD;
204 // add BS tables to PMA configuration
205 $PMA_Config->set('BLOBSTREAMING_TABLES', $bs_tables);
207 return TRUE;
211 * checks for databases that support BLOBStreaming
213 * @access public
214 * @uses PMA_GetDatabases()
215 * @uses PMA_TablesExist()
216 * @uses PMA_Config::set()
218 function checkBLOBStreamableDatabases()
220 // load PMA configuration
221 $PMA_Config = $_SESSION['PMA_Config'];
223 // return if unable to load PMA configuration
224 if (empty($PMA_Config))
225 return;
227 // retrieve BS tables from PMA configuration
228 $session_bs_tables = $PMA_Config->get('BLOBSTREAMING_TABLES');
230 $bs_databases = array();
231 $bs_tables = array();
233 // return if BS tables do not exist
234 if (!$session_bs_tables)
235 return;
237 foreach ($session_bs_tables as $table_key=>$table)
239 $bs_tables[$table_key] = array();
240 $bs_tables[$table_key]['Exists'] = FALSE;
243 // retrieve MySQL databases
244 $databases = PMA_GetDatabases();
246 // check if BS tables exist for each database
247 foreach ($databases as $db_key=>$db_name)
249 $bs_databases[$db_name] = $bs_tables;
251 PMA_TablesExist($bs_databases[$db_name], $db_name);
254 // set BS databases in PMA configuration
255 $PMA_Config->set('BLOBSTREAMABLE_DATABASES', $bs_databases);
259 * checks whether a set of plugins exist
261 * @access public
262 * @param array - a list of plugin names and accompanying library filenames to check for
263 * @uses PMA_DBI_query()
264 * @uses PMA_DBI_fetch_assoc()
266 function PMA_PluginsExist(&$plugins)
268 if (PMA_MYSQL_INT_VERSION < 50109) {
269 return;
271 // run query to retrieve MySQL plugins
272 $query = "SHOW PLUGINS";
273 $result = PMA_DBI_query($query);
275 // while there are records to parse
276 while ($data = @PMA_DBI_fetch_assoc($result))
278 // reset plugin state
279 $state = TRUE;
281 // check if required plugins exist
282 foreach ($plugins as $plugin_key=>$plugin)
283 if (!$plugin['Exists'])
284 if (
285 strtolower($data['Library']) == strtolower($plugin['Library']) &&
286 $data['Status'] == "ACTIVE"
288 $plugins[$plugin_key]['Exists'] = TRUE;
289 else
290 if ($state)
291 $state = FALSE;
293 // break if all necessary plugins are found before all records are parsed
294 if ($state)
295 break;
296 } // end while ($data = @PMA_DBI_fetch_assoc($result))
300 * checks whether a given set of tables exist in a given database
302 * @access public
303 * @param array - list of tables to look for
304 * @param string - name of database
305 * @uses PMA_DBI_select_db()
306 * @uses PMA_DBI_query()
307 * @uses PMA_DBI_fetch_assoc()
309 function PMA_TablesExist(&$tables, $db_name)
311 // select specified database
312 PMA_DBI_select_db($db_name);
314 // run query to retrieve tables in specified database
315 $query = "SHOW TABLES";
316 $result = PMA_DBI_query($query);
318 // while there are records to parse
319 while ($data = @PMA_DBI_fetch_assoc($result))
321 $state = TRUE;
323 // check if necessary tables exist
324 foreach ($tables as $table_key=>$table)
325 if (!$table['Exists'])
326 if ($data['Tables_in_' . $db_name] == $table_key)
327 $tables[$table_key]['Exists'] = TRUE;
328 else
329 if ($state)
330 $state = FALSE;
332 // break if necessary tables are found before all records are parsed
333 if ($state)
334 break;
335 } // end while ($data = @PMA_DBI_fetch_assoc($result))
339 * returns a list of databases
341 * @access public
342 * @uses PMA_DBI_query()
343 * @uses PMA_DBI_fetch_assoc()
344 * @return array - list of databases acquired via MySQL
346 function PMA_GetDatabases()
348 // run query to retrieve databases
349 $query = "SHOW DATABASES";
350 $result = PMA_DBI_query($query);
352 $databases = array();
354 // while there are records to parse
355 while ($data = @PMA_DBI_fetch_assoc($result))
356 $databases[] = $data['Database'];
358 // return list of databases
359 return $databases;
363 * sets BLOBStreaming variables to a list of specified arguments
364 * @access public
365 * @uses PMA_DBI_query()
366 * @returns boolean - success of variables setup
369 function PMA_BS_SetVariables($bs_variables)
371 // if no variables exist in array, return false
372 if (empty($bs_variables) || count($bs_variables) == 0)
373 return FALSE;
375 // set BS variables to those specified in array
376 foreach ($bs_variables as $key=>$val)
377 if (!is_null($val) && strlen($val) > 0)
379 // set BS variable to specified value
380 $query = "SET GLOBAL $key=" . PMA_sqlAddSlashes($val);
381 $result = PMA_DBI_query($query);
383 // if query fails execution, return false
384 if (!$result)
385 return FALSE;
386 } // end if (!is_null($val) && strlen($val) > 0)
388 // return true on success
389 return TRUE;
393 * returns a list of BLOBStreaming variables used by MySQL
395 * @access public
396 * @uses PMA_Config::get()
397 * @uses PMA_DBI_query()
398 * @uses PMA_DBI_fetch_assoc()
399 * @return array - list of BLOBStreaming variables
401 function PMA_BS_GetVariables()
403 // load PMA configuration
404 $PMA_Config = $_SESSION['PMA_Config'];
406 // return if unable to load PMA configuration
407 if (empty($PMA_Config))
408 return NULL;
410 // run query to retrieve BS variables
411 $query = "SHOW VARIABLES LIKE '%" . $PMA_Config->get('PBMS_NAME') . "%'";
412 $result = PMA_DBI_query($query);
414 $BS_Variables = array();
416 // while there are records to retrieve
417 while ($data = @PMA_DBI_fetch_assoc($result))
418 $BS_Variables[$data['Variable_name']] = $data['Value'];
420 // return BS variables
421 return $BS_Variables;
425 * sets the BLOBStreaming global field references to ON/OFF
427 * @access public
428 * @param string - ON or OFF
429 * @uses PMA_Config::get()
430 * @uses PMA_sqlAddslashes()
431 * @uses PMA_DBI_query()
432 * @return boolean - success/failure of query execution
434 function PMA_BS_SetFieldReferences($val)
436 // load PMA configuration
437 $PMA_Config = $_SESSION['PMA_Config'];
439 // return if unable to load PMA configuration
440 if (empty($PMA_Config))
441 return FALSE;
443 // set field references to value specified
444 $query = "SET GLOBAL " . $PMA_Config->get('PBMS_NAME') . "_field_references=" . PMA_sqlAddslashes($val);
445 $result = PMA_DBI_try_query($query, null, 0);
447 // get last known error (if applicable)
448 PMA_DBI_getError();
450 // return success of query execution
451 if ($result && 0 == $GLOBALS['errno'])
452 return TRUE;
453 else
454 return FALSE;
458 * gets the SQL table definition for a given BLOBStreaming table
460 * @access public
461 * @param string - table name
462 * @uses PMA_Config::get()
463 * @return string - SQL table definition
465 function PMA_BS_GetTableStruct($tbl_name)
467 // retrieve table structures for BS tables
468 $bs_tables = $_SESSION['PMA_Config']->get('BLOBSTREAMING_TABLES');
470 // return if tables don't exist
471 if (!$bs_tables)
472 return;
474 // return if specified table doesn't exist in collection of BS tables
475 if (!isset($bs_tables[$tbl_name]))
476 return;
478 // return specified table's structure
479 return $bs_tables[$tbl_name]['struct'];
483 * creates the BLOBStreaming tables for a given database
485 * @access public
486 * @param string - database name
487 * @uses PMA_Config::get()
488 * @uses PMA_DBI_select_db()
489 * @uses PMA_DBI_query()
490 * @uses PMA_BS_GetTableStruct()
491 * @return boolean - success/failure of transactional query execution
493 function PMA_BS_CreateTables($db_name)
495 // retrieve BS tables
496 $bs_tables = $_SESSION['PMA_Config']->get('BLOBSTREAMING_TABLES');
498 // select specified database
499 PMA_DBI_select_db($db_name);
501 // create necessary BS tables for specified database
502 foreach ($bs_tables as $table_key=>$table)
504 $result = PMA_DBI_query(PMA_BS_GetTableStruct($table_key));
506 // return false if query execution fails
507 if (!$result)
508 return FALSE;
511 // return true on success
512 return TRUE;
516 * drops BLOBStreaming tables for a given database
518 * @access public
519 * @param string - database name
520 * @uses PMA_Config::get()
521 * @uses PMA_DBI_select_db()
522 * @uses PMA_backquote()
523 * @uses PMA_DBI_query()
524 * @return boolean - success/failure of transactional query execution
526 function PMA_BS_DropTables($db_name)
528 // load PMA configuration
529 $PMA_Config = $_SESSION['PMA_Config'];
531 // return if unable to load PMA configuration
532 if (empty($PMA_Config))
533 return FALSE;
535 // retrieve BS tables
536 $bs_tables = $PMA_Config->get('BLOBSTREAMING_TABLES');
538 // select specified database
539 PMA_DBI_select_db($db_name);
541 // drop BS tables
542 foreach ($bs_tables as $table_key=>$table)
544 $query = "DROP TABLE IF EXISTS " . PMA_backquote($table_key);
545 $result = PMA_DBI_query($query);
547 // return false if query execution fails
548 if (!$result)
549 return FALSE;
552 // return true on success
553 return TRUE;
557 * returns the field name for a primary key of a given table in a given database
559 * @access public
560 * @param string - database name
561 * @param string - table name
562 * @uses PMA_DBI_select_db()
563 * @uses PMA_backquote()
564 * @uses PMA_DBI_query()
565 * @uses PMA_DBI_fetch_assoc()
566 * @return string - field name for primary key
568 function PMA_BS_GetPrimaryField($db_name, $tbl_name)
570 // load PMA configuration
571 $PMA_Config = $_SESSION['PMA_Config'];
573 // return if unable to load PMA configuration
574 if (empty($PMA_Config))
575 return FALSE;
577 // select specified database
578 PMA_DBI_select_db($db_name);
580 // retrieve table fields
581 $query = "SHOW FULL FIELDS FROM " . PMA_backquote($tbl_name);
582 $result = PMA_DBI_query($query);
584 // while there are records to parse
585 while ($data = PMA_DBI_fetch_assoc($result))
586 if ("PRI" == $data['Key'])
587 return $data['Field'];
589 // return NULL on no primary key
590 return NULL;
594 * checks whether a BLOB reference exists in the BLOB repository
596 * @access public
597 * @param string - BLOB reference
598 * @param string - database name
599 * @uses PMA_DBI_select_db()
600 * @uses PMA_backquote()
601 * @uses PMA_Config::get()
602 * @uses PMA_sqlAddslashes()
603 * @uses PMA_DBI_query()
604 * @return boolean - existence of BLOB reference
606 function PMA_BS_ReferenceExists($bs_reference, $db_name)
608 $referenceExists = FALSE;
610 // return false on invalid BS reference
611 if (strlen ($bs_reference) < strlen ("~*$db_name/~") || "~*$db_name/~" != substr ($bs_reference, 0, strlen ($db_name) + 4))
612 return $referenceExists;
614 // load PMA configuration
615 $PMA_Config = $_SESSION['PMA_Config'];
617 // return if unable to load PMA configuration
618 if (empty($PMA_Config))
619 return $referenceExists;
621 // select specified database
622 PMA_DBI_select_db($db_name);
624 // run query on BS reference retrieval
625 $query = "SELECT * FROM " . PMA_backquote($PMA_Config->get('PBMS_NAME') . "_reference") . " WHERE Blob_url='" . PMA_sqlAddslashes($bs_reference) . "'";
626 $result = PMA_DBI_query($query);
628 // if record exists
629 if ($data = @PMA_DBI_fetch_assoc($result))
630 $referenceExists = TRUE;
632 // return reference existance
633 return $referenceExists;
637 * creates a HTTP link to a given blob reference for a given database
639 * @access public
640 * @param string - BLOB reference
641 * @param string - database name
642 * @uses PMA_Config::get()
643 * @uses PMA_DBI_select_db()
644 * @uses PMA_backquote()
645 * @uses PMA_sqlAddslashes()
646 * @uses PMA_DBI_query()
647 * @uses PMA_DBI_fetch_assoc()
648 * @return string - HTTP link or Error
650 function PMA_BS_CreateReferenceLink($bs_reference, $db_name)
652 // load PMA configuration
653 $PMA_Config = $_SESSION['PMA_Config'];
655 // return if unable to load PMA configuration
656 if (empty($PMA_Config))
657 return '';
659 // generate bs reference link
660 $bs_ref_link = 'http://' . $PMA_Config->get('BLOBSTREAMING_SERVER') . '/' . $bs_reference;
662 // select specified database
663 PMA_DBI_select_db($db_name);
665 $pbms_repo_bq = PMA_backquote($PMA_Config->get('PBMS_NAME') . "_repository");
666 $pbms_ref_bq = PMA_backquote($PMA_Config->get('PBMS_NAME') . "_reference");
667 $pbms_cust_content_bq = PMA_backquote($PMA_Config->get('PBMS_NAME') . "_custom_content_type");
669 // run query on determining specified BS reference
670 $query = "SELECT $pbms_repo_bq.Content_type, $pbms_cust_content_bq.Content_type AS Custom_type";
671 $query .= " FROM $pbms_repo_bq LEFT JOIN $pbms_ref_bq ON";
672 $query .= "$pbms_repo_bq.Repository_id=$pbms_ref_bq.Repository_id";
673 $query .= " AND $pbms_repo_bq.Blob_size=$pbms_ref_bq.Blob_size";
674 $query .= " AND $pbms_repo_bq.Repo_blob_offset=$pbms_ref_bq.Repo_blob_offset";
675 $query .= " LEFT JOIN $pbms_cust_content_bq ON $pbms_cust_content_bq.Blob_url=$pbms_ref_bq.Blob_url";
676 $query .= " WHERE $pbms_ref_bq.Blob_url='" . PMA_sqlAddslashes($bs_reference) . "'";
678 $result = PMA_DBI_query($query);
680 // if record exists
681 if ($data = @PMA_DBI_fetch_assoc($result))
683 // determine content-type for BS repository file (original or custom)
684 $is_custom_type = false;
686 if (isset($data['Custom_type']))
688 $content_type = $data['Custom_type'];
689 $is_custom_type = true;
691 else
692 $content_type = $data['Content_type'];
694 if (!$content_type)
695 $content_type = NULL;
697 $output = "<a href=\"#\" onclick=\"requestMIMETypeChange('" . urlencode($db_name) . "', '" . urlencode($GLOBALS['table']) . "', '" . urlencode($bs_reference) . "', '" . urlencode($content_type) . "')\">$content_type</a>";
699 // specify custom HTML for various content types
700 switch ($content_type)
702 // no content specified
703 case NULL:
704 $output = "NULL";
705 break;
706 // image content
707 case 'image/jpeg':
708 case 'image/png':
709 $output .= ' (<a href="' . $bs_ref_link . '" target="new">' . $GLOBALS['strViewImage'] . '</a>)';
710 break;
711 // audio content
712 case 'audio/mpeg':
713 $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>)';
714 break;
715 // video content
716 case 'application/x-flash-video':
717 case 'video/mpeg':
718 $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>)';
719 break;
720 // unsupported content. specify download
721 default:
722 $output .= ' (<a href="' . $bs_ref_link . '" target="new">' . $GLOBALS['strDownloadFile']. '</a>)';
725 // return HTML
726 return $output;
727 } // end if ($data = @PMA_DBI_fetch_assoc($result))
729 // return on error
730 return 'Error';