@@ -356,7 +356,7 @@ public function backup($params = [])
356356 'tables ' => [],
357357 'ignore ' => [],
358358 'filename ' => '' ,
359- 'format ' => 'gzip ' , // gzip, zip, txt
359+ 'format ' => 'gzip ' , // gzip, txt
360360 'add_drop ' => true ,
361361 'add_insert ' => true ,
362362 'newline ' => "\n" ,
@@ -383,15 +383,14 @@ public function backup($params = [])
383383 }
384384
385385 // Validate the format
386- if (! in_array ($ prefs ['format ' ], ['gzip ' , 'zip ' , ' txt ' ], true ))
386+ if (! in_array ($ prefs ['format ' ], ['gzip ' , 'txt ' ], true ))
387387 {
388388 $ prefs ['format ' ] = 'txt ' ;
389389 }
390390
391391 // Is the encoder supported? If not, we'll either issue an
392392 // error or use plain text depending on the debug settings
393- if (($ prefs ['format ' ] === 'gzip ' && ! function_exists ('gzencode ' ))
394- || ( $ prefs ['format ' ] === 'zip ' && ! function_exists ('gzcompress ' )))
393+ if ($ prefs ['format ' ] === 'gzip ' && ! function_exists ('gzencode ' ))
395394 {
396395 if ($ this ->db ->DBDebug )
397396 {
@@ -401,46 +400,12 @@ public function backup($params = [])
401400 $ prefs ['format ' ] = 'txt ' ;
402401 }
403402
404- // Was a Zip file requested?
405- if ($ prefs ['format ' ] === 'zip ' )
406- {
407- // Set the filename if not provided (only needed with Zip files)
408- if ($ prefs ['filename ' ] === '' )
409- {
410- $ prefs ['filename ' ] = (count ($ prefs ['tables ' ]) === 1 ? $ prefs ['tables ' ] : $ this ->db ->database )
411- . date ('Y-m-d_H-i ' , time ()) . '.sql ' ;
412- }
413- else
414- {
415- // If they included the .zip file extension we'll remove it
416- if (preg_match ('|.+?\.zip$| ' , $ prefs ['filename ' ]))
417- {
418- $ prefs ['filename ' ] = str_replace ('.zip ' , '' , $ prefs ['filename ' ]);
419- }
420-
421- // Tack on the ".sql" file extension if needed
422- if (! preg_match ('|.+?\.sql$| ' , $ prefs ['filename ' ]))
423- {
424- $ prefs ['filename ' ] .= '.sql ' ;
425- }
426- }
427-
428- // Load the Zip class and output it
429- // $CI =& get_instance();
430- // $CI->load->library('zip');
431- // $CI->zip->add_data($prefs['filename'], $this->_backup($prefs));
432- // return $CI->zip->get_zip();
433- }
434- elseif ($ prefs ['format ' ] === 'txt ' ) // Was a text file requested?
403+ if ($ prefs ['format ' ] === 'txt ' ) // Was a text file requested?
435404 {
436405 return $ this ->_backup ($ prefs );
437406 }
438- elseif ($ prefs ['format ' ] === 'gzip ' ) // Was a Gzip file requested?
439- {
440- return gzencode ($ this ->_backup ($ prefs ));
441- }
442407
443- return ;
408+ return gzencode ( $ this -> _backup ( $ prefs )) ;
444409 }
445410
446411 //--------------------------------------------------------------------
0 commit comments