From: <be...@us...> - 2012-04-11 04:08:55
|
Revision: 9296 http://xoops.svn.sourceforge.net/xoops/?rev=9296&view=rev Author: beckmi Date: 2012-04-11 04:08:46 +0000 (Wed, 11 Apr 2012) Log Message: ----------- Adding Backup module Added Paths: ----------- XoopsModules/Backup-readme.txt XoopsModules/backup/ XoopsModules/backup/branches/ XoopsModules/backup/releases/ XoopsModules/backup/releases/3.0/ XoopsModules/backup/trunk/ XoopsModules/backup/trunk/backup/ XoopsModules/backup/trunk/backup/admin/ 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.html XoopsModules/backup/trunk/backup/admin/index.php XoopsModules/backup/trunk/backup/admin/restore.php XoopsModules/backup/trunk/backup/images/ XoopsModules/backup/trunk/backup/images/index.html XoopsModules/backup/trunk/backup/images/slogo.png XoopsModules/backup/trunk/backup/include/ 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/index.html XoopsModules/backup/trunk/backup/include/zip.lib.php XoopsModules/backup/trunk/backup/index.html XoopsModules/backup/trunk/backup/language/ XoopsModules/backup/trunk/backup/language/english/ XoopsModules/backup/trunk/backup/language/english/admin.php XoopsModules/backup/trunk/backup/language/english/index.html XoopsModules/backup/trunk/backup/language/english/modinfo.php XoopsModules/backup/trunk/backup/language/index.html XoopsModules/backup/trunk/backup/language/schinese/ XoopsModules/backup/trunk/backup/language/schinese/admin.php XoopsModules/backup/trunk/backup/language/schinese/index.html XoopsModules/backup/trunk/backup/language/schinese/modinfo.php XoopsModules/backup/trunk/backup/readme.txt XoopsModules/backup/trunk/backup/xoops_version.php Added: XoopsModules/Backup-readme.txt =================================================================== --- XoopsModules/Backup-readme.txt (rev 0) +++ XoopsModules/Backup-readme.txt 2012-04-11 04:08:46 UTC (rev 9296) @@ -0,0 +1,40 @@ +The place for XOOPS modules maintained by XOOPS Dev Team. +Each module is managed as a sub-project by lead authors. + +Structure: + +XoopsModules +-- dirname +----- branches +----- releases +----- trunk +-------- yourmodule (dirname of your module) +-- dirname +----- branches +----- releases +----- trunk +-------- yourmodule (dirname of your module) + + + +SVN Related links: + +1) SVN Best Practices: +http://svn.apache.org/repos/asf/subversion/trunk/doc/user/svn-best-practices.html + +2) TortoiseSVN (best Windows client for SVN): +http://tortoisesvn.net/ + +2) Using Subversion at PLU with Tortoise SVN +http://www.cs.plu.edu/~dwolff/svn-tutorial/svn-tutorial.html + +3) How to use TortoiseSVN: Tutorials +http://www.youtube.com/watch?v=fPUdXvjY_G4 (video) +http://baltimorehackerspace.com/2009/07/sourceforge-and-tortoisesvn-tutorial/ +http://www.igorexchange.com/node/87 + +4) Version Control with Subversion +http://svnbook.red-bean.com/ + +5) For file comparison, WinMerge works with Tortoise SVN +http://winmerge.org/ \ No newline at end of file Added: XoopsModules/backup/trunk/backup/admin/admin_header.php =================================================================== --- XoopsModules/backup/trunk/backup/admin/admin_header.php (rev 0) +++ XoopsModules/backup/trunk/backup/admin/admin_header.php 2012-04-11 04:08:46 UTC (rev 9296) @@ -0,0 +1,3 @@ +<?php +include("../../../include/cp_header.php"); +?> \ No newline at end of file Added: XoopsModules/backup/trunk/backup/admin/backup.php =================================================================== --- XoopsModules/backup/trunk/backup/admin/backup.php (rev 0) +++ XoopsModules/backup/trunk/backup/admin/backup.php 2012-04-11 04:08:46 UTC (rev 9296) @@ -0,0 +1,228 @@ +<?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 Added: XoopsModules/backup/trunk/backup/admin/cache.php =================================================================== --- XoopsModules/backup/trunk/backup/admin/cache.php (rev 0) +++ XoopsModules/backup/trunk/backup/admin/cache.php 2012-04-11 04:08:46 UTC (rev 9296) @@ -0,0 +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(); +?> \ No newline at end of file Added: XoopsModules/backup/trunk/backup/admin/index.html =================================================================== --- XoopsModules/backup/trunk/backup/admin/index.html (rev 0) +++ XoopsModules/backup/trunk/backup/admin/index.html 2012-04-11 04:08:46 UTC (rev 9296) @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Added: XoopsModules/backup/trunk/backup/admin/index.php =================================================================== --- XoopsModules/backup/trunk/backup/admin/index.php (rev 0) +++ XoopsModules/backup/trunk/backup/admin/index.php 2012-04-11 04:08:46 UTC (rev 9296) @@ -0,0 +1,35 @@ +<?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 Added: XoopsModules/backup/trunk/backup/admin/restore.php =================================================================== --- XoopsModules/backup/trunk/backup/admin/restore.php (rev 0) +++ XoopsModules/backup/trunk/backup/admin/restore.php 2012-04-11 04:08:46 UTC (rev 9296) @@ -0,0 +1,298 @@ +<?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 Added: XoopsModules/backup/trunk/backup/images/index.html =================================================================== --- XoopsModules/backup/trunk/backup/images/index.html (rev 0) +++ XoopsModules/backup/trunk/backup/images/index.html 2012-04-11 04:08:46 UTC (rev 9296) @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Added: XoopsModules/backup/trunk/backup/images/slogo.png =================================================================== (Binary files differ) Property changes on: XoopsModules/backup/trunk/backup/images/slogo.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: XoopsModules/backup/trunk/backup/include/build_dump.lib.php =================================================================== --- XoopsModules/backup/trunk/backup/include/build_dump.lib.php (rev 0) +++ XoopsModules/backup/trunk/backup/include/build_dump.lib.php 2012-04-11 04:08:46 UTC (rev 9296) @@ -0,0 +1,498 @@ +<?php +/* $Id: build_dump.lib.php,v 1.17 2002/02/17 11:59:04 loic1 Exp $ */ + + +/** + * Set of functions used to build dumps of tables + */ + + + +if (!defined('PMA_BUILD_DUMP_LIB_INCLUDED')){ + define('PMA_BUILD_DUMP_LIB_INCLUDED', 1); + + function PMA_sqlAddslashes($a_string = '', $is_like = FALSE) + { + if ($is_like) { + $a_string = str_replace('\\', '\\\\\\\\', $a_string); + } else { + $a_string = str_replace('\\', '\\\\', $a_string); + } + $a_string = str_replace('\'', '\\\'', $a_string); + + return $a_string; + } // end of the 'PMA_sqlAddslashes()' function + + function PMA_mysqlDie($error_message = '', $the_query = '', + $is_modify_link = TRUE, $back_url = '') + { + + include($xoopsConfig['root_path']."header.php"); + opentable(); + + if (!$error_message) { + $error_message = mysql_error(); + } + if (!$the_query && !empty($GLOBALS['sql_query'])) { + $the_query = $GLOBALS['sql_query']; + } + + echo '<p><b>'. $GLOBALS['strError'] . '</b></p>' . "\n"; + // if the config password is wrong, or the MySQL server does not + // respond, do not show the query that would reveal the + // username/password + if (!empty($the_query) && !strstr($the_query, 'connect')) { + $query_base = htmlspecialchars($the_query); + $query_base = ereg_replace("((\015\012)|(\015)|(\012)){3,}", "\n\n", $query_base); + echo '<p>' . "\n"; + echo ' ' . $GLOBALS['strSQLQuery'] . ' : ' . "\n"; + if ($is_modify_link) { + echo ' [' + . '<a href="db_details.php?lang=' . $GLOBALS['lang'] . '&server=' . urlencode($GLOBALS['server']) . '&db=' . urlencode($GLOBALS['db']) . '&sql_query=' . urlencode($the_query) . '&show_query=y">' . $GLOBALS['strEdit'] . '</a>' + . ']' . "\n"; + } // end if + echo '<pre>' . "\n" . $query_base . "\n" . '</pre>' . "\n"; + echo '</p>' . "\n"; + } // end if + if (!empty($error_message)) { + $error_message = htmlspecialchars($error_message); + $error_message = ereg_replace("((\015\012)|(\015)|(\012)){3,}", "\n\n", $error_message); + } + echo '<p>' . "\n"; + echo ' ' . $GLOBALS['strMySQLSaid'] . '<br />' . "\n"; + echo '<pre>' . "\n" . $error_message . "\n" . '</pre>' . "\n"; + echo '</p>' . "\n"; + if (!empty($back_url)) { + echo '<a href="' . $back_url . '">' . $GLOBALS['strBack'] . '</a>'; + } + echo "\n"; + closetable(); + include($xoopsConfig['root_path']."header.php"); + exit(); + } // end of the 'PMA_mysqlDie()' function + + function PMA_backquote($a_name, $do_it = TRUE) + { + if ($do_it + && PMA_MYSQL_INT_VERSION >= 32306 + && !empty($a_name) && $a_name != '*') { + return '`' . $a_name . '`'; + } else { + return $a_name; + } + } // end of the 'PMA_backquote()' function + /** + * Uses the 'htmlspecialchars()' php function on databases, tables and fields + * name if the dump has to be displayed on screen. + * + * @param string the string to format + * + * @return string the formatted string + * + * @access private + */ + /** + * Returns $table's CREATE definition + * + * Uses the 'PMA_htmlFormat()' function defined in 'tbl_dump.php' + * + * @param string the database name + * @param string the table name + * @param string the end of line sequence + * @param string the url to go back in case of error + * + * @return string the CREATE statement on success + * + * @global boolean whether to add 'drop' statements or not + * @global boolean whether to use backquotes to allow the use of special + * characters in database, table and fields names or not + * + * @see PMA_htmlFormat() + * + * @access public + */ + function PMA_getTableDef($db, $table, $crlf, $error_url) + { + global $drop; + global $use_backquotes; + + $schema_create = ''; + if (!empty($drop)) { + $schema_create .= 'DROP TABLE IF EXISTS ' . PMA_backquote($table, $use_backquotes) . ';' . $crlf; + } + + // Steve Alberty's patch for complete table dump, + // modified by Lem9 to allow older MySQL versions to continue to work + if (PMA_MYSQL_INT_VERSION >= 32321) { + // Whether to quote table and fields names or not + if ($use_backquotes) { + mysql_query('SET SQL_QUOTE_SHOW_CREATE = 1'); + } else { + mysql_query('SET SQL_QUOTE_SHOW_CREATE = 0'); + } + $result = mysql_query('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table)); + if ($result != FALSE && mysql_num_rows($result) > 0) { + $tmpres = mysql_fetch_array($result); + $schema_create .= str_replace("\n", $crlf, $tmpres[1]); + } + mysql_free_result($result); + return $schema_create; + } // end if MySQL >= 3.23.20 + + // For MySQL < 3.23.20 + $schema_create .= 'CREATE TABLE ' . PMA_backquote($table, $use_backquotes) . ' (' . $crlf; + + $local_query = 'SHOW FIELDS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table); + $result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $error_url); + while ($row = mysql_fetch_array($result)) { + $schema_create .= ' ' . PMA_backquote($row['Field'], $use_backquotes) . ' ' . $row['Type']; + if (isset($row['Default']) && $row['Default'] != '') { + $schema_create .= ' DEFAULT \'' . PMA_sqlAddslashes($row['Default']) . '\''; + } + if ($row['Null'] != 'YES') { + $schema_create .= ' NOT NULL'; + } + if ($row['Extra'] != '') { + $schema_create .= ' ' . $row['Extra']; + } + $schema_create .= ',' . $crlf; + } // end while + mysql_free_result($result); + $schema_create = ereg_replace(',' . $crlf . '$', '', $schema_create); + + $local_query = 'SHOW KEYS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table); + $result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $error_url); + while ($row = mysql_fetch_array($result)) + { + $kname = $row['Key_name']; + $comment = (isset($row['Comment'])) ? $row['Comment'] : ''; + $sub_part = (isset($row['Sub_part'])) ? $row['Sub_part'] : ''; + + if ($kname != 'PRIMARY' && $row['Non_unique'] == 0) { + $kname = "UNIQUE|$kname"; + } + if ($comment == 'FULLTEXT') { + $kname = 'FULLTEXT|$kname'; + } + if (!isset($index[$kname])) { + $index[$kname] = array(); + } + if ($sub_part > 1) { + $index[$kname][] = PMA_backquote($row['Column_name'], $use_backquotes) . '(' . $sub_part . ')'; + } else { + $index[$kname][] = PMA_backquote($row['Column_name'], $use_backquotes); + } + } // end while + mysql_free_result($result); + + while (list($x, $columns) = @each($index)) { + $schema_create .= ',' . $crlf; + if ($x == 'PRIMARY') { + $schema_create .= ' PRIMARY KEY ('; + } else if (substr($x, 0, 6) == 'UNIQUE') { + $schema_create .= ' UNIQUE ' . substr($x, 7) . ' ('; + } else if (substr($x, 0, 8) == 'FULLTEXT') { + $schema_create .= ' FULLTEXT ' . substr($x, 9) . ' ('; + } else { + $schema_create .= ' KEY ' . $x . ' ('; + } + $schema_create .= implode($columns, ', ') . ')'; + } // end while + + $schema_create .= $crlf . ')'; + + return $schema_create; + } // end of the 'PMA_getTableDef()' function + + + /** + * php >= 4.0.5 only : get the content of $table as a series of INSERT + * statements. + * After every row, a custom callback function $handler gets called. + * + * Last revision 13 July 2001: Patch for limiting dump size from + * vi...@sa... & gi...@sa... + * + * @param string the current database name + * @param string the current table name + * @param string the 'limit' clause to use with the sql query + * @param string the name of the handler (function) to use at the end + * of every row. This handler must accept one parameter + * ($sql_insert) + * @param string the url to go back in case of error + * + * @return boolean always true + * + * @global boolean whether to use backquotes to allow the use of special + * characters in database, table and fields names or not + * @global integer the number of records + * @global integer the current record position + * + * @access private + * + * @see PMA_getTableContent() + * + * @author staybyte + */ + function PMA_getTableContentFast($db, $table, $add_query = '', $handler, $error_url) + { + global $use_backquotes; + global $rows_cnt; + global $current_row; + + $local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . $add_query; + $result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $error_url); + if ($result != FALSE) { + $fields_cnt = mysql_num_fields($result); + $rows_cnt = mysql_num_rows($result); + + // Checks whether the field is an integer or not + for ($j = 0; $j < $fields_cnt; $j++) { + $field_set[$j] = PMA_backquote(mysql_field_name($result, $j), $use_backquotes); + $type = mysql_field_type($result, $j); + if ($type == 'tinyint' || $type == 'smallint' || $type == 'mediumint' || $type == 'int' || + $type == 'bigint' ||$type == 'timestamp') { + $field_num[$j] = TRUE; + } else { + $field_num[$j] = FALSE; + } + } // end for + + // Sets the scheme + if (isset($GLOBALS['showcolumns'])) { + $fields = implode(', ', $field_set); + $schema_insert = 'INSERT INTO ' . PMA_backquote($table, $use_backquotes) + . ' (' . $fields . ') VALUES ('; + } else { + $schema_insert = 'INSERT INTO ' . PMA_backquote($table, $use_backquotes) + . ' VALUES ('; + } + + $search = array("\x00", "\x0a", "\x0d", "\x1a"); //\x08\\x09, not required + $replace = array('\0', '\n', '\r', '\Z'); + $current_row = 0; + + @set_time_limit($GLOBALS['cfgExecTimeLimit']); + + // loic1: send a fake header to bypass browser timeout if data + // are bufferized - part 1 +// $time0 = time(); + + while ($row = mysql_fetch_row($result)) { + $current_row++; + for ($j = 0; $j < $fields_cnt; $j++) { + if (!isset($row[$j])) { + $values[] = 'NULL'; + } else if ($row[$j] == '0' || $row[$j] != '') { + // a number + if ($field_num[$j]) { + $values[] = $row[$j]; + } + // a string + else { + $values[] = "'" . str_replace($search, $replace, PMA_sqlAddslashes($row[$j])) . "'"; + } + } else { + $values[] = "''"; + } // end if + } // end for + + // Extended inserts case + if (isset($GLOBALS['extended_ins'])) { + if ($current_row == 1) { + $insert_line = $schema_insert . implode(', ', $values) . ')'; + } else { + $insert_line = '(' . implode(', ', $values) . ')'; + } + } + // Other inserts case + else { + $insert_line = $schema_insert . implode(', ', $values) . ')'; + } + unset($values); + + // Call the handler + $handler($insert_line); + + // loic1: send a fake header to bypass browser timeout if data + // are bufferized - part 2 + if (isset($time0)) { + $time1 = time(); + if ($time1 >= $time0 + 30) { + $time0 = $time1; + header('X-pmaPing: Pong'); + } + } // end if + } // end while + } // end if ($result != FALSE) + mysql_free_result($result); + + return TRUE; + } // end of the 'PMA_getTableContentFast()' function + + + /** + * php < 4.0.5 only: get the content of $table as a series of INSERT + * statements. + * After every row, a custom callback function $handler gets called. + * + * Last revision 13 July 2001: Patch for limiting dump size from + * vi...@sa... & gi...@sa... + * + * @param string the current database name + * @param string the current table name + * @param string the 'limit' clause to use with the sql query + * @param string the name of the handler (function) to use at the end + * of every row. This handler must accept one parameter + * ($sql_insert) + * @param string the url to go back in case of error + * + * @return boolean always true + * + * @global boolean whether to use backquotes to allow the use of special + * characters in database, table and fields names or not + * @global integer the number of records + * @global integer the current record position + * + * @access private + * + * @see PMA_getTableContent() + */ + function PMA_getTableContentOld($db, $table, $add_query = '', $handler, $error_url) + { + global $use_backquotes; + global $rows_cnt; + global $current_row; + + $local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . $add_query; + $result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $error_url); + $current_row = 0; + $fields_cnt = mysql_num_fields($result); + $rows_cnt = mysql_num_rows($result); + + @set_time_limit($GLOBALS['cfgExecTimeLimit']); // HaRa + + // loic1: send a fake header to bypass browser timeout if data + // are bufferized - part 1 + $time0 = time(); + + while ($row = mysql_fetch_row($result)) { + $current_row++; + $table_list = '('; + for ($j = 0; $j < $fields_cnt; $j++) { + $table_list .= PMA_backquote(mysql_field_name($result, $j), $use_backquotes) . ', '; + } + $table_list = substr($table_list, 0, -2); + $table_list .= ')'; + + if (isset($GLOBALS['extended_ins']) && $current_row > 1) { + $schema_insert = '('; + } else { + if (isset($GLOBALS['showcolumns'])) { + $schema_insert = 'INSERT INTO ' . PMA_backquote($table, $use_backquotes) + . ' ' . $table_list . ' VALUES ('; + } else { + $schema_insert = 'INSERT INTO ' . PMA_backquote($table, $use_backquotes) + . ' VALUES ('; + } + $is_first_row = FALSE; + } + + for ($j = 0; $j < $fields_cnt; $j++) { + if (!isset($row[$j])) { + $schema_insert .= ' NULL, '; + } else if ($row[$j] == '0' || $row[$j] != '') { + $type = mysql_field_type($result, $j); + // a number + if ($type == 'tinyint' || $type == 'smallint' || $type == 'mediumint' || $type == 'int' || + $type == 'bigint' ||$type == 'timestamp') { + $schema_insert .= $row[$j] . ', '; + } + // a string + else { + $dummy = ''; + $srcstr = $row[$j]; + for ($xx = 0; $xx < strlen($srcstr); $xx++) { + $yy = strlen($dummy); + if ($srcstr[$xx] == '\\') $dummy .= '\\\\'; + if ($srcstr[$xx] == '\'') $dummy .= '\\\''; +// if ($srcstr[$xx] == '"') $dummy .= '\\"'; + if ($srcstr[$xx] == "\x00") $dummy .= '\0'; + if ($srcstr[$xx] == "\x0a") $dummy .= '\n'; + if ($srcstr[$xx] == "\x0d") $dummy .= '\r'; +// if ($srcstr[$xx] == "\x08") $dummy .= '\b'; +// if ($srcstr[$xx] == "\t") $dummy .= '\t'; + if ($srcstr[$xx] == "\x1a") $dummy .= '\Z'; + if (strlen($dummy) == $yy) $dummy .= $srcstr[$xx]; + } + $schema_insert .= "'" . $dummy . "', "; + } + } else { + $schema_insert .= "'', "; + } // end if + } // end for + $schema_insert = ereg_replace(', $', '', $schema_insert); + $schema_insert .= ')'; + $handler(trim($schema_insert)); + + // loic1: send a fake header to bypass browser timeout if data + // are bufferized - part 2 + if (isset($time0)) { + $time1 = time(); + if ($time1 >= $time0 + 30) { + $time0 = $time1; + header('X-pmaPing: Pong'); + } + } // end if + } // end while + mysql_free_result($result); + + return TRUE; + } // end of the 'PMA_getTableContentOld()' function + + + /** + * Dispatches between the versions of 'getTableContent' to use depending + * on the php version + * + * Last revision 13 July 2001: Patch for limiting dump size from + * vi...@sa... & gi...@sa... + * + * @param string the current database name + * @param string the current table name + * @param integer the offset on this table + * @param integer the last row to get + * @param string the name of the handler (function) to use at the end + * of every row. This handler must accept one parameter + * ($sql_insert) + * @param string the url to go back in case of error + * + * @access public + * + * @see PMA_getTableContentFast(), PMA_getTableContentOld() + * + * @author staybyte + */ + function PMA_getTableContent($db, $table, $limit_from = 0, $limit_to = 0, $handler, $error_url) + { + // Defines the offsets to use + if ($limit_from > 0) { + $limit_from--; + } else { + $limit_from = 0; + } + if ($limit_to > 0 && $limit_from >= 0) { + $add_query = " LIMIT $limit_from, $limit_to"; + } else { + $add_query = ''; + } + + // Call the working function depending on the php version + if (PMA_PHP_INT_VERSION >= 40005) { + PMA_getTableContentFast($db, $table, $add_query, $handler, $error_url); + } else { + PMA_getTableContentOld($db, $table, $add_query, $handler, $error_url); + } + } // end of the 'PMA_getTableContent()' function +} // $__PMA_BUILD_DUMP_LIB__ +?> Added: XoopsModules/backup/trunk/backup/include/defines.lib.php =================================================================== --- XoopsModules/backup/trunk/backup/include/defines.lib.php (rev 0) +++ XoopsModules/backup/trunk/backup/include/defines.lib.php 2012-04-11 04:08:46 UTC (rev 9296) @@ -0,0 +1,131 @@ +<?php +/* $Id: defines.lib.php,v 1.34 2002/04/21 18:15:21 lem9 Exp $ */ + +/** + * DEFINES VARIABLES & CONSTANTS + * Overview: + * PMA_VERSION (string) - phpMyAdmin version string + * PMA_PHP_INT_VERSION (int) - eg: 30017 instead of 3.0.17 or + * 40006 instead of 4.0.6RC3 + * PMA_IS_WINDOWS (bool) - mark if phpMyAdmin running on windows + * server + * PMA_MYSQL_INT_VERSION (int) - eg: 32339 instead of 3.23.39 + * PMA_USR_OS (string) - the plateform (os) of the user + * PMA_USR_BROWSER_AGENT (string) - the browser of the user + * PMA_USR_BROWSER_VER (double) - the version of this browser + */ +// phpMyAdmin release +if (!defined('PMA_VERSION')) { + define('PMA_VERSION', '2.2.6'); +} + +// php version +if (!defined('PMA_PHP_INT_VERSION')) { + if (!ereg('([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2})', phpversion(), $match)) { + $result = ereg('([0-9]{1,2}).([0-9]{1,2})', phpversion(), $match); + } + if (isset($match) && !empty($match[1])) { + if (!isset($match[2])) { + $match[2] = 0; + } + if (!isset($match[3])) { + $match[3] = 0; + } + define('PMA_PHP_INT_VERSION', (int)sprintf('%d%02d%02d', $match[1], $match[2], $match[3])); + unset($match); + } else { + define('PMA_PHP_INT_VERSION', 0); + } +} + +// Whether the os php is running on is windows or not +if (!defined('PMA_IS_WINDOWS')) { + if (defined('PHP_OS') && eregi('win', PHP_OS)) { + define('PMA_IS_WINDOWS', 1); + } else { + define('PMA_IS_WINDOWS', 0); + } +} + +// MySQL Version +if (!defined('PMA_MYSQL_INT_VERSION')) { + if (!empty($server)) { + $result = mysql_query('SELECT VERSION() AS version'); + if ($result != FALSE && @mysql_num_rows($result) > 0) { + $row = mysql_fetch_array($result); + $match = explode('.', $row['version']); + } else { + $result = @mysql_query('SHOW VARIABLES LIKE \'version\''); + if ($result != FALSE && @mysql_num_rows($result) > 0){ + $row = mysql_fetch_row($result); + $match = explode('.', $row[1]); + } + } + } // end server id is defined case + + if (!isset($match) || !isset($match[0])) { + $match[0] = 3; + } + if (!isset($match[1])) { + $match[1] = 21; + } + if (!isset($match[2])) { + $match[2] = 0; + } + + define('PMA_MYSQL_INT_VERSION', (int)sprintf('%d%02d%02d', $match[0], $match[1], intval($match[2]))); + unset($match); +} + + +// Determines platform (OS), browser and version of the user +// Based on a phpBuilder article: +// see http://www.phpbuilder.net/columns/tim20000821.php +if (!defined('PMA_USR_OS')) { + // loic1 - 2001/25/11: use the new globals arrays defined with + // php 4.1+ + if (!empty($_SERVER['HTTP_USER_AGENT'])) { + $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; + } else if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) { + $HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT']; + } else if (!isset($HTTP_USER_AGENT)) { + $HTTP_USER_AGENT = ''; + } + + // 1. Platform + if (strstr($HTTP_USER_AGENT, 'Win')) { + define('PMA_USR_OS', 'Win'); + } else if (strstr($HTTP_USER_AGENT, 'Mac')) { + define('PMA_USR_OS', 'Mac'); + } else if (strstr($HTTP_USER_AGENT, 'Linux')) { + define('PMA_USR_OS', 'Linux'); + } else if (strstr($HTTP_USER_AGENT, 'Unix')) { + define('PMA_USR_OS', 'Unix'); + } else if (strstr($HTTP_USER_AGENT, 'OS/2')) { + define('PMA_USR_OS', 'OS/2'); + } else { + define('PMA_USR_OS', 'Other'); + } + + // 2. browser and version + if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { + define('PMA_USR_BROWSER_VER', $log_version[2]); + define('PMA_USR_BROWSER_AGENT', 'OPERA'); + } else if (ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { + define('PMA_USR_BROWSER_VER', $log_version[1]); + define('PMA_USR_BROWSER_AGENT', 'IE'); + } else if (ereg('OmniWeb/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { + define('PMA_USR_BROWSER_VER', $log_version[1]); + define('PMA_USR_BROWSER_AGENT', 'OMNIWEB'); + } else if (ereg('Mozilla/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { + define('PMA_USR_BROWSER_VER', $log_version[1]); + define('PMA_USR_BROWSER_AGENT', 'MOZILLA'); + } else if (ereg('Konqueror/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) { + define('PMA_USR_BROWSER_VER', $log_version[1]); + define('PMA_USR_BROWSER_AGENT', 'KONQUEROR'); + } else { + define('PMA_USR_BROWSER_VER', 0); + define('PMA_USR_BROWSER_AGENT', 'OTHER'); + } +} // $__PMA_DEFINES_LIB__ +?> Added: XoopsModules/backup/trunk/backup/include/functions.php =================================================================== --- XoopsModules/backup/trunk/backup/include/functions.php (rev 0) +++ XoopsModules/backup/trunk/backup/include/functions.php 2012-04-11 04:08:46 UTC (rev 9296) @@ -0,0 +1,67 @@ +<?php +// $Id: functions.php,v 1.5 2004/09/20 22:36:31 phppp Exp $ +// ------------------------------------------------------------------------ // +// DIGEST for XOOPS // +// Copyright (c) 2004 Xoops China Community // +// <http://www.xoops.org.cn/> // +// ------------------------------------------------------------------------ // +// 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 // +// ------------------------------------------------------------------------ // +// Author: D.J.(phppp) ph...@ho... // +// URL: http://www.xoops.org.cn // +// ------------------------------------------------------------------------- // + +function backup_export($configs=null) +{ + if(!is_array($configs) || count($configs)==0){ + $module_handler =& xoops_gethandler('module'); + $xoopsModule =& $module_handler->getByDirname('backup'); + $config_handler = & xoops_gethandler( 'config' ); + $configs = & $config_handler->getConfigsByCat( 0, $xoopsModule->getVar( 'mid' ) ); + } + if(!is_array($configs) || count($configs)==0){ + return false; + } + + $export_file = XOOPS_CACHE_PATH.'/backup.php'; + if(!$fp = fopen($export_file,'w')) { + echo "<br /> the update file can not be created"; + return false; + } + $file_content = "<?php"; + $file_content .= "\n return \$config = '".serialize($configs)."';\n"; + $file_content .= "?>"; + fputs($fp,$file_content); + fclose($fp); + return true; +} + +function &backup_import() +{ + $import_file = XOOPS_CACHE_PATH.'/backup.php'; + if(!is_readable($import_file) && !backup_export()) { + echo "<br />the imported file can not be read: ".$import_file; + return false; + } + $config = include($import_file); + $configs = unserialize($config); + return $configs; +} +?> \ No newline at end of file Added: XoopsModules/backup/trunk/backup/include/index.html =================================================================== --- XoopsModules/backup/trunk/backup/include/index.html (rev 0) +++ XoopsModules/backup/trunk/backup/include/index.html 2012-04-11 04:08:46 UTC (rev 9296) @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Added: XoopsModules/backup/trunk/backup/include/zip.lib.php =================================================================== --- XoopsModules/backup/trunk/backup/include/zip.lib.php (rev 0) +++ XoopsModules/backup/trunk/backup/include/zip.lib.php 2012-04-11 04:08:46 UTC (rev 9296) @@ -0,0 +1,186 @@ +<?php +/* $Id: zip.lib.php,v 1.6 2002/03/30 08:24:04 loic1 Exp $ */ + + +/** + * Zip file creation class. + * Makes zip files. + * + * Based on : + * + * http://www.zend.com/codex.php?id=535&single=1 + * By Eric Mueller <er...@th...> + * + * http://www.zend.com/codex.php?id=470&single=1 + * by Denis125 <web...@at...> + * + * a patch from Peter Listiak <ml...@us...> for last modified + * date and time of the compressed file + * + * Official ZIP file format: http://www.pkware.com/appnote.txt + * + * @access public + */ +class zipfile +{ + /** + * Array to store compressed data + * + * @var array $datasec + */ + var $datasec = array(); + + /** + * Central directory + * + * @var array $ctrl_dir + */ + var $ctrl_dir = array(); + + /** + * End of central directory record + * + * @var string $eof_ctrl_dir + */ + var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; + + /** + * Last offset position + * + * @var integer $old_offset + */ + var $old_offset = 0; + + + /** + * 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). + * + * @param integer the current Unix timestamp + * + * @return integer the current date in a four byte DOS format + * + * @access private + */ + function unix2DosTime($unixtime = 0) { + $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); + + if ($timearray['year'] < 1980) { + $timearray['year'] = 1980; + $timearray['mon'] = 1; + $timearray['mday'] = 1; + $timearray['hours'] = 0; + $timearray['minutes'] = 0; + $timearray['seconds'] = 0; + } // end if + + return (($timearray['year'] - 1980)... [truncated message content] |