From d6b8d71f95b9c41b11de35a69269213e9902a5c8 Mon Sep 17 00:00:00 2001 From: Gareth Pursehouse Date: Tue, 17 May 2011 01:38:14 -0700 Subject: [PATCH 1/5] ctrl-enter in sql editor to submit query instead of having to click "go" button --- js/functions.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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(); From 39210c606d8239d3a000cb2181e11b7fe47a5284 Mon Sep 17 00:00:00 2001 From: Brian Carcich Date: Tue, 17 May 2011 15:21:15 +0200 Subject: [PATCH 2/5] Add support to output zip content on the fly. --- libraries/zip.lib.php | 68 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 14 deletions(-) diff --git a/libraries/zip.lib.php b/libraries/zip.lib.php index a8bcb98d07..081d3820fc 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,40 @@ 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 . - $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 $ctrldir; + echo $this -> eof_ctrl_dir; + echo pack('v', sizeof($this -> ctrl_dir)); // total # of entries "on this disk" + echo pack('v', sizeof($this -> ctrl_dir)); // total # of entries overall + echo pack('V', strlen($ctrldir)); // size of central dir + echo pack('V', $this -> old_offset); // offset to start of central dir + echo "\x00\x00"; // .zip file comment length + return ""; // Return empty string + + } else { // Return entire ZIP archive as string + + $data = implode('', $this -> datasec); + + return + $data . + $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 + } } // end of the 'file()' method } // end of the 'zipfile' class From c38b3ad1ce6e2012ff01d5e61d4632c12aacb418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 17 May 2011 15:21:49 +0200 Subject: [PATCH 3/5] Whitespace cleanup --- libraries/zip.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/zip.lib.php b/libraries/zip.lib.php index 081d3820fc..e3083c0c62 100644 --- a/libraries/zip.lib.php +++ b/libraries/zip.lib.php @@ -68,7 +68,7 @@ class zipfile * - 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, + * 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 * From 69f164291f8792dbf0d8641b25a08b49515fad1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 17 May 2011 15:23:08 +0200 Subject: [PATCH 4/5] Avoid duplicating code --- libraries/zip.lib.php | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/libraries/zip.lib.php b/libraries/zip.lib.php index e3083c0c62..443b173783 100644 --- a/libraries/zip.lib.php +++ b/libraries/zip.lib.php @@ -200,30 +200,20 @@ class zipfile function file() { $ctrldir = implode('', $this -> ctrl_dir); + $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 $ctrldir; - echo $this -> eof_ctrl_dir; - echo pack('v', sizeof($this -> ctrl_dir)); // total # of entries "on this disk" - echo pack('v', sizeof($this -> ctrl_dir)); // total # of entries overall - echo pack('V', strlen($ctrldir)); // size of central dir - echo pack('V', $this -> old_offset); // offset to start of central dir - echo "\x00\x00"; // .zip file comment length + echo $header; return ""; // Return empty string - } else { // Return entire ZIP archive as string - - $data = implode('', $this -> datasec); - - return - $data . - $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 + $data = implode('', $this -> datasec); + return $data . $header; } } // end of the 'file()' method From 5e557a89b7362aad1e11250659345256354389c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 17 May 2011 15:29:22 +0200 Subject: [PATCH 5/5] Create file without storing in memory --- webapp.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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(); ?>