Optimize PNG images with zopfli
[phpmyadmin.git] / tbl_get_field.php
blob95f8b67b4364029f088d0e70eec5d13e27173f44
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 /**
10 * Common functions.
12 // we don't want the usual PMA\libraries\Response-generated HTML above the column's
13 // data
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(
20 array('db', 'table')
23 /* Select database */
24 if (!$GLOBALS['dbi']->selectDb($db)) {
25 PMA\libraries\Util::mysqlDie(
26 sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
27 '', false
31 /* Check if table exists */
32 if (!$GLOBALS['dbi']->getColumns($db, $table)) {
33 PMA\libraries\Util::mysqlDie(__('Invalid table name'));
36 /* Grab data */
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', '');
52 PMA_downloadHeader(
53 $table . '-' . $_GET['transform_key'] . '.bin',
54 PMA_detectMIME($result),
55 strlen($result)
57 echo $result;