Translated using Weblate (Breton)
[phpmyadmin.git] / tbl_get_field.php
blob37a75970da59195847e425f40f2bbda046ce82ca
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Provides download to a given field defined in parameters.
6 * @package PhpMyAdmin
7 */
9 use PhpMyAdmin\Core;
10 use PhpMyAdmin\Mime;
11 use PhpMyAdmin\Response;
13 /**
14 * Common functions.
16 require_once 'libraries/common.inc.php';
18 // we don't want the usual PhpMyAdmin\Response-generated HTML above the column's
19 // data
20 $response = Response::getInstance();
21 $response->disable();
23 /* Check parameters */
24 PhpMyAdmin\Util::checkParameters(
25 array('db', 'table')
28 /* Select database */
29 if (!$GLOBALS['dbi']->selectDb($db)) {
30 PhpMyAdmin\Util::mysqlDie(
31 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
32 '', false
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'])
44 ) {
45 /* l10n: In case a SQL query did not pass a security check */
46 Core::fatalError(__('There is an issue with your request.'));
47 exit;
50 /* Grab data */
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', '');
66 Core::downloadHeader(
67 $table . '-' . $_GET['transform_key'] . '.bin',
68 Mime::detect($result),
69 strlen($result)
71 echo $result;