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
;
12 use PhpMyAdmin\Di\Container
;
14 use PhpMyAdmin\Response
;
16 if (! defined('ROOT_PATH')) {
17 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
23 require_once ROOT_PATH
. 'libraries/common.inc.php';
25 $container = Container
::getDefaultContainer();
26 $container->set(Response
::class, Response
::getInstance());
28 /** @var Response $response */
29 $response = $container->get(Response
::class);
31 /** @var DatabaseInterface $dbi */
32 $dbi = $container->get(DatabaseInterface
::class);
36 /* Check parameters */
37 PhpMyAdmin\Util
::checkParameters(
45 if (! $dbi->selectDb($db)) {
46 PhpMyAdmin\Util
::mysqlDie(
47 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
53 /* Check if table exists */
54 if (! $dbi->getColumns($db, $table)) {
55 PhpMyAdmin\Util
::mysqlDie(__('Invalid table name'));
59 $sql = 'SELECT ' . PhpMyAdmin\Util
::backquote($_GET['transform_key'])
60 . ' FROM ' . PhpMyAdmin\Util
::backquote($table)
61 . ' WHERE ' . $_GET['where_clause'] . ';';
62 $result = $dbi->fetchValue($sql);
64 /* Check return code */
65 if ($result === false) {
66 PhpMyAdmin\Util
::mysqlDie(
67 __('MySQL returned an empty result set (i.e. zero rows).'),
72 /* Avoid corrupting data */
73 ini_set('url_rewriter.tags', '');
76 $table . '-' . $_GET['transform_key'] . '.bin',
77 Mime
::detect($result),