2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Provides download to a given field defined in parameters.
11 use PhpMyAdmin\Response
;
16 require_once 'libraries/common.inc.php';
18 // we don't want the usual PhpMyAdmin\Response-generated HTML above the column's
20 $response = Response
::getInstance();
23 /* Check parameters */
24 PhpMyAdmin\Util
::checkParameters(
29 if (!$GLOBALS['dbi']->selectDb($db)) {
30 PhpMyAdmin\Util
::mysqlDie(
31 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
36 /* Check if table exists */
37 if (!$GLOBALS['dbi']->getColumns($db, $table)) {
38 PhpMyAdmin\Util
::mysqlDie(__('Invalid table name'));
41 if (! isset($_GET['where_clause'])
42 ||
! isset($_GET['where_clause_sign'])
43 ||
! Core
::checkSqlQuerySignature($_GET['where_clause'], $_GET['where_clause_sign'])
45 /* l10n: In case a SQL query did not pass a security check */
46 Core
::fatalError(__('There is an issue with your request.'));
51 $sql = 'SELECT ' . PhpMyAdmin\Util
::backquote($_GET['transform_key'])
52 . ' FROM ' . PhpMyAdmin\Util
::backquote($table)
53 . ' WHERE ' . $_GET['where_clause'] . ';';
54 $result = $GLOBALS['dbi']->fetchValue($sql);
56 /* Check return code */
57 if ($result === false) {
58 PhpMyAdmin\Util
::mysqlDie(
59 __('MySQL returned an empty result set (i.e. zero rows).'), $sql
63 /* Avoid corrupting data */
64 ini_set('url_rewriter.tags', '');
67 $table . '-' . $_GET['transform_key'] . '.bin',
68 Mime
::detect($result),