[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_3_1-12954-g1369bf2

Michal Čihař nijel at users.sourceforge.net
Thu Aug 4 14:39:34 CEST 2011


The branch, master has been updated
       via  1369bf2c4330ebc57da869428ae747a2903642cb (commit)
       via  b4a2dc7196347d891a1b2d0a397052c1a860c3d6 (commit)
       via  bbaeb8922bcc7ee70232c375358b7fe530a11313 (commit)
       via  6196970dc26de011646a581044dbf05d95400c67 (commit)
       via  2283b016bb597ab70e557ae0f2ac18c64b473faa (commit)
       via  6ef6ab3d79e74dcd58de6207d867e20a67403701 (commit)
       via  cb337bbb02b41f4b99123dc6b9035a4ca4e0282c (commit)
       via  7281d04793978b1954128ef6f74ecddfc46f547b (commit)
       via  1a5154bd876edf2b703c7eebfa6650a4f242c33d (commit)
       via  d6c2dfb51b1a2977ad03033cdfe5c74709313f9c (commit)
       via  eeb54e007b4d51269e6d3a31578bb92ac5bae21c (commit)
       via  045f59c78a7aa74efa002b17044996309d93d41d (commit)
       via  1031bf2df83d0fc8e1a5790d6ff64448d4e4579b (commit)
       via  5b568db10fa5629ac5eea30de71b9e1dcc6e7fa7 (commit)
       via  e7db079b819461bed60cdc69a4bb972e704cc630 (commit)
       via  aa5156463bf75cfaf3a0a49deabe8cf03ae8c379 (commit)
       via  34da1ea053e35723a2d22e25360bbb6ab3866e49 (commit)
       via  c79fc30debdfc23c5d65b8a8c43f16d0899cee2e (commit)
       via  b68145bf88e607734a73bee845486635393c3d03 (commit)
       via  7afe37b0a535fa7069ac26d0e415442aada65bf6 (commit)
       via  69a69a5fb85742c026cb3b42cbde8c63939057b8 (commit)
       via  5d05da19f20f098bb71fad429f7ca56944a27d85 (commit)
       via  b9f1fe6bfa858f4a9ed6bef78da379e61ddf277c (commit)
       via  350157c5523d6e72f4b326c1bd8b9f31b8a5d22d (commit)
       via  66f9667a61d2fdc269cd07a5bb2ed990ab2c46cf (commit)
       via  17689a2df4a4d1239bfba8911f6badbe36ce13be (commit)
      from  b9a7ac74251c490c67dae063e3cf4bb637cce288 (commit)


- Log -----------------------------------------------------------------
commit 1369bf2c4330ebc57da869428ae747a2903642cb
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:38:59 2011 +0200

    Document weirdness

commit b4a2dc7196347d891a1b2d0a397052c1a860c3d6
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:38:07 2011 +0200

    Use new function for download headers

commit bbaeb8922bcc7ee70232c375358b7fe530a11313
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:37:42 2011 +0200

    Use new function for download headers

commit 6196970dc26de011646a581044dbf05d95400c67
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:36:01 2011 +0200

    Use new function for no cache headers

commit 2283b016bb597ab70e557ae0f2ac18c64b473faa
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:35:36 2011 +0200

    Use HTTP/1.1 for all browsers

commit 6ef6ab3d79e74dcd58de6207d867e20a67403701
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:33:11 2011 +0200

    Add some comments

commit cb337bbb02b41f4b99123dc6b9035a4ca4e0282c
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:32:02 2011 +0200

    Use new function for no cache headers

commit 7281d04793978b1954128ef6f74ecddfc46f547b
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:31:32 2011 +0200

    Factor out no caching headers

commit 1a5154bd876edf2b703c7eebfa6650a4f242c33d
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:29:56 2011 +0200

    Use new function for download headers

commit d6c2dfb51b1a2977ad03033cdfe5c74709313f9c
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:28:23 2011 +0200

    Use new function for download headers

commit eeb54e007b4d51269e6d3a31578bb92ac5bae21c
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:27:44 2011 +0200

    Use new function for download headers

commit 045f59c78a7aa74efa002b17044996309d93d41d
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:26:47 2011 +0200

    Use new function for download headers

commit 1031bf2df83d0fc8e1a5790d6ff64448d4e4579b
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:25:45 2011 +0200

    Use new function for download headers

commit 5b568db10fa5629ac5eea30de71b9e1dcc6e7fa7
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:24:57 2011 +0200

    Use new function for download headers

commit e7db079b819461bed60cdc69a4bb972e704cc630
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:24:15 2011 +0200

    Use predefined PHP constant for date instead of manually defining format

commit aa5156463bf75cfaf3a0a49deabe8cf03ae8c379
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:22:41 2011 +0200

    Allow spaces in filename

commit 34da1ea053e35723a2d22e25360bbb6ab3866e49
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:22:05 2011 +0200

    Use new function for download headers

commit c79fc30debdfc23c5d65b8a8c43f16d0899cee2e
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:21:27 2011 +0200

    Use new function for download headers

commit b68145bf88e607734a73bee845486635393c3d03
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:21:01 2011 +0200

    Use new function for download headers

commit 7afe37b0a535fa7069ac26d0e415442aada65bf6
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:20:32 2011 +0200

    Use new function for download headers

commit 69a69a5fb85742c026cb3b42cbde8c63939057b8
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:19:53 2011 +0200

    Use new function for download headers

commit 5d05da19f20f098bb71fad429f7ca56944a27d85
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:19:07 2011 +0200

    Use new function for download headers

commit b9f1fe6bfa858f4a9ed6bef78da379e61ddf277c
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:18:32 2011 +0200

    Include no caching headers

commit 350157c5523d6e72f4b326c1bd8b9f31b8a5d22d
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:17:18 2011 +0200

    Use generic function for download headers

commit 66f9667a61d2fdc269cd07a5bb2ed990ab2c46cf
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:17:07 2011 +0200

    Generic function for sending download headers

commit 17689a2df4a4d1239bfba8911f6badbe36ce13be
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 4 14:12:09 2011 +0200

    Coding style

-----------------------------------------------------------------------

Summary of changes:
 bs_disp_as_mime_type.php                         |    9 +----
 export.php                                       |   20 +----------
 file_echo.php                                    |   29 ++++++---------
 import_status.php                                |    3 +-
 libraries/core.lib.php                           |   43 +++++++++++++++++++++-
 libraries/gis/pma_gis_visualization.php          |   11 +-----
 libraries/header_http.inc.php                    |    5 +--
 libraries/schema/Dia_Relation_Schema.class.php   |    3 +-
 libraries/schema/Eps_Relation_Schema.class.php   |    3 +-
 libraries/schema/Pdf_Relation_Schema.class.php   |    4 +--
 libraries/schema/Svg_Relation_Schema.class.php   |    3 +-
 libraries/schema/Visio_Relation_Schema.class.php |    3 +-
 prefs_manage.php                                 |    4 +--
 setup/config.php                                 |    3 +-
 show_config_errors.php                           |    5 +--
 tbl_get_field.php                                |   14 +-------
 tbl_tracking.php                                 |   25 ++++---------
 transformation_wrapper.php                       |   11 +++---
 webapp.php                                       |    3 +-
 19 files changed, 83 insertions(+), 118 deletions(-)

diff --git a/bs_disp_as_mime_type.php b/bs_disp_as_mime_type.php
index 9ec0ec5..fd75c4d 100644
--- a/bs_disp_as_mime_type.php
+++ b/bs_disp_as_mime_type.php
@@ -43,14 +43,7 @@ if ($fHnd === false) {
 
 $f_size = $hdrs['Content-Length'];
 
-header("Expires: 0");
-header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
-header("Cache-Control: no-store, no-cache, must-revalidate");
-header("Cache-Control: post-check=0, pre-check=0", false);
-header("Pragma: no-cache");
-header("Content-type: $c_type");
-header('Content-length: ' . $f_size);
-header("Content-disposition: attachment; filename=" . basename($filename));
+PMA_download_header(basename($filename), $c_type, true, $f_size);
 
 $pos = 0;
 $content = "";
diff --git a/export.php b/export.php
index d7c2f87..3678924 100644
--- a/export.php
+++ b/export.php
@@ -347,25 +347,7 @@ if (!$save_on_server) {
         // this was reported to happen under Plesk)
         @ini_set('url_rewriter.tags','');
 
-        header('Content-Type: ' . $mime_type);
-        header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
-        // Tested behavior of
-        //       IE 5.50.4807.2300
-        //       IE 6.0.2800.1106 (small glitch, asks twice when I click Open)
-        //       IE 6.0.2900.2180
-        //       Firefox 1.0.6
-        // in http and https
-        header('Content-Disposition: attachment; filename="' . $filename . '"');
-        if (PMA_USR_BROWSER_AGENT == 'IE') {
-            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
-            header('Pragma: public');
-        } else {
-            header('Pragma: no-cache');
-            // test case: exporting a database into a .gz file with Safari
-            // would produce files not having the current time
-            // (added this header for Safari but should not harm other browsers)
-            header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
-        }
+        PMA_download_header($filename, $mime_type);
     } else {
         // HTML
         if ($export_type == 'database') {
diff --git a/file_echo.php b/file_echo.php
index da8baa0..d2f7257 100644
--- a/file_echo.php
+++ b/file_echo.php
@@ -1,7 +1,8 @@
 <?php
 /* vim: set expandtab sw=4 ts=4 sts=4: */
 /**
- * "Echo" service to allow force downloading of exported charts (png or svg) and server status monitor settings
+ * "Echo" service to allow force downloading of exported charts (png or svg)
+ * and server status monitor settings
  *
  * @package phpMyAdmin
  */
@@ -11,23 +12,27 @@ require_once './libraries/common.inc.php';
 if(isset($_REQUEST['filename']) && isset($_REQUEST['image'])) {
     $allowed = Array( 'image/png'=>'png', 'image/svg+xml'=>'svg');
 
-    if (! isset($allowed[$_REQUEST['type']])) exit('Invalid export type');
+    if (! isset($allowed[$_REQUEST['type']])) {
+        exit('Invalid export type');
+    }
 
-    if (! preg_match("/(".implode("|",$allowed).")$/i", $_REQUEST['filename']))
+    if (! preg_match("/(".implode("|",$allowed).")$/i", $_REQUEST['filename'])) {
         $_REQUEST['filename'] .= '.' . $allowed[$_REQUEST['type']];
+    }
 
-    downloadHeader($_REQUEST['filename'],$_REQUEST['type']);
+    PMA_download_header($_REQUEST['filename'], $_REQUEST['type']);
 
-    if ($allowed[$_REQUEST['type']] != 'svg')
+    if ($allowed[$_REQUEST['type']] != 'svg') {
         echo base64_decode(substr($_REQUEST['image'], strpos($_REQUEST['image'],',') + 1));
-    else
+    } else {
         echo $_REQUEST['image'];
+    }
 
     exit();
 }
 
 if(isset($_REQUEST['monitorconfig'])) {
-    downloadHeader('monitor.cfg','application/force-download');
+    PMA_download_header('monitor.cfg', 'application/force-download');
     echo urldecode($_REQUEST['monitorconfig']);
     exit();
 }
@@ -36,14 +41,4 @@ if(isset($_REQUEST['import'])) {
     echo '<html><body>' . file_get_contents($_FILES['file']['tmp_name']) . '</body></html>';
     exit();
 }
-
-exit('Invalid request');
-
-function downloadHeader($file,$type) {
-    header("Cache-Control: public");
-    header("Content-Description: File Transfer");
-    header("Content-Disposition: attachment; filename=".$file);
-    header("Content-Type: ".$type);
-    header("Content-Transfer-Encoding: binary");
-}
 ?>
diff --git a/import_status.php b/import_status.php
index 7c77e31..75a3361 100644
--- a/import_status.php
+++ b/import_status.php
@@ -9,8 +9,7 @@ require_once './libraries/common.inc.php';
 require_once './libraries/display_import_ajax.lib.php';
 
 // AJAX requests can't be cached!
-header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
-header("Expires: Sat, 11 Jan 1991 06:30:00 GMT"); // Date in the past
+PMA_no_cache_header();
 
 // $GLOBALS["message"] is used for asking for an import message
 if (isset($GLOBALS["message"]) && $GLOBALS["message"]) {
diff --git a/libraries/core.lib.php b/libraries/core.lib.php
index bb542ba..fd8c39a 100644
--- a/libraries/core.lib.php
+++ b/libraries/core.lib.php
@@ -224,7 +224,7 @@ function PMA_fatalError($error_message, $message_args = null)
     }
 
     require('./libraries/error.inc.php');
-    
+
     if (!defined('TESTSUITE')) {
         exit;
     }
@@ -538,6 +538,47 @@ function PMA_sendHeaderLocation($uri)
 }
 
 /**
+ * Outputs headers to prevent caching in browser (and on the way).
+ */
+function PMA_no_cache_header()
+{
+    header('Expires: ' . date(DATE_RFC1123)); // rfc2616 - Section 14.21
+    header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
+    if (PMA_USR_BROWSER_AGENT == 'IE') {
+        /* FIXME: Why is this speecial case for IE needed? */
+        header('Pragma: public');
+    } else {
+        header('Pragma: no-cache'); // HTTP/1.0
+        // test case: exporting a database into a .gz file with Safari
+        // would produce files not having the current time
+        // (added this header for Safari but should not harm other browsers)
+        header('Last-Modified: ' . date(DATE_RFC1123));
+    }
+}
+
+
+/**
+ * Sends header indicating file download.
+ *
+ * @param $filename string Filename to include in headers.
+ * @param $mimetype string MIME type to include in headers.
+ * @return nothing
+ */
+function PMA_download_header($filename, $mimetype, $avoid_cache = true, $length = 0) {
+    if ($avoid_cache) {
+        PMA_no_cache_header();
+    }
+    header('Content-Description: File Transfer');
+    header('Content-Disposition: attachment; filename="' . $filename . '"');
+    header('Content-Type: ' . $mimetype);
+    header('Content-Transfer-Encoding: binary');
+    if ($length > 0) {
+        header('Content-Length: ' . $length);
+    }
+}
+
+
+/**
  * Returns value of an element in $array given by $path.
  * $path is a string describing position of an element in an associative array,
  * eg. Servers/1/host refers to $array[Servers][1][host]
diff --git a/libraries/gis/pma_gis_visualization.php b/libraries/gis/pma_gis_visualization.php
index d8da0d7..2817a23 100644
--- a/libraries/gis/pma_gis_visualization.php
+++ b/libraries/gis/pma_gis_visualization.php
@@ -134,16 +134,7 @@ class PMA_GIS_Visualization
 
         ob_clean();
 
-        header('Content-type: ' . $type);
-        header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
-        header('Content-Disposition: Attachment;filename=' . $file_name);
-        if (PMA_USR_BROWSER_AGENT == 'IE') {
-            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
-            header('Pragma: public');
-        } else {
-            header('Pragma: no-cache');
-            header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
-        }
+        PMA_download_header($file_name, $type);
     }
 
     /**
diff --git a/libraries/header_http.inc.php b/libraries/header_http.inc.php
index f9d7d71..c30316d 100644
--- a/libraries/header_http.inc.php
+++ b/libraries/header_http.inc.php
@@ -24,10 +24,7 @@ if (!$GLOBALS['cfg']['AllowThirdPartyFraming']) {
     header('X-Frame-Options: SAMEORIGIN');
     header('X-Content-Security-Policy: allow \'self\'; options inline-script eval-script; frame-ancestors \'self\'; img-src \'self\' data:; script-src \'self\' www.phpmyadmin.net');
 }
-header('Expires: ' . $GLOBALS['now']); // rfc2616 - Section 14.21
-header('Last-Modified: ' . $GLOBALS['now']);
-header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
-header('Pragma: no-cache'); // HTTP/1.0
+PMA_no_cache_header()
 if (!defined('IS_TRANSFORMATION_WRAPPER')) {
     // Define the charset to be used
     header('Content-Type: text/html; charset=utf-8');
diff --git a/libraries/schema/Dia_Relation_Schema.class.php b/libraries/schema/Dia_Relation_Schema.class.php
index bccf214..46e07d3 100644
--- a/libraries/schema/Dia_Relation_Schema.class.php
+++ b/libraries/schema/Dia_Relation_Schema.class.php
@@ -170,8 +170,7 @@ class PMA_DIA extends XMLWriter
          if(ob_get_clean()){
             ob_end_clean();
         }
-        header('Content-type: application/x-dia-diagram');
-        header('Content-Disposition: attachment; filename="'.$fileName.'.dia"');
+        PMA_download_header($fileName . '.dia', 'application/x-dia-diagram');
         $output = $this->flush();
         print $output;
     }
diff --git a/libraries/schema/Eps_Relation_Schema.class.php b/libraries/schema/Eps_Relation_Schema.class.php
index 50ea7e3..91e4bfa 100644
--- a/libraries/schema/Eps_Relation_Schema.class.php
+++ b/libraries/schema/Eps_Relation_Schema.class.php
@@ -333,8 +333,7 @@ class PMA_EPS
         // if(ob_get_clean()){
             //ob_end_clean();
         //}
-        header('Content-type: image/x-eps');
-        header('Content-Disposition: attachment; filename="'.$fileName.'.eps"');
+        PMA_download_header($fileName . '.eps', 'image/x-eps');
         $output = $this->stringCommands;
         print $output;
     }
diff --git a/libraries/schema/Pdf_Relation_Schema.class.php b/libraries/schema/Pdf_Relation_Schema.class.php
index abdcf6c..68efc28 100644
--- a/libraries/schema/Pdf_Relation_Schema.class.php
+++ b/libraries/schema/Pdf_Relation_Schema.class.php
@@ -1068,9 +1068,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
         }
         // instead of $pdf->Output():
         $pdfData = $pdf->getPDFData();
-        header('Content-Type: application/pdf');
-        header('Content-Length: '.strlen($pdfData).'');
-        header('Content-disposition: attachment; filename="'.$filename.'"');
+        PMA_download_header($filename, 'application/pdf');
         echo $pdfData;
     }
 
diff --git a/libraries/schema/Svg_Relation_Schema.class.php b/libraries/schema/Svg_Relation_Schema.class.php
index c845efe..71f93c6 100644
--- a/libraries/schema/Svg_Relation_Schema.class.php
+++ b/libraries/schema/Svg_Relation_Schema.class.php
@@ -168,8 +168,7 @@ class PMA_SVG extends XMLWriter
     function showOutput($fileName)
     {
         //ob_get_clean();
-        header('Content-type: image/svg+xml');
-        header('Content-Disposition: attachment; filename="'.$fileName.'.svg"');
+        PMA_download_header($fileName . '.svg', 'image/svg+xml');
         $output = $this->flush();
         print $output;
     }
diff --git a/libraries/schema/Visio_Relation_Schema.class.php b/libraries/schema/Visio_Relation_Schema.class.php
index 011e73e..aa18c06 100644
--- a/libraries/schema/Visio_Relation_Schema.class.php
+++ b/libraries/schema/Visio_Relation_Schema.class.php
@@ -155,8 +155,7 @@ class PMA_VISIO extends XMLWriter
          //if(ob_get_clean()){
             //ob_end_clean();
         //}
-        header('Content-type: application/visio');
-        header('Content-Disposition: attachment; filename="'.$fileName.'.vdx"');
+        PMA_download_header($fileName . '.vdx', 'application/visio');
         $output = $this->flush();
         print $output;
     }
diff --git a/prefs_manage.php b/prefs_manage.php
index ec1b481..000cce4 100644
--- a/prefs_manage.php
+++ b/prefs_manage.php
@@ -24,9 +24,7 @@ $error = '';
 if (isset($_POST['submit_export']) && filter_input(INPUT_POST, 'export_type') == 'text_file') {
     // export to JSON file
     $filename = 'phpMyAdmin-config-' . urlencode(PMA_getenv('HTTP_HOST')) . '.json';
-    header('Content-Type: application/json');
-    header('Content-Disposition: attachment; filename="' . $filename . '"');
-    header('Expires: ' . date(DATE_RFC1123));
+    PMA_download_header($filename, 'application/json');
     $settings = PMA_load_userprefs();
     echo json_encode($settings['config_data']);
     return;
diff --git a/setup/config.php b/setup/config.php
index 5333cb0..b90d24c 100644
--- a/setup/config.php
+++ b/setup/config.php
@@ -38,8 +38,7 @@ if (PMA_ifSetOr($_POST['submit_clear'], '')) {
     //
     // Output generated config file
     //
-    header('Content-Type: text/plain');
-    header('Content-Disposition: attachment; filename="config.inc.php"');
+    PMA_download_header('config.inc.php', 'text/plain');
     echo ConfigGenerator::getConfigFile();
     exit;
 } elseif (PMA_ifSetOr($_POST['submit_save'], '')) {
diff --git a/show_config_errors.php b/show_config_errors.php
index 09a286f..e163c42 100644
--- a/show_config_errors.php
+++ b/show_config_errors.php
@@ -7,10 +7,7 @@
  */
 
 $GLOBALS['now'] = gmdate('D, d M Y H:i:s') . ' GMT';
-header('Expires: ' . $GLOBALS['now']); // rfc2616 - Section 14.21
-header('Last-Modified: ' . $GLOBALS['now']);
-header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
-header('Pragma: no-cache'); // HTTP/1.0
+PMA_no_cache_header();
 header('Content-Type: text/html; charset=utf-8');
 
 require './libraries/vendor_config.php';
diff --git a/tbl_get_field.php b/tbl_get_field.php
index a58eb51..8c6c163 100644
--- a/tbl_get_field.php
+++ b/tbl_get_field.php
@@ -37,18 +37,6 @@ if ($result === false) {
 /* Avoid corrupting data */
 @ini_set('url_rewriter.tags', '');
 
-header('Content-Type: ' . PMA_detectMIME($result));
-header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
-header('Content-Disposition: attachment; filename="' . $table . '-' .  $transform_key . '.bin"');
-if (PMA_USR_BROWSER_AGENT == 'IE') {
-    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
-    header('Pragma: public');
-} else {
-    header('Pragma: no-cache');
-    // test case: exporting a database into a .gz file with Safari
-    // would produce files not having the current time
-    // (added this header for Safari but should not harm other browsers)
-    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
-}
+PMA_download_header($table . '-' .  $transform_key . '.bin',  PMA_detectMIME($result));
 echo $result;
 ?>
diff --git a/tbl_tracking.php b/tbl_tracking.php
index e308066..445976f 100644
--- a/tbl_tracking.php
+++ b/tbl_tracking.php
@@ -112,16 +112,7 @@ if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'sqldumpfil
         $dump .= $entry['statement'];
     }
     $filename = 'log_' . htmlspecialchars($_REQUEST['table']) . '.sql';
-    header('Content-Type: text/x-sql');
-    header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
-    header('Content-Disposition: attachment; filename="' . $filename . '"');
-    if (PMA_USR_BROWSER_AGENT == 'IE') {
-        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
-        header('Pragma: public');
-    } else {
-        header('Pragma: no-cache');
-        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
-    }
+    PMA_download_header($filename, 'text/x-sql');
 
     echo $dump;
     exit();
@@ -370,14 +361,14 @@ if (isset($_REQUEST['snapshot'])) {
 if (isset($_REQUEST['report']) && (isset($_REQUEST['delete_ddlog']) || isset($_REQUEST['delete_dmlog']))) {
 
     if (isset($_REQUEST['delete_ddlog'])) {
-        
+
         // Delete ddlog row data
         $delete_id = $_REQUEST['delete_ddlog'];
-        
+
         // Only in case of valable id
         if ($delete_id == (int)$delete_id) {
             unset($data['ddlog'][$delete_id]);
-            
+
             if (PMA_Tracker::changeTrackingData($_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version'], 'DDL', $data['ddlog']))
                 $msg = PMA_Message::success(__('Tracking data definition successfully deleted'));
             else
@@ -387,14 +378,14 @@ if (isset($_REQUEST['report']) && (isset($_REQUEST['delete_ddlog']) || isset($_R
     }
 
     if (isset($_REQUEST['delete_dmlog'])) {
-        
+
         // Delete dmlog row data
         $delete_id = $_REQUEST['delete_dmlog'];
-        
+
         // Only in case of valable id
         if ($delete_id == (int)$delete_id) {
             unset($data['dmlog'][$delete_id]);
-            
+
             if (PMA_Tracker::changeTrackingData($_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version'], 'DML', $data['dmlog']))
                 $msg = PMA_Message::success(__('Tracking data manipulation successfully deleted'));
             else
@@ -403,7 +394,7 @@ if (isset($_REQUEST['report']) && (isset($_REQUEST['delete_ddlog']) || isset($_R
         }
     }
 }
- 
+
 if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
     ?>
     <h3><?php echo __('Tracking report');?>  [<a href="tbl_tracking.php?<?php echo $url_query;?>"><?php echo __('Close');?></a>]</h3>
diff --git a/transformation_wrapper.php b/transformation_wrapper.php
index f229bd3..577a435 100644
--- a/transformation_wrapper.php
+++ b/transformation_wrapper.php
@@ -61,16 +61,17 @@ if ($cfgRelation['commwork'] && $cfgRelation['mimework']) {
 require_once './libraries/header_http.inc.php';
 // [MIME]
 if (isset($ct) && !empty($ct)) {
-    $content_type = 'Content-Type: ' . $ct;
+    $mime_type = $ct;
 } else {
-    $content_type = 'Content-Type: ' . (isset($mime_map[$transform_key]['mimetype']) ? str_replace('_', '/', $mime_map[$transform_key]['mimetype']) : $default_ct) . (isset($mime_options['charset']) ? $mime_options['charset'] : '');
+    $mime_type = (isset($mime_map[$transform_key]['mimetype']) ? str_replace('_', '/', $mime_map[$transform_key]['mimetype']) : $default_ct) . (isset($mime_options['charset']) ? $mime_options['charset'] : '');
 }
-header($content_type);
 
-if (isset($cn) && !empty($cn)) {
-    header('Content-Disposition: attachment; filename=' . $cn);
+if (empty($cn)) {
+    $cn = 'download.bin';
 }
 
+PMA_download_header($mime_type, $cn);
+
 if (! isset($resize)) {
     echo $row[$transform_key];
 } else {
diff --git a/webapp.php b/webapp.php
index cdc0a87..8295efd 100644
--- a/webapp.php
+++ b/webapp.php
@@ -44,8 +44,7 @@ foreach ($parameters as $key => $value) {
     $ini_file .= $key . '=' . $value . "\n";
 }
 
-header('Content-Type: application/webapp');
-header('Content-Disposition: attachment; filename="' . $name . '"');
+PMA_download_header($name, 'application/webapp', false);
 
 $zip = new zipfile;
 $zip->setDoWrite();


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list