From: <be...@us...> - 2012-04-11 04:13:33
|
Revision: 9298 http://xoops.svn.sourceforge.net/xoops/?rev=9298&view=rev Author: beckmi Date: 2012-04-11 04:13:25 +0000 (Wed, 11 Apr 2012) Log Message: ----------- Adding release 3.1 from Roby73 Modified Paths: -------------- XoopsModules/backup/trunk/backup/admin/admin_header.php XoopsModules/backup/trunk/backup/admin/backup.php XoopsModules/backup/trunk/backup/admin/cache.php XoopsModules/backup/trunk/backup/admin/index.php XoopsModules/backup/trunk/backup/admin/restore.php XoopsModules/backup/trunk/backup/images/slogo.png XoopsModules/backup/trunk/backup/include/build_dump.lib.php XoopsModules/backup/trunk/backup/include/defines.lib.php XoopsModules/backup/trunk/backup/include/functions.php XoopsModules/backup/trunk/backup/include/zip.lib.php XoopsModules/backup/trunk/backup/language/english/admin.php XoopsModules/backup/trunk/backup/language/english/modinfo.php XoopsModules/backup/trunk/backup/language/schinese/admin.php XoopsModules/backup/trunk/backup/language/schinese/modinfo.php XoopsModules/backup/trunk/backup/xoops_version.php Added Paths: ----------- XoopsModules/backup/trunk/backup/admin/about.php XoopsModules/backup/trunk/backup/admin/admin_footer.php XoopsModules/backup/trunk/backup/admin/main.php XoopsModules/backup/trunk/backup/admin/menu.php XoopsModules/backup/trunk/backup/admin/other.php XoopsModules/backup/trunk/backup/docs/ XoopsModules/backup/trunk/backup/docs/index.html XoopsModules/backup/trunk/backup/docs/readme.txt XoopsModules/backup/trunk/backup/images/admin/ XoopsModules/backup/trunk/backup/images/admin/database.png XoopsModules/backup/trunk/backup/images/admin/database_add.png XoopsModules/backup/trunk/backup/images/admin/delete.png XoopsModules/backup/trunk/backup/images/admin/index.html XoopsModules/backup/trunk/backup/images/admin/restore.png XoopsModules/backup/trunk/backup/language/english/changelog.txt XoopsModules/backup/trunk/backup/language/english/main.php XoopsModules/backup/trunk/backup/language/french/ XoopsModules/backup/trunk/backup/language/french/admin.php XoopsModules/backup/trunk/backup/language/french/index.html XoopsModules/backup/trunk/backup/language/french/modinfo.php Removed Paths: ------------- XoopsModules/backup/trunk/backup/admin/index.html XoopsModules/backup/trunk/backup/readme.txt Added: XoopsModules/backup/trunk/backup/admin/about.php =================================================================== --- XoopsModules/backup/trunk/backup/admin/about.php (rev 0) +++ XoopsModules/backup/trunk/backup/admin/about.php 2012-04-11 04:13:25 UTC (rev 9298) @@ -0,0 +1,15 @@ +<?php +include '../../../include/cp_header.php'; +include 'admin_header.php'; +xoops_cp_header(); + +$module_info =& $module_handler->get($xoopsModule->getVar("mid")); + +$aboutAdmin = new ModuleAdmin(); + +echo $aboutAdmin->addNavigation('about.php'); +echo $aboutAdmin->renderabout('6KJ7RW5DR3VTJ', false); + +include 'admin_footer.php'; + +?> Added: XoopsModules/backup/trunk/backup/admin/admin_footer.php =================================================================== --- XoopsModules/backup/trunk/backup/admin/admin_footer.php (rev 0) +++ XoopsModules/backup/trunk/backup/admin/admin_footer.php 2012-04-11 04:13:25 UTC (rev 9298) @@ -0,0 +1,24 @@ +<?php +/** + * MyLinks module + * + * 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. + * + * @copyright:: The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license:: http://www.fsf.org/copyleft/gpl.html GNU public license + * @package:: mylinks + * @subpackage:: admin + * @since: 2.5.0 + * @author:: Magic.Shao <mag...@gm...> - Susheng Yang <ezs...@gm...> + * @version:: $Id $ +**/ +global $moduleInfo; +echo "<div align=\"center\"><a href=\"http://www.xoops.org\" target=\"_blank\"><img src=" . XOOPS_URL ."/". $moduleInfo->getInfo("icons32")."/xoopsmicrobutton.gif"." alt=\"XOOPS\" title=\"XOOPS\"></a></div>"; +echo "<div class='center smallsmall italic pad5'><strong>" . $xoopsModule->getVar("name") . "</strong> is maintained by the <a class='tooltip' rel='external' href='http://www.xoops.org/' title='Visit XOOPS Community'>XOOPS Community</a></div>"; + +xoops_cp_footer(); Modified: XoopsModules/backup/trunk/backup/admin/admin_header.php =================================================================== --- XoopsModules/backup/trunk/backup/admin/admin_header.php 2012-04-11 04:10:37 UTC (rev 9297) +++ XoopsModules/backup/trunk/backup/admin/admin_header.php 2012-04-11 04:13:25 UTC (rev 9298) @@ -1,3 +1,31 @@ -<?php -include("../../../include/cp_header.php"); -?> \ No newline at end of file +<?php +include_once dirname(dirname(dirname(dirname(__FILE__)))) . '/mainfile.php'; +include_once XOOPS_ROOT_PATH . '/include/cp_functions.php'; +include("../../../include/cp_header.php"); + +//defined ('FRAMEWORKS_ART_FUNCTIONS_INI') || include_once XOOPS_ROOT_PATH . '/Frameworks/art/functions.ini.php' ; +if ( file_exists($GLOBALS['xoops']->path('/Frameworks/moduleclasses/moduleadmin/moduleadmin.php'))){ + include_once $GLOBALS['xoops']->path('/Frameworks/moduleclasses/moduleadmin/moduleadmin.php'); + //return true; + }else{ + echo xoops_error("Error: You don't use the Frameworks \"admin module\". Please install this Frameworks"); + //return false; + } + + +$moduleInfo =& $module_handler->get($xoopsModule->getVar('mid')); +$pathIcon16 = XOOPS_URL .'/'. $moduleInfo->getInfo('icons16'); +$pathIcon32 = XOOPS_URL .'/'. $moduleInfo->getInfo('icons32'); + +$myts =& MyTextSanitizer::getInstance(); + +if (!isset($xoopsTpl) || !is_object($xoopsTpl)) { + include_once XOOPS_ROOT_PATH . '/class/template.php' ; + $xoopsTpl = new XoopsTpl() ; +} + +//Load languages +xoops_loadLanguage('admin', $xoopsModule->getVar("dirname")); +xoops_loadLanguage('modinfo', $xoopsModule->getVar("dirname")); +xoops_loadLanguage('main', $xoopsModule->getVar("dirname")); +?> Modified: XoopsModules/backup/trunk/backup/admin/backup.php =================================================================== --- XoopsModules/backup/trunk/backup/admin/backup.php 2012-04-11 04:10:37 UTC (rev 9297) +++ XoopsModules/backup/trunk/backup/admin/backup.php 2012-04-11 04:13:25 UTC (rev 9298) @@ -1,228 +1,243 @@ -<?php -// ------------------------------------------------------------------------ // -// Author: D.J.(phppp) ph...@ho... // -// URL: http://xoops.org.cn // -// ------------------------------------------------------------------------- // - -include("../../../mainfile.php"); -$module_handler =& xoops_gethandler('module'); -$xoopsModule =& $module_handler->getByDirname('backup'); -$config_handler = & xoops_gethandler( 'config' ); -$xoopsModuleConfig = & $config_handler->getConfigsByCat( 0, $xoopsModule->getVar( 'mid' ) ); -if ( file_exists( XOOPS_ROOT_PATH."/modules/backup/language/" . $xoopsConfig['language'] . "/admin.php" ) ) { - include XOOPS_ROOT_PATH."/modules/backup/language/" . $xoopsConfig['language'] . "/admin.php"; -} -elseif ( file_exists( XOOPS_ROOT_PATH."/modules/backup/language/english/admin.php" ) ) { - include XOOPS_ROOT_PATH."/modules/backup/language/english/admin.php"; -} - -include_once(XOOPS_ROOT_PATH.'/modules/backup/include/defines.lib.php'); -include_once(XOOPS_ROOT_PATH.'/modules/backup/include/build_dump.lib.php'); -include_once(XOOPS_ROOT_PATH.'/modules/backup/include/zip.lib.php'); -include_once(XOOPS_ROOT_PATH."/class/xoopslists.php"); - -$cfgBackupTarget = $xoopsModuleConfig['cfgBackupTarget']; -$drop = $xoopsModuleConfig['drop']; -$cfgZipType = $xoopsModuleConfig['cfgZipType']; -$cfgExecTimeLimit = $xoopsModuleConfig['cfgExecTimeLimit']; -$use_backquotes = $xoopsModuleConfig['use_backquotes']; - -$server = XOOPS_DB_NAME; - -function PMA_myHandler($sql_insert) -{ - global $tmp_buffer; - $eol_dlm = (isset($GLOBALS['extended_ins']) && ($GLOBALS['current_row'] < $GLOBALS['rows_cnt'])) - ? ',' - : ';'; - $tmp_buffer .= $sql_insert . $eol_dlm . $GLOBALS['crlf']; -} - -function PMA_whichCrlf() -{ - $the_crlf = "\n"; - if (PMA_USR_OS == 'Win') { - $the_crlf = "\r\n"; - } - else if (PMA_USR_OS == 'Mac') { - $the_crlf = "\r"; - } - else { - $the_crlf = "\n"; - } - return $the_crlf; -} - -$err_url = XOOPS_URL; - -@set_time_limit($cfgExecTimeLimit); -$crlf = PMA_whichCrlf(); - -if (($cfgZipType == 'bzip') && (PMA_PHP_INT_VERSION >= 40004 && @function_exists('bzcompress'))) { - $ext = 'bz2'; - $mime_type = 'application/x-bzip'; -} else if (($cfgZipType == 'gzip') &&(PMA_PHP_INT_VERSION >= 40004 && @function_exists('gzencode'))) { - $ext = 'gz'; - $mime_type = 'application/x-gzip'; -} else if (($cfgZipType == 'zip') && (PMA_PHP_INT_VERSION >= 40000 && @function_exists('gzcompress'))) { - $ext = 'zip'; - $mime_type = 'application/x-zip'; -} else { - $ext = 'sql'; - $cfgZipType = 'none'; - $mime_type = (PMA_USR_BROWSER_AGENT == 'IE' || PMA_USR_BROWSER_AGENT == 'OPERA') - ? 'application/octetstream' - : 'application/octet-stream'; -} - -$tables = mysql_list_tables($db = XOOPS_DB_NAME); -$num_tables = @mysql_numrows($tables); - -$dirname = XOOPS_ROOT_PATH.'/'.$xoopsModuleConfig["dbfiles_path"]; -$prefix = 'bkp'; - -if ($num_tables == 0) { - echo '# ' ._DB_NOTABLESFOUND; - if(isset($_GET['oldurl'])){ - redirect_header($_GET['oldurl'], 3, _DB_BACKUP_READY ); - }else{ - redirect_header("javascript:history.go(-1)", 1, _DB_BACKUP_READY ); - } - exit; -} - -$filename_prefix = $prefix.date('ymdHi'); -$split = (is_array($xoopsModuleConfig["dbfiles_split"])&&count($xoopsModuleConfig["dbfiles_split"])>0)?$xoopsModuleConfig["dbfiles_split"]:array("1"); -$files_backup=array(); -for($i=0; $i<$num_tables; $i++){ - $name = mysql_tablename($tables, $i); - if(in_array("1",$split)||in_array($name, $split)){ - $files_backup[$name] = array($name); - }else{ - $files_backup["body"][] = $name; - } -} -$formatted_db_name = (isset($use_backquotes)) - ? PMA_backquote($db) - : '\'' . $db . '\''; -foreach($files_backup as $fl => $names){ - $filename = ($fl == "body")?$filename_prefix:$filename_prefix."_".$fl; - $dump_buffer = '# Backup for MySQL' . $crlf - . '#' . $crlf; - foreach ($names as $table) { - $formatted_table_name = (isset($use_backquotes)) - ? PMA_backquote($table) - : '\'' . $table . '\''; - $dump_buffer .= '# --------------------------------------------------------' . $crlf - . $crlf . '#' . $crlf - . '# ' ._DB_TABLESTRUCTURE. ' ' . $formatted_table_name . $crlf - . '#' . $crlf . $crlf - . PMA_getTableDef($db, $table, $crlf, $err_url) . ';' . $crlf; - - $tcmt = $crlf . '#' . $crlf - . '# ' ._DB_DUMPINGDATA. ' ' . $formatted_table_name . $crlf - . '#' . $crlf .$crlf; - $dump_buffer .= $tcmt; - $tmp_buffer = ''; - if (!isset($limit_from) || !isset($limit_to)) { - $limit_from = $limit_to = 0; - } - PMA_getTableContent($db, $table, $limit_from, $limit_to, 'PMA_myHandler', $err_url); - $dump_buffer .= $tmp_buffer; - } - $dump_buffer .= $crlf; - - - if ($cfgZipType == 'zip') { - if (PMA_PHP_INT_VERSION >= 40000 && @function_exists('gzcompress')) { - $extbis = '.sql'; - $zipfile = new zipfile(); - $zipfile -> addFile($dump_buffer, $filename . $extbis); - $dump_buffer = $zipfile -> file(); - } - } - else if ($cfgZipType == 'bzip') { - if (PMA_PHP_INT_VERSION >= 40004 && @function_exists('bzcompress')) { - $dump_buffer = bzcompress($dump_buffer); - } - } - else if ($cfgZipType == 'gzip') { - if (PMA_PHP_INT_VERSION >= 40004 && @function_exists('gzencode')) { - // without the optional parameter level because it bug - $dump_buffer = gzencode($dump_buffer); - } - } - - $fp = fopen($dirname.'/'. $filename . '.' . $ext,'w'); - fwrite($fp, $dump_buffer); - fclose($fp); - - if ($cfgBackupTarget == 'download') { - if(!is_object($xoopsUser)||!$xoopsUser->isAdmin()){ - redirect_header("javascript:history.go(-1)", 1, _NOPERM ); - exit; - } - header('Content-Type: ' . $mime_type); - if (PMA_USR_BROWSER_AGENT == 'IE') { - header('Content-Disposition: inline; filename="' . $filename . '.' . $ext . '"'); - header('Expires: 0'); - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); - header('Pragma: public'); - } else { - header('Content-Disposition: attachment; filename="' . $filename . '.' . $ext . '"'); - header('Expires: 0'); - header('Pragma: no-cache'); - } - echo $dump_buffer; - } elseif ($cfgBackupTarget == 'email') { - $subject = sprintf(_DB_BACKUP_FOR, $xoopsConfig['sitename']) ; - $message = _DB_CREATEON.': '.date('H:i D d-M-Y')." \n" ; - $message .= _DB_DOWNLOAD.":\n"; - $message .= XOOPS_URL."/modules/backup/cache/".$filename.'.'.$ext."\n\n"; - $message .= "------------------\n"; - $message .= $xoopsConfig['sitename']."\n".$xoopsConfig['xoops_url']."/"; - $xoopsMailer =& getMailer(); - $xoopsMailer->useMail(); - $emails = explode(',',$xoopsModuleConfig['email_to']); - foreach ($emails as $key=>$value) { $emails[$key]=trim($value); } - $xoopsMailer->setToEmails($emails); - $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); - $xoopsMailer->setFromName($xoopsConfig['sitename']); - $xoopsMailer->setSubject($subject); - $xoopsMailer->setBody($message); - if($xoopsModuleConfig['email_attach']){ - $xoopsMailer->multimailer->AddAttachment($dirname.'/'.$filename.'.'.$ext); - } - $xoopsMailer->send(); - } -} - -$db_files =& XoopsLists::getFileListAsArray($dirname); -$dbfiles = array(); -$dbprefix = array(); -foreach($db_files as $_file => $_filename){ - if(preg_match("/(^".$prefix."[^_]*)(_.*)?\.(.*)/i", $_filename, $matches)){ - $dbprefix[$matches[1]] = 1; - $dbfiles[]=$_filename; - } -} - -$dbpre = array_keys($dbprefix); -arsort($dbpre); -reset($dbpre); -$dbpre_valid = array_slice($dbpre, 0, $xoopsModuleConfig['dbfiles_store']); -foreach($dbfiles as $dbfile){ - if(!preg_match("/^(".implode("|",$dbpre_valid).")(_.*)?\.(.*)/i", $dbfile, $matches)){ - unlink($dirname.'/'.$dbfile); - } -} - - -if ($cfgBackupTarget != 'download') { - if(isset($_GET['oldurl'])){ - redirect_header($_GET['oldurl'], 3, _DB_BACKUP_READY ); - }else{ - redirect_header("javascript:history.go(-1)", 1, _DB_BACKUP_READY ); - } -} -?> \ No newline at end of file +<?php +// ------------------------------------------------------------------------ // +// Author: D.J.(phppp) ph...@ho... // +// URL: http://xoops.org.cn // +// ------------------------------------------------------------------------- // + +include 'admin_header.php'; +$module_handler =& xoops_gethandler('module'); +$xoopsModule =& $module_handler->getByDirname('backup'); +$config_handler = & xoops_gethandler( 'config' ); +$xoopsModuleConfig = & $config_handler->getConfigsByCat( 0, $xoopsModule->getVar( 'mid' ) ); + +include_once(XOOPS_ROOT_PATH.'/modules/backup/include/defines.lib.php'); +include_once(XOOPS_ROOT_PATH.'/modules/backup/include/build_dump.lib.php'); +include_once(XOOPS_ROOT_PATH.'/modules/backup/include/zip.lib.php'); +include_once(XOOPS_ROOT_PATH."/class/xoopslists.php"); + +$cfgBackupTarget = $xoopsModuleConfig['cfgBackupTarget']; +$drop = $xoopsModuleConfig['drop']; +$cfgZipType = $xoopsModuleConfig['cfgZipType']; +$cfgExecTimeLimit = $xoopsModuleConfig['cfgExecTimeLimit']; +$use_backquotes = $xoopsModuleConfig['use_backquotes']; + +$other_tables = (!isset($_POST['tables']))?false:$_POST['tables']; +$db_name = (!isset($_GET['db_name']))?XOOPS_DB_NAME:$_GET['db_name']; + +if ($db_name) { +$db_selected = mysql_select_db($db_name); + if (!$db_selected) { + redirect_header('index.php', 3, 'Database not exist'); + exit; + } +} + +$server = $db_name; +function PMA_myHandler($sql_insert) +{ + global $tmp_buffer; + $eol_dlm = (isset($GLOBALS['extended_ins']) && ($GLOBALS['current_row'] < $GLOBALS['rows_cnt'])) + ? ',' + : ';'; + $tmp_buffer .= $sql_insert . $eol_dlm . $GLOBALS['crlf']; +} + +function PMA_whichCrlf() +{ + $the_crlf = "\n"; + if (PMA_USR_OS == 'Win') { + $the_crlf = "\r\n"; + } + else if (PMA_USR_OS == 'Mac') { + $the_crlf = "\r"; + } + else { + $the_crlf = "\n"; + } + return $the_crlf; +} + +$err_url = XOOPS_URL; + +@set_time_limit($cfgExecTimeLimit); +$crlf = PMA_whichCrlf(); + +if (($cfgZipType == 'bzip') && (PMA_PHP_INT_VERSION >= 40004 && @function_exists('bzcompress'))) { + $ext = 'bz2'; + $mime_type = 'application/x-bzip'; +} else if (($cfgZipType == 'gzip') &&(PMA_PHP_INT_VERSION >= 40004 && @function_exists('gzencode'))) { + $ext = 'gz'; + $mime_type = 'application/x-gzip'; +} else if (($cfgZipType == 'zip') && (PMA_PHP_INT_VERSION >= 40000 && @function_exists('gzcompress'))) { + $ext = 'zip'; + $mime_type = 'application/x-zip'; +} else { + $ext = 'sql'; + $cfgZipType = 'none'; + $mime_type = (PMA_USR_BROWSER_AGENT == 'IE' || PMA_USR_BROWSER_AGENT == 'OPERA') + ? 'application/octetstream' + : 'application/octet-stream'; +} +$db = $db_name; +$sql = "SHOW TABLES FROM $db"; +$tables = mysql_query($sql); +$num_tables = @mysql_numrows($tables); + +$dirname = XOOPS_ROOT_PATH.'/'.$xoopsModuleConfig["dbfiles_path"]; +$prefix = 'bkp'; + +if ($num_tables == 0) { + echo '# ' ._DB_NOTABLESFOUND; + if(isset($_GET['oldurl'])){ + redirect_header($_GET['oldurl'], 3, _DB_BACKUP_READY ); + }else{ + redirect_header("javascript:history.go(-1)", 1, _DB_BACKUP_READY ); + } + exit; +} + +$filename_prefix = $prefix.'_'.$db.'-'.date('ymdHi'); +if (!$other_tables) { +$split = (is_array($xoopsModuleConfig["dbfiles_split"])&&count($xoopsModuleConfig["dbfiles_split"])>0)?$xoopsModuleConfig["dbfiles_split"]:array("1"); +} else { +$split = (is_array($other_tables)&&count($other_tables)>0)?$other_tables:array("1"); +} +$files_backup=array(); +for($i=0; $i<$num_tables; $i++){ + $name = mysql_tablename($tables, $i); + if(in_array("1",$split)||in_array($name, $split)){ + $files_backup[$name] = array($name); + }else{ + if ($xoopsModuleConfig['split']==1) $files_backup["body"][] = $name; + } +} + +$formatted_db_name = (isset($use_backquotes)) + ? PMA_backquote($db) + : '\'' . $db . '\''; +foreach($files_backup as $fl => $names){ + if ($xoopsModuleConfig['split']==1) { + $filename = ($fl == "body")?$filename_prefix:$filename_prefix."_".$fl; + } else { + $filename = $filename_prefix."_".$fl; + } + $dump_buffer = '# Backup for MySQL' . $crlf + . '#' . $crlf; + foreach ($names as $table) { + $formatted_table_name = (isset($use_backquotes)) + ? PMA_backquote($table) + : '\'' . $table . '\''; + $dump_buffer .= '# --------------------------------------------------------' . $crlf + . $crlf . '#' . $crlf + . '# ' ._DB_TABLESTRUCTURE. ' ' . $formatted_table_name . $crlf + . '#' . $crlf . $crlf + . PMA_getTableDef($db, $table, $crlf, $err_url) . ';' . $crlf; + + $tcmt = $crlf . '#' . $crlf + . '# ' ._DB_DUMPINGDATA. ' ' . $formatted_table_name . $crlf + . '#' . $crlf .$crlf; + $dump_buffer .= $tcmt; + $tmp_buffer = ''; + if (!isset($limit_from) || !isset($limit_to)) { + $limit_from = $limit_to = 0; + } + PMA_getTableContent($db, $table, $limit_from, $limit_to, 'PMA_myHandler', $err_url); + $dump_buffer .= $tmp_buffer; + } + $dump_buffer .= $crlf; + + + if ($cfgZipType == 'zip') { + if (PMA_PHP_INT_VERSION >= 40000 && @function_exists('gzcompress')) { + $extbis = '.sql'; + $zipfile = new zipfile(); + $zipfile -> addFile($dump_buffer, $filename . $extbis); + $dump_buffer = $zipfile -> file(); + } + } + else if ($cfgZipType == 'bzip') { + if (PMA_PHP_INT_VERSION >= 40004 && @function_exists('bzcompress')) { + $dump_buffer = bzcompress($dump_buffer); + } + } + else if ($cfgZipType == 'gzip') { + if (PMA_PHP_INT_VERSION >= 40004 && @function_exists('gzencode')) { + // without the optional parameter level because it bug + $dump_buffer = gzencode($dump_buffer); + } + } + + $fp = fopen($dirname.'/'. $filename . '.' . $ext,'w'); + fwrite($fp, $dump_buffer); + fclose($fp); + + if ($cfgBackupTarget == 'download') { + if(!is_object($xoopsUser)||!$xoopsUser->isAdmin()){ + redirect_header("javascript:history.go(-1)", 1, _NOPERM ); + exit; + } + header('Content-Type: ' . $mime_type); + if (PMA_USR_BROWSER_AGENT == 'IE') { + header('Content-Disposition: inline; filename="' . $filename . '.' . $ext . '"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + } else { + header('Content-Disposition: attachment; filename="' . $filename . '.' . $ext . '"'); + header('Expires: 0'); + header('Pragma: no-cache'); + } + echo $dump_buffer; + } elseif ($cfgBackupTarget == 'email') { + $subject = sprintf(_DB_BACKUP_FOR, $xoopsConfig['sitename']) ; + $message = _DB_CREATEON.': '.date('H:i D d-M-Y')." \n" ; + $message .= _DB_DOWNLOAD.":\n"; + $message .= XOOPS_URL."/uploads/backup/".$filename.'.'.$ext."\n\n"; + $message .= "------------------\n"; + $message .= $xoopsConfig['sitename']."\n".$xoopsConfig['xoops_url']."/"; + $xoopsMailer =& xoops_getMailer(); + $xoopsMailer->useMail(); + $emails = explode(',',$xoopsModuleConfig['email_to']); + foreach ($emails as $key=>$value) { $emails[$key]=trim($value); } + $xoopsMailer->setToEmails($emails); + $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); + $xoopsMailer->setFromName($xoopsConfig['sitename']); + $xoopsMailer->setSubject($subject); + $xoopsMailer->setBody($message); + if($xoopsModuleConfig['email_attach']){ + $xoopsMailer->multimailer->AddAttachment($dirname.'/'.$filename.'.'.$ext); + } + $xoopsMailer->send(); + } +} + +$db_files =& XoopsLists::getFileListAsArray($dirname); +$dbfiles = array(); +$dbprefix = array(); +foreach($db_files as $_file => $_filename){ + if(preg_match("/(^".$prefix."[^_]*)(_.*)?\.(.*)/i", $_filename, $matches)){ + $dbprefix[$matches[1]] = 1; + $dbfiles[]=$_filename; + } +} + +$dbpre = array_keys($dbprefix); +arsort($dbpre); +reset($dbpre); +$dbpre_valid = array_slice($dbpre, 0, $xoopsModuleConfig['dbfiles_store']); +foreach($dbfiles as $dbfile){ + if(!preg_match("/^(".implode("|",$dbpre_valid).")(_.*)?\.(.*)/i", $dbfile, $matches)){ + unlink($dirname.'/'.$dbfile); + } +} + + +if ($cfgBackupTarget != 'download') { + if(isset($_GET['oldurl'])){ + redirect_header($_GET['oldurl'], 3, _DB_BACKUP_READY ); + }else{ + redirect_header("javascript:history.go(-1)", 1, _DB_BACKUP_READY ); + } +} +include "admin_footer.php"; +?> Modified: XoopsModules/backup/trunk/backup/admin/cache.php =================================================================== --- XoopsModules/backup/trunk/backup/admin/cache.php 2012-04-11 04:10:37 UTC (rev 9297) +++ XoopsModules/backup/trunk/backup/admin/cache.php 2012-04-11 04:13:25 UTC (rev 9298) @@ -1,7 +1,7 @@ -<?php -include ('admin_header.php'); -require_once(XOOPS_ROOT_PATH.'/modules/backup/include/functions.php'); -$res = backup_export(); -redirect_header('index.php', 2, empty($res)?"configs backup error":"configs backup over!" ); -exit(); +<?php +include ('admin_header.php'); +require_once(XOOPS_ROOT_PATH.'/modules/backup/include/functions.php'); +$res = backup_export(); +redirect_header('index.php', 2, empty($res)?"configs backup error":"configs backup over!" ); +exit(); ?> \ No newline at end of file Deleted: XoopsModules/backup/trunk/backup/admin/index.html =================================================================== --- XoopsModules/backup/trunk/backup/admin/index.html 2012-04-11 04:10:37 UTC (rev 9297) +++ XoopsModules/backup/trunk/backup/admin/index.html 2012-04-11 04:13:25 UTC (rev 9298) @@ -1 +0,0 @@ - <script>history.go(-1);</script> \ No newline at end of file Modified: XoopsModules/backup/trunk/backup/admin/index.php =================================================================== --- XoopsModules/backup/trunk/backup/admin/index.php 2012-04-11 04:10:37 UTC (rev 9297) +++ XoopsModules/backup/trunk/backup/admin/index.php 2012-04-11 04:13:25 UTC (rev 9298) @@ -1,35 +1,52 @@ -<?php -include ('admin_header.php'); - -$op = 'Choice'; - -if ( isset($HTTP_POST_VARS['op']) ) { - $op = trim($HTTP_POST_VARS['op']); -} elseif ( isset($HTTP_GET_VARS['op']) ) { - $op = trim($HTTP_GET_VARS['op']); -} - -function Choice() { - global $xoopsModule; - xoops_cp_header(); - - OpenTable(); - echo "- <a href='".XOOPS_URL."/modules/system/admin.php?fct=preferences&op=showmod&mod=".$xoopsModule->getVar('mid')."'>"._DB_CONFIG."</a><br /><br />"; - echo "- <a href='".XOOPS_URL."/modules/backup/admin/backup.php?oldurl=".$_SERVER['PHP_SELF']."'>"._DB_BACKUP."</a><br /><br />"; - echo "- <a href='".XOOPS_URL."/modules/backup/admin/restore.php'>"._DB_RESTORE."</a> |"; - echo " <a href='".XOOPS_URL."/modules/backup/admin/restore.php?NA=1'>"._DB_NOADMIN."</a><br /><br />"; - echo "- <a href='".XOOPS_URL."/modules/backup/admin/cache.php'>"._DB_CACHE."</a><br />"; - echo "<br/><hr><br/><small>"._DB_README."</small>"; - CloseTable(); - xoops_cp_footer(); -} - -switch($op) { - case "Config": - Config(); - break; - default: - Choice(); - break; -} -?> \ No newline at end of file +<?php +/** + * **************************************************************************** + * + * 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. + * + * @copyright XOOPS Project + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @package + * @author metalslug + * + * Version : $Id: + * **************************************************************************** + */ + +require_once '../../../include/cp_header.php'; +include 'admin_header.php'; +xoops_cp_header(); +$indexadmin = new ModuleAdmin(); +$tot_file=0; + if ($handle = opendir(XOOPS_ROOT_PATH.'/uploads/backup/')) { + while (false !== ($file = readdir($handle))) { + if ( $file == ".." || $file == "." || substr($file,0,1)=='.' ) continue; + $tot_file++; + } + closedir($handle); +} + $sql = "SHOW TABLES"; + $result = mysql_query($sql); + $tot_tables = mysql_num_rows($result); + $indexadmin->addInfoBox(_DB_BACKUP_BOX1); + if ( 0 < $tot_file ) { + $indexadmin->addInfoBoxLine(_DB_BACKUP_BOX1, _MD_BACKUP_TOTALFILES, $tot_file, 'Red'); + } else { + $indexadmin->addInfoBoxLine(_DB_BACKUP_BOX1, _MD_BACKUP_TOTALFILES, $tot_file, 'Green'); + } + + $indexadmin->addInfoBox(_DB_BACKUP_BOX2); + if ( 0 == $tot_tables ) { + $indexadmin->addInfoBoxLine(_DB_BACKUP_BOX2, _MD_BACKUP_TOTALDB_TABLES, $tot_tables, 'Red'); + } else { + $indexadmin->addInfoBoxLine(_DB_BACKUP_BOX2, _MD_BACKUP_TOTALDB_TABLES, $tot_tables, 'Green'); + } + echo $indexadmin->addNavigation('index.php') ; + echo $indexadmin->renderIndex(); + +include "admin_footer.php"; Added: XoopsModules/backup/trunk/backup/admin/main.php =================================================================== --- XoopsModules/backup/trunk/backup/admin/main.php (rev 0) +++ XoopsModules/backup/trunk/backup/admin/main.php 2012-04-11 04:13:25 UTC (rev 9298) @@ -0,0 +1,52 @@ +<?php +include_once '../../../include/cp_header.php'; +include_once 'admin_header.php'; +include_once XOOPS_ROOT_PATH."/modules/" . $xoopsModule->getVar("dirname") . "/include/functions.php"; +if ( file_exists("../language/".$xoopsConfig['language']."/admin.php") ) { + include_once "../language/".$xoopsConfig['language']."/admin.php"; +} else { +include_once "../language/english/admin.php"; +} + +$op = !empty( $_GET[ 'op' ] ) ? $_GET['op'] :"index"; + +switch ($op) +{ + case "backup": + xoops_cp_header(); + $index_admin = new ModuleAdmin(); + echo $index_admin->addNavigation('main.php?op=backup'); + if (isset($_POST['backup']) && $_POST['backup']=="confirm_backup") + { + header ('location: backup.php?oldurl='.$_SERVER['PHP_SELF']); + exit(); + } + xoops_confirm(array( 'backup' => "confirm_backup" ), 'main.php?op=backup', _AM_DBASE_BACKUP); + break; + + case "delete": + xoops_cp_header(); + $index_admin = new ModuleAdmin(); + echo $index_admin->addNavigation('main.php?op=delete'); + if (isset($_POST['delete']) && $_POST['delete']=="confirm_delete") + { + $dirpath=XOOPS_ROOT_PATH.'/'.$xoopsModuleConfig['dbfiles_path'].'/'; + $handle = opendir($dirpath); + while (($file = readdir($handle)) !== false) { + if ( $file != ".." && $file != "." && substr($file,0,1)!='.' ) + @unlink($dirpath . $file); + } + closedir($handle); + redirect_header("index.php", 2, _AM_DBASE_FILES_DELETED); + exit(); + } + xoops_confirm(array( 'delete' => "confirm_delete" ), 'main.php?op=delete', _AM_DBASE_DELETE); + break; + + case "index": + header ('location: index.php'); + exit(); + break; +} + +include "admin_footer.php"; Added: XoopsModules/backup/trunk/backup/admin/menu.php =================================================================== --- XoopsModules/backup/trunk/backup/admin/menu.php (rev 0) +++ XoopsModules/backup/trunk/backup/admin/menu.php 2012-04-11 04:13:25 UTC (rev 9298) @@ -0,0 +1,59 @@ +<?php +// $Id: menu.php,v 1.7 2003/04/17 12:45:28 okazu Exp $ +// ------------------------------------------------------------------------ // +// XOOPS - PHP Content Management System // +// Copyright (c) 2000 XOOPS.org // +// <http://www.xoops.org/> // +// ------------------------------------------------------------------------ // +// 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 // +// ------------------------------------------------------------------------ // + +$module_handler =& xoops_gethandler('module'); +$xoopsModule =& XoopsModule::getByDirname('profile'); +$moduleInfo =& $module_handler->get($xoopsModule->getVar('mid')); +$pathIcon32 = $moduleInfo->getInfo('icons32'); + +$i = 1; +$adminmenu[$i]['title'] = _MI_BACKUP_ADMIN_HOME; +$adminmenu[$i]['link'] = 'admin/index.php'; +$adminmenu[$i]['desc'] = _MI_BACKUP_ADMIN_HOME_DESC; +$adminmenu[$i]['icon'] = '../../'.$pathIcon32.'/home.png' ; +$i++; +$adminmenu[$i]['title'] = _MI_BACKUP_ADMENU2; +$adminmenu[$i]['link'] = "admin/main.php?op=backup"; +$adminmenu[$i]['icon'] = 'images/admin/database.png'; +$i++; +$adminmenu[$i]['title'] = _MI_BACKUP_ADMENU3; +$adminmenu[$i]['link'] = "admin/other.php"; +$adminmenu[$i]['icon'] = 'images/admin/database_add.png'; +$i++; +$adminmenu[$i]['title'] = _MI_BACKUP_ADMENU4; +$adminmenu[$i]['link'] = "admin/restore.php"; +$adminmenu[$i]['icon'] = 'images/admin/restore.png'; +$i++; +$adminmenu[$i]['title'] = _MI_BACKUP_ADMENU5; +$adminmenu[$i]['link'] = "admin/main.php?op=delete"; +$adminmenu[$i]['icon'] = 'images/admin/delete.png'; +$i++; +$adminmenu[$i]['title'] = _MI_BACKUP_ADMIN_ABOUT; +$adminmenu[$i]['link'] = 'admin/about.php'; +$adminmenu[$i]['desc'] = _MI_BACKUP_ADMIN_ABOUT_DESC; +$adminmenu[$i]['icon'] = '../../'.$pathIcon32.'/about.png'; +?> Added: XoopsModules/backup/trunk/backup/admin/other.php =================================================================== --- XoopsModules/backup/trunk/backup/admin/other.php (rev 0) +++ XoopsModules/backup/trunk/backup/admin/other.php 2012-04-11 04:13:25 UTC (rev 9298) @@ -0,0 +1,78 @@ +<?php +// $Id: admin_forum_prune.php,v 1.3 2005/10/19 17:20:32 phppp Exp $ +// ------------------------------------------------------------------------ // +// XOOPS - PHP Content Management System // +// Copyright (c) 2000 XOOPS.org // +// <http://www.xoops.org/> // +// ------------------------------------------------------------------------ // +// 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_once '../../../include/cp_header.php'; +include 'admin_header.php'; +include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php"; + + xoops_cp_header(); + $indexAdmin = new ModuleAdmin(); + echo $indexAdmin->addNavigation('other.php'); + if (!empty($_POST['db_name'])) { + $db = $_POST['db_name']; + + $db_selected = mysql_select_db($db); + if (!$db_selected) { + redirect_header('other.php', 3, 'Database not exist'); + } + + $sql = "SHOW TABLES FROM $db"; + $tables = mysql_query($sql); + $num_tables = @mysql_numrows($tables); + + $options = array(0=>_NONE, 1=>_ALL); + for($i=0; $i<$num_tables; $i++){ + $name = mysql_tablename($tables, $i); + $options[$name] = $name; + } + + $sform = new XoopsThemeForm(_DB_BACKUP_TITLE, 'name', 'backup.php?oldurl='.$_SERVER['PHP_SELF'].'&db_name='.$db, 'post'); + $tab_select = new XoopsFormSelect(_DB_TABLES, 'tables', null, 6,true); + $tab_select->addOptionArray($options); + $sform->addElement($tab_select, true); + $button_tray = new XoopsFormElementTray('' ,''); + $submit_btn = new XoopsFormButton('', 'post', _SUBMIT, 'submit'); + $button_tray->addElement($submit_btn); + $sform->addElement($button_tray); + $sform->display(); + + } else { + + $sform = new XoopsThemeForm(_DB_BACKUP_TITLE, 'name', 'other.php', 'post'); + $sform->addElement(new XoopsFormText(_DB_DBASE, 'db_name', 50, 255, ""), true); + $button_tray = new XoopsFormElementTray('' ,''); + $submit_btn = new XoopsFormButton('', 'post', _SUBMIT, 'submit'); + $button_tray->addElement($submit_btn); + $sform->addElement($button_tray); + $sform->display(); + } + //$submit_btn = new XoopsFormButton('', 'post', _SUBMIT, 'submit'); + //$button_tray->addElement($submit_btn); + //$sform->addElement($button_tray); + //$sform->display(); +include 'admin_footer.php'; + +?> Modified: XoopsModules/backup/trunk/backup/admin/restore.php =================================================================== --- XoopsModules/backup/trunk/backup/admin/restore.php 2012-04-11 04:10:37 UTC (rev 9297) +++ XoopsModules/backup/trunk/backup/admin/restore.php 2012-04-11 04:13:25 UTC (rev 9298) @@ -1,298 +1,287 @@ -<?php - -// BigDump ver. 0.21b from 2005-02-08 -// Staggered import of an large MySQL Dump (like phpMyAdmin 2.x Dump) -// Even through the webservers with hard runtime limit and those in safe mode -// Works fine with Internet Explorer 6.0 SP1, Mozilla 1.x and even Netscape 4.8 - -// Author: Alexey Ozerov (alexey at ozerov dot de) -// Copyright: GPL (C) 2003-2005 -// More Infos: http://www.ozerov.de/bigdump - - -// ------------------------------------------------------------------------ // -// Author: D.J.(phppp) ph...@ho... // -// URL: http://xoops.org.cn // -// ------------------------------------------------------------------------- // - -ini_set("auto_detect_line_endings", true); - -$linespersession = 5000; // Lines to be executed per one import session -$delaypersession = 2000; // You can specify a sleep time in milliseconds after each session - // Works only if JavaScript is activated. Use to reduce server overrun - -// Allowed comment delimiters: lines starting with these strings will be dropped by BigDump - -$comment[0]="#"; // Standard comment lines are dropped by default -$comment[1]="-- "; -// $comment[2]="---"; // Uncomment this line if using proprietary dump created by outdated mysqldump -// $comment[3]=""; // Or add your own string to leave out other proprietary things - -define ("MAX_LINE_LENGTH",65536); -define ("MAX_QUERY_LINES",300); - -include("../../../mainfile.php"); -require_once(XOOPS_ROOT_PATH . "/include/cp_functions.php"); -require_once(XOOPS_ROOT_PATH . "/modules/backup/include/functions.php"); -require_once(XOOPS_ROOT_PATH.'/class/xoopslists.php'); // Merci, christian -$_REQUEST["NA"] = empty($_REQUEST["NA"])?0:1; -if(empty($_REQUEST["NA"])){ - include ('admin_header.php'); - $module_handler =& xoops_gethandler('module'); - $xoopsModule =& $module_handler->getByDirname('backup'); - $config_handler = & xoops_gethandler( 'config' ); - $xoopsModuleConfig = & $config_handler->getConfigsByCat( 0, $xoopsModule->getVar( 'mid' ) ); -}else{ - $xoopsModuleConfig = & backup_import(); - if(empty($xoopsModuleConfig["restore_nonadmin"])){ - include('admin_header.php'); - }else{ - if ( file_exists( XOOPS_ROOT_PATH."/modules/backup/language/" . $xoopsConfig['language'] . "/admin.php" ) ) { - include XOOPS_ROOT_PATH."/modules/backup/language/" . $xoopsConfig['language'] . "/admin.php"; - } - elseif ( file_exists( XOOPS_ROOT_PATH."/modules/backup/language/english/admin.php" ) ) { - include XOOPS_ROOT_PATH."/modules/backup/language/english/admin.php"; - } - } -} - -xoops_cp_header(); - -$dirname = XOOPS_ROOT_PATH.'/'.$xoopsModuleConfig["dbfiles_path"]; - -if(empty($_REQUEST["fn"])){ - $db_files =& XoopsLists::getFileListAsArray($dirname); - echo "<form method=\"post\">\n"; - echo _DB_SELECTFILE.": <select name=\"fn\" id=\"fn\">\n"; - foreach($db_files as $_file => $_filename){ - if (eregi("\.sql$",$_file) || (eregi("\.gz$",$_file) && function_exists("gzopen"))){ - echo "<option value=\"".$_file."\">".$_file."</option>\n"; - } - } - echo "</select>\n"; - echo "<input type=\"hidden\" name=\"NA\" value=".$_REQUEST["NA"].">\n"; - echo "<input type=\"submit\" value=\""._GO."\">\n"; - echo "</form>\n"; -}else{ - - $error=false; - // Recognize GZip filename - - if (eregi("\.gz$",$_REQUEST["fn"])) - $gzipmode=true; - else - $gzipmode=false; - - if ((!$gzipmode && !$file=fopen($dirname."/".$_REQUEST["fn"],"rt")) || ($gzipmode && !$file=gzopen($dirname."/".$_REQUEST["fn"],"rt"))) - { - echo ("<p class=\"error\">Can't open ".$_REQUEST["fn"]." for import</p>\n"); - $error=true; - } - - // Get the file size (can't do it fast on gzipped files, no idea how) - - else if ((!$gzipmode && fseek($file, 0, SEEK_END)==0) || ($gzipmode && gzseek($file, 0, SEEK_SET)==0)) - { if (!$gzipmode) $filesize = ftell($file); - else $filesize = gztell($file); // Always zero, ignore - } - else - { echo ("<p class=\"error\">I can't get the filesize of ".$_REQUEST["fn"]."</p>\n"); - $error=true; - } - - - $dbconnection=$xoopsDB->conn; - // **************************************************** - // START IMPORT SESSION HERE - // **************************************************** - - $_REQUEST["start"] = isset($_REQUEST["start"])?intval($_REQUEST["start"]):1; - $_REQUEST["foffset"] = isset($_REQUEST["foffset"])?intval($_REQUEST["foffset"]):0; - $_REQUEST["totalqueries"] = isset($_REQUEST["totalqueries"])?intval($_REQUEST["totalqueries"]):0; - - if (!$error) - { - echo ("<p>Processing file: ".$_REQUEST["fn"]."</p>\n"); - echo ("<p>Starting at the line: ".$_REQUEST["start"]."</p>\n"); - - // Check $_REQUEST["foffset"] upon $filesize (can't do it on gzipped files) - - if (!$gzipmode && $_REQUEST["foffset"]>$filesize) - { echo ("<p class=\"error\">UNEXPECTED: Can't set file pointer behind the end of file</p>\n"); - $error=true; - } - - // Set file pointer to $_REQUEST["foffset"] - - if(empty($xoopsModuleConfig["pos_line"])){ - if (!$error && ((!$gzipmode && fseek($file, $_REQUEST["foffset"])!=0) || ($gzipmode && gzseek($file, $_REQUEST["foffset"])!=0))) - { echo ("<p class=\"error\">UNEXPECTED: Can't set file pointer to offset: ".$_REQUEST["foffset"]."</p>\n"); - $error=true; - } - $linenumber=$_REQUEST["start"]; - }else{ - if (!$error && ((!$gzipmode && fseek($file, 0)!=0) || ($gzipmode && gzseek($file, 0)!=0))) - { echo ("<p class=\"error\">UNEXPECTED: Can't set file pointer to offset: ".$_REQUEST["foffset"]."</p>\n"); - $error=true; - } - $linenumber = 1; - } - - - // Start processing queries from $file - - if (!$error) - { - $query=""; - $queries=0; - $totalqueries=$_REQUEST["totalqueries"]; - //$linenumber=$_REQUEST["start"]; - $querylines=0; - $inparents=false; - - //echo "<br />ln: ".$linenumber."; totalqueries: ".$_REQUEST["totalqueries"]; - while (($linenumber<$_REQUEST["start"]+$linespersession || $query!="") - && ((!$gzipmode && $dumpline=fgets($file, MAX_LINE_LENGTH)) || ($gzipmode && $dumpline=gzgets($file, MAX_LINE_LENGTH)))) - { - if(!empty($xoopsModuleConfig["pos_line"]) && $linenumber<$_REQUEST["start"]){ - $linenumber++; - continue; - } - //echo "<br />ln: ".$linenumber."; start: ".$_REQUEST["start"]; - - // Handle DOS and Mac encoded linebreaks (I don't know if it will work on Win32 or Mac Servers) - - $dumpline=ereg_replace("\r\n$", "\n", $dumpline); - $dumpline=ereg_replace("\r$", "\n", $dumpline); - - // DIAGNOSTIC - // echo ("<p>Line $linenumber: $dumpline</p>\n"); - - // Skip comments and blank lines only if NOT in parents - - if (!$inparents) - { $skipline=false; - reset($comment); - foreach ($comment as $comment_value) - { if (!$inparents && (trim($dumpline)=="" || strpos ($dumpline, $comment_value) === 0)) - { $skipline=true; - break; - } - } - if ($skipline) - { $linenumber++; - continue; - } - } - - // Remove double back-slashes from the dumpline prior to count the quotes ('\\' can only be within strings) - - $dumpline_deslashed = str_replace ("\\\\","",$dumpline); - - // Count ' and \' in the dumpline to avoid query break within a text field ending by ; - // Please don't use double quotes ('"')to surround strings, it wont work - - $parents=substr_count ($dumpline_deslashed, "'")-substr_count ($dumpline_deslashed, "\\'"); - if ($parents % 2 != 0) - $inparents=!$inparents; - - // Add the line to query - - $query .= $dumpline; - - // Don't count the line if in parents (text fields may include unlimited linebreaks) - - if (!$inparents) - $querylines++; - - // Stop if query contains more lines as defined by MAX_QUERY_LINES - - if ($querylines>MAX_QUERY_LINES) - { - echo ("<p class=\"error\">Stopped at the line $linenumber. </p>"); - echo ("<p>At this place the current query includes more than ".MAX_QUERY_LINES." dump lines. That can happen if your dump file was "); - echo ("created by some tool which doesn't place a semicolon followed by a linebreak at the end of each query, or if your dump contains "); - echo ("extended inserts. Please read the BigDump FAQs for more infos.</p>\n"); - $error=true; - break; - } - - // Execute query if end of query detected (; as last character) AND NOT in parents - - if (ereg(";$",trim($dumpline)) && !$inparents) - { - if (!mysql_query(trim($query), $dbconnection)) - //if (false) - { - echo ("<p>Error at the line $linenumber: ". trim($dumpline)."</p>\n"); - echo ("<p>Query: ".trim($query)."</p>\n"); - echo ("<p>MySQL: ".mysql_error()."</p>\n"); - $error=true; - break; - }else{ - //echo ("<p>line #".$linenumber.": ".trim($query)."<br />dumpline: ".$dumpline."</p>\n"); - } - //echo "<br />query: ".$query; - $totalqueries++; - $queries++; - $query=""; - $querylines=0; - } - $linenumber++; - } - } - - // Get the current file position - - if (!$error) - { if (!$gzipmode) - $foffset = ftell($file); - else - $foffset = gztell($file); - if (!$foffset) - { echo ("<p class=\"error\">UNEXPECTED: Can't read the file pointer offset</p>\n"); - $error=true; - } - } - - // Finish message and restart the script - - if (!$error) - { echo ("<p>Stopping at the line: ".($linenumber-1)."</p>\n"); - echo ("<p>Queries performed (this session/total): $queries/$totalqueries</p>\n"); - echo ("<p>Total bytes processed: $foffset (".round($foffset/1024)." KB)</p>\n"); - if ($linenumber<$_REQUEST["start"]+$linespersession) - { - echo ("<p class=\"success\">Congratulations: End of file reached, assuming OK</p>\n"); - $over=true; - } - else - { - if ($delaypersession!=0){ - echo ("<p>Now I'm <b>waiting $delaypersession milliseconds</b> before starting next session...</p>\n"); - } - echo ("<script language=\"JavaScript\" type=\"text/javascript\">window.setTimeout('location.href=\"".$_SERVER["PHP_SELF"]."?start=$linenumber&fn=".$_REQUEST["fn"]."&foffset=$foffset&totalqueries=$totalqueries&NA=".$_REQUEST["NA"]."\";',500+$delaypersession);</script>\n"); - echo ("<noscript>\n"); - echo ("<p><a href=\"".$_SERVER["PHP_SELF"]."?start=$linenumber&fn=".$_REQUEST["fn"]."&foffset=$foffset&totalqueries=$totalqueries\">Continue from the line $linenumber</a> (Enable JavaScript to do it automatically)</p>\n"); - echo ("</noscript>\n"); - echo ("<p>Press <a href=\"".$_SERVER["PHP_SELF"]."\">STOP</a> to abort the import <b>OR WAIT!</b></p>\n"); - } - } - else - echo ("<p class=\"error\">Stopped on error</p>\n"); - } - - if ($error){ - echo ("<p><a href=\"".$_SERVER["PHP_SELF"]."?&NA=".$_REQUEST["NA"]."\">Start from the beginning</a> (DROP the old tables before restarting)</p>\n"); - }elseif(!empty($over)){ - echo ("<p><a href=\"".$_SERVER["PHP_SELF"]."?&NA=".$_REQUEST["NA"]."\">Start another file</a></p>\n"); - echo ("<p><a href=\"".XOOPS_URL."/modules/backup/admin/index.php\">Back to index page</a></p>\n"); - //unlink($dirname."/".$_REQUEST["fn"]); - } - - if ($file && !$gzipmode) fclose($file); - else if ($file && $gzipmode) gzclose($file); - -} -xoops_cp_footer(); -?> \ No newline at end of file +<?php + +// BigDump ver. 0.21b from 2005-02-08 +// Staggered import of an large MySQL Dump (like phpMyAdmin 2.x Dump) +// Even through the webservers with hard runtime limit and those in safe mode +// Works fine with Internet Explorer 6.0 SP1, Mozilla 1.x and even Netscape 4.8 + +// Author: Alexey Ozerov (alexey at ozerov dot de) +// Copyright: GPL (C) 2003-2005 +// More Infos: http://www.ozerov.de/bigdump + + +// ------------------------------------------------------------------------ // +// Author: D.J.(phppp) ph...@ho... // +// URL: http://xoops.org.cn // +// ------------------------------------------------------------------------- // + +ini_set("auto_detect_line_endings", true); + +$linespersession = 5000; // Lines to be executed per one import session +$delaypersession = 2000; // You can specify a sleep time in milliseconds after each session + // Works only if JavaScript is activated. Use to reduce server overrun + +// Allowed comment delimiters: lines starting with these strings will be dropped by BigDump + +$comment[0]="#"; // Standard comment lines are dropped by default +$comment[1]="-- "; +// $comment[2]="---"; // Uncomment this line if using proprietary dump created by outdated mysqldump +// $comment[3]=""; // Or add your own string to leave out other proprietary things + +define ("MAX_LINE_LENGTH",65536); +define ("MAX_QUERY_LINES",300); +include('admin_header.php'); +require_once(XOOPS_ROOT_PATH . "/include/cp_functions.php"); +require_once(XOOPS_ROOT_PATH . "/modules/backup/include/functions.php"); +require_once(XOOPS_ROOT_PATH.'/class/xoopslists.php'); // Merci, christian + + $xoopsModuleConfig = & backup_import(); + +xoops_cp_header(); +$indexAdmin = new ModuleAdmin(); +echo $indexAdmin->addNavigation('restore.php'); +$dirname = XOOPS_ROOT_PATH.'/'.$xoopsModuleConfig["dbfiles_path"]; +$db_name=(empty($_POST['db_name']))?XOOPS_DB_NAME:$_POST['db_name']; + +if(empty($_REQUEST["fn"])){ + $db_files =& XoopsLists::getFileListAsArray($dirname); + echo "<form method=\"post\">\n"; + echo _DB_INSERT.": <input type=\"text\" name=\"db_name\" value=\"".XOOPS_DB_NAME."\">\n"; + echo _DB_SELECTFILE.": <select name=\"fn\" id=\"fn\">\n"; + foreach($db_files as $_file => $_filename){ + if (preg_match("/\.sql$/i",$_file) || (preg_match("/\.gz$/i",$_file) && function_exists("gzopen"))){ + echo "<option value=\"".$_file."\">".$_file."</option>\n"; + } + } + echo "</select>\n"; + echo "<input type=\"submit\" value=\""._GO."\">\n"; + echo "</form>\n"; +}else{ + + $error=false; + // Recognize GZip filename + + if (preg_match("/\.gz$/i",$_REQUEST["fn"])) + $gzipmode=true; + else + $gzipmode=false; + + if ((!$gzipmode && !$file=fopen($dirname."/".$_REQUEST["fn"],"rt")) || ($gzipmode && !$file=gzopen($dirname."/".$_REQUEST["fn"],"rt"))) + { + echo ("<p class=\"error\">Can't open ".$_REQUEST["fn"]." for import</p>\n"); + $error=true; + } + + // Get the file size (can't do it fast on gzipped files, no idea how) + + else if ((!$gzipmode && fseek($file, 0, SEEK_END)==0) || ($gzipmode && gzseek($file, 0, SEEK_SET)==0)) + { if (!$gzipmode) $filesize = ftell($file); + else $filesize = gztell($file); // Always zero, ignore + } + else + { echo ("<p class=\"error\">I can't get the filesize of ".$_REQUEST["fn"]."</p>\n"); + $error=true; + } + + + $dbconnection=$xoopsDB->conn; + if (!mysql_select_db($db_name)) { + redirect_header('index.php', 3, 'Database not exist'); + exit; + } + @mysql_select_db($db_name, $dbconnection); + + // **************************************************** + // START IMPORT SESSION HERE + // **************************************************** + + $_REQUEST["start"] = isset($_REQUEST["start"])?intval($_REQUEST["start"]):1; + $_REQUEST["foffset"] = isset($_REQUEST["foffset"])?intval($_REQUEST["foffset"]):0; + $_REQUEST["totalqueries"] = isset($_REQUEST["totalqueries"])?intval($_REQUEST["totalqueries"]):0; + + if (!$error) + { + echo ("<p>Processing file: ".$_REQUEST["fn"]."</p>\n"); + echo ("<p>Starting at the line: ".$_REQUEST["start"]."</p>\n"); + + // Check $_REQUEST["foffset"] upon $filesize (can't do it on gzipped files) + + if (!$gzipmode && $_REQUEST["foffset"]>$filesize) + { echo ("<p class=\"error\">UNEXPECTED: Can't set file pointer behind the end of file</p>\n"); + $error=true; + } + + // Set file pointer to $_REQUEST["foffset"] + + if(empty($xoopsModuleConfig["pos_line"])){ + if (!$error && ((!$gzipmode && fseek($file, $_REQUEST["foffset"])!=0) || ($gzipmode && gzseek($file, $_REQUEST["foffset"])!=0))) + { echo ("<p class=\"error\">UNEXPECTED: Can't set file pointer to offset: ".$_REQUEST["foffset"]."</p>\n"); + $error=true; + } + $linenumber=$_REQUEST["start"]; + }else{ + if (!$error && ((!$gzipmode && fseek($file, 0)!=0) || ($gzipmode && gzseek($file, 0)!=0))) + { echo ("<p class=\"error\">UNEXPECTED: Can't set file pointer to offset: ".$_REQUEST["foffset"]."</p>\n"); + $error=true; + } + $linenumber = 1; + } + + + // Start processing queries from $file + + if (!$error) + { + $query=""; + $queries=0; + $totalqueries=$_REQUEST["totalqueries"]; + //$linenumber=$_REQUEST["start"]; + $querylines=0; + $inparents=false; + + //echo "<br />ln: ".$linenumber."; totalqueries: ".$_REQUEST["totalqueries"]; + while (($linenumber<$_REQUEST["start"]+$linespersession || $query!="") + && ((!$gzipmode && $dumpline=fgets($file, MAX_LINE_LENGTH)) || ($gzipmode && $dumpline=gzgets($file, MAX_LINE_LENGTH)))) + { + if(!empty($xoopsModuleConfig["pos_line"]) && $linenumber<$_REQUEST["start"]){ + $linenumber++; + continue; + } + //echo "<br />ln: ".$linenumber."; start: ".$_REQUEST["start"]; + + // Handle DOS and Mac encoded linebreaks (I don't know if it will work on Win32 or Mac Servers) + + $dumpline=preg_replace("/\r\n$/", "\n", $dumpline); + $dumpline=preg_replace("/\r$/", "\n", $dumpline); + + // DIAGNOSTIC + // echo ("<p>Line $linenumber: $dumpline</p>\n"); + + // Skip comments and blank lines only if NOT in parents + + if (!$inparents) + { $skipline=false; + reset($comment); + foreach ($comment as $comment_value) + { if (!$inparents && (trim($dumpline)=="" || strpos ($dumpline, $comment_value) === 0)) + { $skipline=true; + break; + } + } + if ($skipline) + { $linenumber++; + continue; + } + } + + // Remove double back-slashes from the dumpline prior to count the quotes ('\\' can only be within strings) + + $dumpline_deslashed = str_replace ("\\\\","",$dumpline); + + // Count ' and \' in the dumpline to avoid query break within a text field ending by ; + // Please don't use double quotes ('"')to surround strings, it wont work + + $parents=substr_count ($dumpline_deslashed, "'")-substr_count ($dumpline_deslashed, "\\'"); + if ($parents % 2 != 0) + $inparents=!$inparents; + + // Add the line to query + + $query .= $dumpline; + + // Don't count the line if in parents (text fields may include unlimited linebreaks) + + if (!$inparents) + $querylines++; + + // Stop if query contains more lines as defined by MAX_QUERY_LINES + + if ($querylines>MAX_QUERY_LINES) + { + echo ("<p class=\"error\">Stopped at the line $linenumber. </p>"); + echo ("<p>At this place the current query includes more than ".MAX_QUERY_LINES." dump lines. That can happen if your dump file was "); + echo ("created by some tool which doesn't place a semicolon followed by a linebreak at the end of each query, or if your dump contains "); + echo ("extended inserts. Please read the BigDump FAQs for more infos.</p>\n"); + $error=true; + break; + } + + // Execute query if end of query detected (; as last character) AND NOT in parents + + if (preg_match("/;$/",trim($dumpline)) && !$inparents) + { + if (!mysql_query(trim($query), $dbconnection)) + //if (false) + { + echo ("<p>Error at the line $linenumber: ". trim($dumpline)."</p>\n"); + echo ("<p>Query: ".trim($query)."</p>\n"); + echo ("<p>MySQL: ".mysql_error()."</p>\n"); + $error=true; + break; + }else{ + //echo ("<p>line #".$linenumber.": ".trim($query)."<br />dumpline: ".$dumpline."</p>\n"); + } + //echo "<br />query: ".$query; + $totalqueries++; + $queries++; + $query=""; + $querylines=0; + } + $linenumber++; + } + } + + // Get the current file position + + if (!$error) + { if (!$gzipmode) + $foffset = ftell($file); + else + $foffset = gztell($file); + if (!$foffset) + { echo ("<p class=\"error\">UNEXPECTED: Can't read the file pointer offset</p>\n"); + $error=true; + } + } + + // Finish message and restart the script + + if (!$error) + { echo ("<p>Stopping at the line: ".($linenumber-1)."</p>\n"); + echo ("<p>Queries performed (this session/total): $queries/$totalqueries</p>\n"); + echo ("<p>Total bytes processed: $foffset (".round($foffset/1024)." KB)</p>\n"); + if ($linenumber<$_REQUEST["start"]+$linespersession) + { + echo ("<p class=\"success\">Congratulations: End of file reached, assuming OK</p>\n"); + $over=true; + } + else + { + if ($delaypersession!=0){ + echo ("<p>Now I'm <b>waiting $delaypersession milliseconds</b> before starting next session...</p>\n"); + } + echo ("<script language=\"JavaScript\" type=\"text/javascript\">window.setTimeout('location.href=\"".$_SERVER["PHP_SELF"]."?start=$linenumber&fn=".$_REQUEST["fn"]."&foffset=$foffset&totalqueries=$totalqueries&NA=".$_REQUEST["NA"]."\";',500+$delaypersession);</script>\n"); + echo ("<noscript>\n"); + echo (... [truncated message content] |