2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Provides download to a given field defined in parameters.
8 declare(strict_types
=1);
11 use PhpMyAdmin\DatabaseInterface
;
13 use PhpMyAdmin\Response
;
15 if (! defined('ROOT_PATH')) {
16 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
19 global $containerBuilder;
21 require_once ROOT_PATH
. 'libraries/common.inc.php';
23 /** @var Response $response */
24 $response = $containerBuilder->get(Response
::class);
26 /** @var DatabaseInterface $dbi */
27 $dbi = $containerBuilder->get(DatabaseInterface
::class);
29 /** @var string $db */
30 $db = $containerBuilder->getParameter('db');
32 /** @var string $table */
33 $table = $containerBuilder->getParameter('table');
37 /* Check parameters */
38 PhpMyAdmin\Util
::checkParameters(
46 if (! $dbi->selectDb($db)) {
47 PhpMyAdmin\Util
::mysqlDie(
48 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
54 /* Check if table exists */
55 if (! $dbi->getColumns($db, $table)) {
56 PhpMyAdmin\Util
::mysqlDie(__('Invalid table name'));
60 $sql = 'SELECT ' . PhpMyAdmin\Util
::backquote($_GET['transform_key'])
61 . ' FROM ' . PhpMyAdmin\Util
::backquote($table)
62 . ' WHERE ' . $_GET['where_clause'] . ';';
63 $result = $dbi->fetchValue($sql);
65 /* Check return code */
66 if ($result === false) {
67 PhpMyAdmin\Util
::mysqlDie(
68 __('MySQL returned an empty result set (i.e. zero rows).'),
73 /* Avoid corrupting data */
74 ini_set('url_rewriter.tags', '');
77 $table . '-' . $_GET['transform_key'] . '.bin',
78 Mime
::detect($result),