diff --git a/js/functions.js b/js/functions.js index fd8b36bf28..570f578ba1 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1195,7 +1195,12 @@ $(document).ready(function(){ } }); - $('#sqlquery').focus(); + $('#sqlquery').focus().keydown(function (e) { + if (e.ctrlKey && e.keyCode == 13) { + $("#sqlqueryform").submit(); + } + }); + if ($('#input_username')) { if ($('#input_username').val() == '') { $('#input_username').focus(); diff --git a/libraries/zip.lib.php b/libraries/zip.lib.php index a8bcb98d07..443b173783 100644 --- a/libraries/zip.lib.php +++ b/libraries/zip.lib.php @@ -27,6 +27,13 @@ */ class zipfile { + /** + * Whether to echo zip as it's built or return as string from -> file + * + * @var boolean $doWrite + */ + var $doWrite = false; + /** * Array to store compressed data * @@ -56,6 +63,21 @@ class zipfile var $old_offset = 0; + /** + * Sets member variable this -> doWrite to true + * - Should be called immediately after class instantiantion + * - If set to true, then ZIP archive are echo'ed to STDOUT as each + * file is added via this -> addfile(), and central directories are + * echoed to STDOUT on final call to this -> file(). Also, + * this -> file() returns an empty string so it is safe to issue a + * "echo $zipfile;" command + * + * @access public + */ + function setDoWrite() { + $this -> doWrite = true; + } // end of the 'setDoWrite()' method + /** * Converts an Unix timestamp to a four byte DOS date and time format (date * in high two bytes, time in low two bytes allowing magnitude comparison). @@ -133,8 +155,12 @@ class zipfile //$fr .= pack('V', $c_len); // compressed filesize //$fr .= pack('V', $unc_len); // uncompressed filesize - // add this entry to array - $this -> datasec[] = $fr; + // echo this entry on the fly, ... + if ( $this -> doWrite) { + echo $fr; + } else { // ... OR add this entry to array + $this -> datasec[] = $fr; + } // now add to central directory record $cdrec = "\x50\x4b\x01\x02"; @@ -165,26 +191,30 @@ class zipfile /** - * Dumps out file + * Echo central dir if ->doWrite==true, else build string to return * - * @return string the zipped file + * @return string if ->doWrite {empty string} else the ZIP file contents * * @access public */ function file() { - $data = implode('', $this -> datasec); $ctrldir = implode('', $this -> ctrl_dir); - - return - $data . - $ctrldir . + $header = $ctrldir . $this -> eof_ctrl_dir . pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk" pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall pack('V', strlen($ctrldir)) . // size of central dir pack('V', strlen($data)) . // offset to start of central dir "\x00\x00"; // .zip file comment length + + if ( $this -> doWrite ) { // Send central directory & end ctrl dir to STDOUT + echo $header; + return ""; // Return empty string + } else { // Return entire ZIP archive as string + $data = implode('', $this -> datasec); + return $data . $header; + } } // end of the 'file()' method } // end of the 'zipfile' class diff --git a/webapp.php b/webapp.php index 86d6bf1c2f..cdc0a87b2b 100644 --- a/webapp.php +++ b/webapp.php @@ -44,11 +44,12 @@ foreach ($parameters as $key => $value) { $ini_file .= $key . '=' . $value . "\n"; } -$zip = new zipfile; -$zip->addFile($ini_file, 'webapp.ini'); -$zip->addFile(file_get_contents($icon), 'phpMyAdmin.ico'); - header('Content-Type: application/webapp'); header('Content-Disposition: attachment; filename="' . $name . '"'); -echo $zip->file(); + +$zip = new zipfile; +$zip->setDoWrite(); +$zip->addFile($ini_file, 'webapp.ini'); +$zip->addFile(file_get_contents($icon), 'phpMyAdmin.ico'); +$zip->file(); ?>