summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-10-02 00:08:34 +0200
committeradmin <devnull@localhost>2006-10-02 00:08:34 +0200
commit0f8015fcdc4eb7a2bedc6a04548e588b39914c60 (patch)
treeb0966f6a12c6c87dd94c746f07c8b34de57b63e5
parente95014f7752ed459075b7270c324b3a8f68dc4e7 (diff)
-rw-r--r--system/database/DB_utility.php81
-rw-r--r--system/libraries/Zip.php6
-rw-r--r--user_guide/database/utilities.html6
-rw-r--r--user_guide/general/changelog.html1
4 files changed, 41 insertions, 53 deletions
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php
index 2748a4407..e239d75e8 100644
--- a/system/database/DB_utility.php
+++ b/system/database/DB_utility.php
@@ -460,10 +460,9 @@ class CI_DB_utility {
return TRUE;
break;
default :
- require BASEPATH.'libraries/Zip.php';
- $zip = new Zip;
- $zip->add_file($this->_backup($prefs), $prefs['filename'].'.sql');
- write_file($path, $zip->output_zipfile());
+ $obj->load->library('zip');
+ $obj->zip->add_data($prefs['filename'].'.sql', $this->_backup($prefs));
+ $obj->zip->archive($path);
return TRUE;
break;
}
@@ -472,65 +471,59 @@ class CI_DB_utility {
// ------------------------------------------------------
- // Set the mime type used in the server header
- switch ($prefs['format'])
- {
- case 'zip' : $mime = 'application/x-zip';
- break;
- case 'gzip' : $mime = 'application/x-gzip';
- break;
- default :
- if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE") || strstr($_SERVER['HTTP_USER_AGENT'], "OPERA"))
- {
- $mime = 'application/octetstream';
- }
- else
- {
- $mime = 'application/octet-stream';
- }
- break;
- }
// Grab the super object
$obj =& get_instance();
// Remap the file extensions
$ext = array('gzip' => 'gz', 'zip' => 'zip', 'txt' => 'sql');
+
+ // Is a Zip file requested?
+ if ($prefs['format'] == 'zip')
+ {
+ $obj->load->library('zip');
+ $obj->zip->add_data($prefs['filename'].'.sql', $this->_backup($prefs));
+ $obj->zip->download($prefs['filename'].'.'.$ext[$prefs['format']]);
+ return TRUE;
+ }
+
+
+ // Set the mime type
+ switch ($prefs['format'])
+ {
+ case 'gzip' : $mime = 'application/x-gzip';
+ break;
+ default : $mime = (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE") || strstr($_SERVER['HTTP_USER_AGENT'], "OPERA")) ? 'application/octetstream' : 'application/octet-stream';
+ break;
+ }
+
+ $filename = $prefs['filename'].'.sql.'.$ext[$prefs['format']];
- // Send headers
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
{
- $obj->output->set_header('Content-Type: '.$mime);
- $obj->output->set_header('Content-Disposition: inline; filename="'.$prefs['filename'].'.'.$ext[$prefs['format']].'"');
- $obj->output->set_header('Content-Transfer-Encoding: binary');
- $obj->output->set_header('Expires: 0');
- $obj->output->set_header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- $obj->output->set_header('Pragma: public');
+ header('Content-Type: '.$mime);
+ header('Content-Disposition: inline; filename="'.$filename.'"');
+ header('Expires: 0');
+ header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+ header("Content-Transfer-Encoding: binary");
+ header('Pragma: public');
}
else
{
- $obj->output->set_header('Content-Type: '.$mime);
- $obj->output->set_header('Content-Disposition: attachment; filename="'.$prefs['filename'].'.'.$ext[$prefs['format']].'"');
- $obj->output->set_header('Content-Transfer-Encoding: binary');
- $obj->output->set_header('Expires: 0');
- $obj->output->set_header('Pragma: no-cache');
+ header('Content-Type: '.$mime);
+ header('Content-Disposition: attachment; filename="'.$filename.'"');
+ header("Content-Transfer-Encoding: binary");
+ header('Expires: 0');
+ header('Pragma: no-cache');
}
-
// Write the file based on type
switch ($prefs['format'])
{
- case 'gzip' : $obj->output->set_output(gzencode($this->_backup($prefs)));
+ case 'gzip' : echo gzencode($this->_backup($prefs));
break;
- case 'txt' : $obj->output->set_output($this->_backup($prefs));
+ case 'txt' : echo $this->_backup($prefs);
break;
- default :
- require BASEPATH.'libraries/Zip.php';
-
- $zip = new Zip;
- $zip->add_file($this->_backup($prefs), $prefs['filename'].'.sql');
- $obj->output->set_output($zip->output_zipfile());
- break;
}
return TRUE;
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index a11699956..218388314 100644
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -227,7 +227,7 @@ class CI_Zip {
// --------------------------------------------------------------------
/**
- * Write File
+ * Write File to the specified direcotry
*
* Lets you write a file
*
@@ -236,9 +236,9 @@ class CI_Zip {
* @param string the data to be encoded
* @return bool
*/
- function write_zip($filepath)
+ function archive($filepath)
{
- if ( ! ($fp = fopen($filepath, "wb")))
+ if ( ! ($fp = @fopen($filepath, "wb")))
{
return FALSE;
}
diff --git a/user_guide/database/utilities.html b/user_guide/database/utilities.html
index 3efa04f1d..cbd8be784 100644
--- a/user_guide/database/utilities.html
+++ b/user_guide/database/utilities.html
@@ -274,12 +274,6 @@ $this->dbutil->backup($prefs);
</code>
-<p class="important"><strong>VERY IMPORTANT:</strong> If you are using the <dfn>download</dfn> action to send the file to your desktop,
-DO NOT display any data in the controller in which you are triggering the backup. Since Code Igniter buffers all output, any data
-sent to the browser will be included in your export file. This issue ONLY applies to downloads. If you are using any other action
-you can display data in your controller.</p>
-
-
<h3>Description of Backup Preferences</h3>
<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
diff --git a/user_guide/general/changelog.html b/user_guide/general/changelog.html
index aab14d516..3f991e077 100644
--- a/user_guide/general/changelog.html
+++ b/user_guide/general/changelog.html
@@ -78,6 +78,7 @@ Change Log
<li>Added $query->field_names() function</li>
<li>Added $this->db->platform() function</li>
<li>Added "is_numeric" to validation</li>
+<li>Added two more protocols to the URI handler to make it more reliable when the $config['uri_protocol'] item is set to AUTO.</li>
<li><strong>Deprecated "init" folder</strong>. Initialization happens automatically now. <a href="creating_libraries.html">Please see documentation</a>.</li>
<li><strong>Deprecated</strong> $this->db->field_names() USE $this->db->list_fields()</li>