2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Provides download to a given field defined in parameters.
12 // we don't want the usual PMA\libraries\Response-generated HTML above the column's
14 define('PMA_BYPASS_GET_INSTANCE', 1);
15 require_once 'libraries/common.inc.php';
16 require_once 'libraries/mime.lib.php';
18 /* Check parameters */
19 PMA\libraries\Util
::checkParameters(
24 if (!$GLOBALS['dbi']->selectDb($db)) {
25 PMA\libraries\Util
::mysqlDie(
26 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
31 /* Check if table exists */
32 if (!$GLOBALS['dbi']->getColumns($db, $table)) {
33 PMA\libraries\Util
::mysqlDie(__('Invalid table name'));
37 $sql = 'SELECT ' . PMA\libraries\Util
::backquote($_GET['transform_key'])
38 . ' FROM ' . PMA\libraries\Util
::backquote($table)
39 . ' WHERE ' . $_GET['where_clause'] . ';';
40 $result = $GLOBALS['dbi']->fetchValue($sql);
42 /* Check return code */
43 if ($result === false) {
44 PMA\libraries\Util
::mysqlDie(
45 __('MySQL returned an empty result set (i.e. zero rows).'), $sql
49 /* Avoid corrupting data */
50 @ini_set
('url_rewriter.tags', '');
53 $table . '-' . $_GET['transform_key'] . '.bin',
54 PMA_detectMIME($result),
55 mb_strlen($result, '8bit')