// // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // // the Free Software Foundation; either version 2 of the License, or // // (at your option) any later version. // // // // You may not change or alter any portion of this comment or credits // // of supporting developers from this source code or any supporting // // source code which is considered copyrighted (c) material of the // // original comment or credit authors. // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License for more details. // // // // You should have received a copy of the GNU General Public License // // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // include '../../../include/cp_header.php'; require('../include/zip.lib.php'); require('../include/defines.lib.php'); require('../include/read_dump.lib.php'); // Include backup functions include("backup.ini.php"); include("backup.inc"); xoops_cp_header(); // Make sure we pick up variables passed via URL if( isset( $_GET[ 'mode' ] ) ) $mode = $_GET[ 'mode' ]; else $mode = '' ; if( isset( $_GET[ 'action' ] ) ) $action = $_GET[ 'action' ]; else $action = '' ; if( isset( $_GET[ 'num_tables' ] ) ) $num_tables = $_GET[ 'num_tables' ]; else $num_tables = '' ; if( isset( $_GET[ 'checkall' ] ) ) $checkall = $_GET[ 'checkall' ]; else $checkall = '' ; // Display Admin Menu Tag include_once './adminmenu.php'; // Handle URL actions switch ($mode) { case POST_SELECT_MODULE_FORM: { $select_dirname = isset($_GET['dirname']) ? $_GET['dirname'] : 0; $mod_selections = make_module_selection($select_dirname); echo "
"; echo "\n"; echo "\n"; echo $tr_strd; echo $tr_comp; echo "
"._AM_MODULEBACKUP."
"._AM_SELECTMODULE."$mod_selections
\n" ."
"; echo "
\n"; echo "

"; break; } case POST_DB_SELECT_FORM: { $select_dirname = isset($_GET['dirname']) ? $_GET['dirname'] : 0; $mod_selections = make_module_selection($select_dirname,1); // Get list of tables in the database and output form if ($action=="module" && $dirname){ $result = get_module_tables($dirname); $num_tables = sizeof($result); $checkall = true; }else{ $result = mysql_list_tables($db_selected); $num_tables = mysql_num_rows($result); } echo "\n"; echo "\n"; echo "\n"; echo ""; } if ($action=="module" && $dirname){ echo ""; } echo ""; echo $tr_strd; echo $tr_comp; echo "\n"; echo "\n"; echo "
"._AM_SELECTTABLES."

"._AM_BACKUPNOTICE; echo "

"._AM_SELECTTABLE."

\n"; $checked = (!empty($checkall) ? ' checked="checked"' : ''); for ($i = 0; $i < $num_tables; $i++) { if ($action=="module" && $dirname){ $tablename = $xoopsDB->prefix($result[$i]); } else { $tablename = mysql_tablename($result, $i); } $checkbox_string = sprintf("  %s
\n", $i, $i, $tablename, $tablename); echo "
$checkbox_string
"; echo ""._AM_CHECKALL."
"; echo "

\n"; echo "\n"; echo "

\n"; break; } case POST_SELECT_TABLES_FORM: { @set_time_limit(TIME_LIMIT); $sql_string = ""; $alltables = $backup_structure = $backup_data =0; if (isset($_GET['alltables'])) $alltables = ($_GET['alltables'] == "on") ? 1 : 0; if (isset($_POST['alltables'])) $alltables = ($_POST['alltables'] == "on") ? 1 : 0; if (isset($_POST['structure'])) $backup_structure = ($_POST['structure'] == "on") ? 1 : 0; if (isset($_POST['data'])) $backup_data = ($_POST['data'] == "on") ? 1 : 0; $dirname = isset($_POST['dirname']) ? $_POST['dirname'] : 0; if ($dirname){ if (strcmp($dirname,"system")==0) $result = $sys_tables; else $result = get_module_tables($dirname); $num_tables = sizeof($result); }else{ $result = mysql_list_tables($db_selected); $num_tables = mysql_num_rows($result); } $j = 0; $tablename_array = array(); if (!$alltables){ for ($i = 0; $i < $num_tables; $i++) { $check_id = sprintf("check_id%d", $i); $tablename = sprintf("tablename%d", $i); if ( isset($_POST[$check_id]) ) { if (isset($_POST[$tablename])){ $tablename_array[$j] = $_POST[$tablename]; $j++; } } } }else{ for ($i = 0; $i < $num_tables; $i++) { if ( $dirname ) $tablename_array[$i] = $xoopsDB->prefix($result[$i]); else $tablename_array[$i] = mysql_tablename($result, $i); } } $dump_buffer = backup_data($tablename_array, $backup_structure, $backup_data); if ($dirname) $filename =$dirname.date("YmdHis",time()); else $filename ="xdb".date("YmdHis",time()); $cfgZipType=$_POST['file_compression']; if (($cfgZipType == 'bzip') && (PMA_PHP_INT_VERSION >= 40004 && @function_exists('bzcompress'))) { $filename .=".sql"; $ext = 'bz2'; $mime_type = 'application/x-bzip'; $dump_buffer = bzcompress($dump_buffer); } else if (($cfgZipType == 'gzip') &&(PMA_PHP_INT_VERSION >= 40004 && @function_exists('gzencode'))) { $filename .=".sql"; $ext = 'gz'; $content_encoding = 'x-gzip'; $mime_type = 'application/x-gzip'; // without the optional parameter level because it bug $dump_buffer = gzencode($dump_buffer,9); } else if (($cfgZipType == 'zip') && (PMA_PHP_INT_VERSION >= 40000 && @function_exists('gzcompress'))) { $ext = 'zip'; $mime_type = 'application/x-zip'; $extbis = '.sql'; $zipfile = new zipfile(); $zipfile -> addFile($dump_buffer, $filename . $extbis); $dump_buffer = $zipfile -> file(); } else { $ext = 'sql'; $cfgZipType = 'none'; $mime_type = "text/plain"; } if (isset($HTTP_POST_VARS['oldurl'])) { $oldurl = $HTTP_POST_VARS['oldurl']; } $oldurl = (!isset($oldurl)||empty($oldurl)) ? XOOPS_URL : $oldurl; $fpathname = $fpath.$filename.'.'.$ext; $fp = fopen($fpathname,'w'); fwrite($fp, $dump_buffer); fclose($fp); if(!file_exists($fpathname)){ print("Error - $filename does not exist."); return ; } ob_clean(); @ignore_user_abort(); //@set_time_limit(TIME_LIMIT); $size = filesize($fpathname); // till here if (!empty($content_encoding)) { header('Content-Encoding: ' . $content_encoding); } header("Content-length: " . $size); header("Content-disposition: inline; filename=" . $filename.'.'.$ext); header("Content-type: " . $mime_type); header("Content-Transfer-Encoding: binary"); header("x-extension: " . $mime_type ); $fp = fopen($fpathname,'r'); while(!feof($fp)) { $buffer = fread($fp, 1024*6); //speed-limit 64kb/s print $buffer; flush(); ob_flush(); usleep(10000); } fclose($fp); unlink($fpathname); exit(); break; } case DB_SELECT_FORM: { // xoops_cp_header(); echo "\n"; if ($action == "backup") { echo "\n"; echo "\n"; echo "
Backup MySQL Data

Select database to backup from"; } if ($action == "backup") echo "

\n"; echo "\n"; echo "
\n"; echo "

\n"; break; } default: { // xoops_cp_header(); $result = mysql_list_tables($db_selected); $num_tables = mysql_num_rows($result); echo "

"; echo "\n"; echo $tr_strd; echo $tr_comp; echo "
"._AM_BACKUPTITLE."
\n". "
"; echo "

"; } } // Close MySQL link mysql_close($link); echo $footer; xoops_cp_footer(); ?>