} $waitbaktime = (int) $_GET['waitbaktime']; $stime = $_GET['stime']; if (empty($stime)) { $stime = time(); } $t = $_GET['t']; if (empty($t)) { $t = 0; } $p = $_GET['p']; if (empty($p)) { $p = 1; } $btb = explode(',', $b_table); $tbcount = count($btb); if ($p >= $tb[$btb[$t]]) { $t++; if ($t >= $tbcount) { echo "<script>alert('" . $fun_r['ReDataSuccess'] . "\\n\\n" . $fun_r['TotalUseTime'] . ToChangeUseTime($stime) . "');self.location.href='../../ReData.php';</script>"; exit; } $nfile = $btb[$t] . '_1.php'; echo "<meta http-equiv=\"refresh\" content=\"" . $waitbaktime . ";url={$nfile}?t={$t}&p=0&mydbname={$mydbname}&mypath={$mypath}&stime={$stime}&waitbaktime={$waitbaktime}\">" . $fun_r['OneTableReSuccOne'] . $btb[$t - 1] . $fun_r['OneTableReSuccTwo']; exit; } $p++; $nfile = $btb[$t] . '_' . $p . '.php'; echo "<meta http-equiv=\"refresh\" content=\"" . $waitbaktime . ";url={$nfile}?t={$t}&p={$p}&mydbname={$mydbname}&mypath={$mypath}&stime={$stime}&waitbaktime={$waitbaktime}\">" . $fun_r['ReOneDataSuccess'] . Ebak_EchoReDataSt($btb[$t], $tbcount, $t, $tb[$btb[$t]], $p); db_close(); $empire = null;
function Ebak_BakExeT($t,$s,$p,$mypath,$alltotal,$thenof,$fnum,$auf='',$aufval=0,$stime=0){ global $empire,$bakpath,$limittype,$fun_r; if(empty($mypath)) { printerror("ErrorUrl","history.go(-1)"); } $path=$bakpath."/".$mypath; @include($path."/config.php"); if(empty($b_table)) { printerror("ErrorUrl","history.go(-1)"); } $waitbaktime=(int)$_GET['waitbaktime']; if(empty($stime)) { $stime=time(); } $header="<?php require(\"../../inc/header.php\"); "; $footer=" require(\"../../inc/footer.php\"); ?>"; $btb=explode(",",$b_table); $count=count($btb); $t=(int)$t; $s=(int)$s; $p=(int)$p; //备份完毕 if($t>=$count) { echo"<script>alert('".$fun_r['BakSuccess']."\\n\\n".$fun_r['TotalUseTime'].ToChangeUseTime($stime)."');self.location.href='ChangeDb.php';</script>"; exit(); } $dumpsql=Ebak_ReturnVer(); //选择数据库 $u=$empire->query("use `$b_dbname`"); //编码 if($b_dbchar=='auto') { if(empty($s)) { $status_r=Ebak_GetTotal($b_dbname,$btb[$t]); $collation=Ebak_GetSetChar($status_r['Collation']); DoSetDbChar($collation); //总记录数 $num=$limittype?-1:$status_r['Rows']; } else { $collation=$_GET['collation']; DoSetDbChar($collation); $num=(int)$alltotal; } $dumpsql.=Ebak_ReturnSetNames($collation); } else { DoSetDbChar($b_dbchar); if(empty($s)) { //总记录数 if($limittype) { $num=-1; } else { $status_r=Ebak_GetTotal($b_dbname,$btb[$t]); $num=$status_r['Rows']; } } else { $num=(int)$alltotal; } } //备份数据库结构 if($b_stru&&empty($s)) { $dumpsql.=Ebak_Returnstru($btb[$t],$b_strufour); } //取得字段数 if(empty($fnum)) { $return_fr=Ebak_ReturnTbfield($b_dbname,$btb[$t],$b_autofield); $fieldnum=$return_fr['num']; $noautof=$return_fr['autof']; $auf=$return_fr['auf']; } else { $fieldnum=$fnum; $noautof=$thenof; } //自动识别自增项 $aufval=(int)$aufval; if($b_autoauf==1&&$auf) { $sql=$empire->query("select * from `".$btb[$t]."` where ".$auf.">".$aufval." order by ".$auf." limit $b_bakline"); } else { $sql=$empire->query("select * from `".$btb[$t]."` limit $s,$b_bakline"); } //完整插入 $inf=''; if($b_beover==1) { $inf='('.Ebak_ReturnInTbfield($b_dbname,$btb[$t]).')'; } //十六进制 $hexf=''; if($b_bakdatatype==1) { $hexf=Ebak_ReturnInStrTbfield($b_dbname,$btb[$t]); } $b=0; while($r=$empire->fetch($sql)) { if($auf) { $lastaufval=$r[$auf]; } $b=1; $s++; $dumpsql.="E_D(\"".$b_insertf." into `".$btb[$t]."`".$inf." values("; $first=1; for($i=0;$i<$fieldnum;$i++) { //首字段 if(empty($first)) { $dumpsql.=','; } else { $first=0; } $myi=$i+1; if(!isset($r[$i])||strstr($noautof,','.$myi.',')) { $dumpsql.='NULL'; } else { $dumpsql.=Ebak_ReSqlFtext($r[$i],$b_bakdatatype,$myi,$hexf); } } $dumpsql.=");\");\r\n"; } if(empty($b)) { //最后一个备份 if(empty($p)) { $p++; $sfile=$path."/".$btb[$t]."_".$p.".php"; $dumpsql=$header.$dumpsql.$footer; WriteFiletext_n($sfile,$dumpsql); } Ebak_RepFilenum($p,$btb[$t],$path); $t++; $empire->free($sql); //进入下一个表 //echo $fun_r['OneTableBakSuccOne'].$btb[$t].$fun_r['OneTableBakSuccTwo']."<script>self.location.href='phomebak.php?phome=BakExeT&s=0&p=0&t=$t&mypath=$mypath&stime=$stime';</script>"; echo"<meta http-equiv=\"refresh\" content=\"".$waitbaktime.";url=phomebak.php?phome=BakExeT&s=0&p=0&t=$t&mypath=$mypath&stime=$stime&waitbaktime=$waitbaktime\">".$fun_r['OneTableBakSuccOne'].$btb[$t-1].$fun_r['OneTableBakSuccTwo']; exit(); } //进入下一组 $p++; $sfile=$path."/".$btb[$t]."_".$p.".php"; $dumpsql=$header.$dumpsql.$footer; WriteFiletext_n($sfile,$dumpsql); $empire->free($sql); //echo $fun_r['BakOneDataSuccess'].Ebak_EchoBakSt($btb[$t],$count,$t,$num,$s)."<script>self.location.href='phomebak.php?phome=BakExeT&s=$s&p=$p&t=$t&mypath=$mypath&alltotal=$num&thenof=$noautof&fieldnum=$fieldnum&auf=$auf&aufval=$lastaufval&stime=$stime';</script>"; echo"<meta http-equiv=\"refresh\" content=\"".$waitbaktime.";url=phomebak.php?phome=BakExeT&s=$s&p=$p&t=$t&mypath=$mypath&alltotal=$num&thenof=$noautof&fieldnum=$fieldnum&auf=$auf&aufval=$lastaufval&stime=$stime&waitbaktime=$waitbaktime&collation=$collation\">".$fun_r['BakOneDataSuccess'].Ebak_EchoBakSt($btb[$t],$count,$t,$num,$s); exit(); }
function Ebak_BakExeT($t, $s, $p, $mypath, $alltotal, $thenof, $fnum, $auf = '', $aufval = 0, $stime = 0) { global $empire, $bakpath, $limittype, $fun_r; if (empty($mypath)) { printerror('ErrorUrl', 'history.go(-1)'); } $path = $bakpath . '/' . $mypath; @(include $path . '/config.php'); if (empty($b_table)) { printerror('ErrorUrl', 'history.go(-1)'); } $waitbaktime = (int) $_GET['waitbaktime']; if (empty($stime)) { $stime = time(); } $header = "<?php\nrequire(\"../../inc/header.php\");\n"; $footer = "\nrequire(\"../../inc/footer.php\");\n?>"; $btb = explode(',', $b_table); $count = count($btb); $t = (int) $t; $s = (int) $s; $p = (int) $p; if ($t >= $count) { echo "<script>alert('" . $fun_r['BakSuccess'] . "\\n\\n" . $fun_r['TotalUseTime'] . ToChangeUseTime($stime) . "');self.location.href='ChangeDb.php';</script>"; exit; } $dumpsql = Ebak_ReturnVer(); $u = $empire->query("use `{$b_dbname}`"); if ($b_dbchar == 'auto') { if (empty($s)) { $status_r = Ebak_GetTotal($b_dbname, $btb[$t]); $collation = Ebak_GetSetChar($status_r['Collation']); DoSetDbChar($collation); $num = $limittype ? -1 : $status_r['Rows']; } else { $collation = $_GET['collation']; DoSetDbChar($collation); $num = (int) $alltotal; } $dumpsql .= Ebak_ReturnSetNames($collation); } else { DoSetDbChar($b_dbchar); if (empty($s)) { if ($limittype) { $num = -1; } else { $status_r = Ebak_GetTotal($b_dbname, $btb[$t]); $num = $status_r['Rows']; } } else { $num = (int) $alltotal; } } if ($b_stru && empty($s)) { $dumpsql .= Ebak_Returnstru($btb[$t], $b_strufour); } if (empty($fnum)) { $return_fr = Ebak_ReturnTbfield($b_dbname, $btb[$t], $b_autofield); $fieldnum = $return_fr['num']; $noautof = $return_fr['autof']; $auf = $return_fr['auf']; } else { $fieldnum = $fnum; $noautof = $thenof; } $aufval = (int) $aufval; if ($b_autoauf == 1 && $auf) { $sql = $empire->query('select * from `' . $btb[$t] . '` where ' . $auf . '>' . $aufval . ' order by ' . $auf . " limit {$b_bakline}"); } else { $sql = $empire->query('select * from `' . $btb[$t] . "` limit {$s},{$b_bakline}"); } $inf = ''; if ($b_beover == 1) { $inf = '(' . Ebak_ReturnInTbfield($b_dbname, $btb[$t]) . ')'; } $hexf = ''; if ($b_bakdatatype == 1) { $hexf = Ebak_ReturnInStrTbfield($b_dbname, $btb[$t]); } $b = 0; while ($r = $empire->fetch($sql)) { if ($auf) { $lastaufval = $r[$auf]; } $b = 1; $s++; $dumpsql .= "E_D(\"" . $b_insertf . ' into `' . $btb[$t] . '`' . $inf . ' values('; $first = 1; for ($i = 0; $i < $fieldnum; $i++) { if (empty($first)) { $dumpsql .= ','; } else { $first = 0; } $myi = $i + 1; if (!isset($r[$i]) || strstr($noautof, ',' . $myi . ',')) { $dumpsql .= 'NULL'; } else { $dumpsql .= Ebak_ReSqlFtext($r[$i], $b_bakdatatype, $myi, $hexf); } } $dumpsql .= ");\");\r\n"; } if (empty($b)) { if (empty($p)) { $p++; $sfile = $path . '/' . $btb[$t] . '_' . $p . '.php'; $dumpsql = $header . $dumpsql . $footer; WriteFiletext_n($sfile, $dumpsql); } Ebak_RepFilenum($p, $btb[$t], $path); $t++; $empire->free($sql); echo "<meta http-equiv=\"refresh\" content=\"" . $waitbaktime . ";url=phomebak.php?phome=BakExeT&s=0&p=0&t={$t}&mypath={$mypath}&stime={$stime}&waitbaktime={$waitbaktime}\">" . $fun_r['OneTableBakSuccOne'] . $btb[$t - 1] . $fun_r['OneTableBakSuccTwo']; exit; } $p++; $sfile = $path . '/' . $btb[$t] . '_' . $p . '.php'; $dumpsql = $header . $dumpsql . $footer; WriteFiletext_n($sfile, $dumpsql); $empire->free($sql); echo "<meta http-equiv=\"refresh\" content=\"" . $waitbaktime . ";url=phomebak.php?phome=BakExeT&s={$s}&p={$p}&t={$t}&mypath={$mypath}&alltotal={$num}&thenof={$noautof}&fieldnum={$fieldnum}&auf={$auf}&aufval={$lastaufval}&stime={$stime}&waitbaktime={$waitbaktime}&collation={$collation}\">" . $fun_r['BakOneDataSuccess'] . Ebak_EchoBakSt($btb[$t], $count, $t, $num, $s); exit; }
$p = 1; } $btb = explode(",", $b_table); $tbcount = count($btb); //最后一个文件 if ($p >= $tb[$btb[$t]]) { $t++; //恢复完毕 if ($t >= $tbcount) { if ($phome_db_dbname != $mydbname) { $use = $empire->query("use " . $phome_db_dbname); } $enews = "ReData"; //操作日志 insert_dolog("dbname=" . $mydbname . "&path=" . $mypath); $varmessage = $fun_r['ReDataSuccess'] . "<br><br>" . $fun_r['TotalUseTime'] . ToChangeUseTime($stime); $GLOBALS['varmessage'] = $varmessage; printerror('VarMessage', '../../ReData.php', 0, 1); } $nfile = $btb[$t] . "_1.php"; //进入下一个表 //echo $btb[$t-1].$fun_r['ReOneTableSuccess']."<script>self.location.href='$nfile?t=$t&p=0&mydbname=$mydbname&mypath=$mypath&stime=$stime';</script>"; echo "<meta http-equiv=\"refresh\" content=\"" . $waitbaktime . ";url={$nfile}?t={$t}&p=0&mydbname={$mydbname}&mypath={$mypath}&stime={$stime}&waitbaktime={$waitbaktime}\">" . $btb[$t - 1] . $fun_r['ReOneTableSuccess']; exit; } //进入下一个文件 $p++; $nfile = $btb[$t] . "_" . $p . ".php"; //echo $fun_r['ReOneDataSuccess'].Ebak_EchoReDataSt($btb[$t],$tbcount,$t,$tb[$btb[$t]],$p)."<script>self.location.href='$nfile?t=$t&p=$p&mydbname=$mydbname&mypath=$mypath&stime=$stime';</script>"; echo "<meta http-equiv=\"refresh\" content=\"" . $waitbaktime . ";url={$nfile}?t={$t}&p={$p}&mydbname={$mydbname}&mypath={$mypath}&stime={$stime}&waitbaktime={$waitbaktime}\">" . $fun_r['ReOneDataSuccess'] . Ebak_EchoReDataSt($btb[$t], $tbcount, $t, $tb[$btb[$t]], $p); db_close();
function BackupDatabaseRecordNum($t, $s, $p, $mypath, $alltotal, $thenof, $fnum, $auf = '', $aufval = 0, $stime = 0) { global $db, $bakpath, $limittype, $fun_r, $adminDir; if (empty($mypath)) { } $path = PLUS_PATH . '/bdata/' . $mypath; @(include $path . "/config.php"); if (empty($b_table)) { } $waitbaktime = (int) $_GET['waitbaktime']; if (empty($stime)) { $stime = time(); } $header = "<?php\r\nrequire(LIB_PATH.\"dbbackup/inc/header.php\");\r\n"; $footer = "\r\nrequire(LIB_PATH.\"dbbackup/inc/footer.php\");\r\n?>"; $btb = explode(",", $b_table); $count = count($btb); $t = (int) $t; $s = (int) $s; $p = (int) $p; if ($t >= $count) { echo "<script>alert('" . $fun_r['BakSuccess'] . "\\n\\n" . $fun_r['TotalUseTime'] . ToChangeUseTime($stime) . "');self.location.href='" . $config['sy_weburl'] . "/" . $adminDir . "/index.php?m=database';</script>"; exit; } $u = $db->query("use `{$b_dbname}`"); if ($b_dbchar == 'auto') { if (!empty($s)) { $status_r = GetTableRows($b_dbname, $btb[$t]); $collation = GetCharset($status_r['Collation']); SetCharset($collation); $num = $limittype ? -1 : $status_r['Rows']; } else { $collation = $_GET['collation']; SetCharset($collation); $num = (int) $alltotal; } $dumpsql .= ExcuteSetCharset($collation); } else { SetCharset($b_dbchar); if (!empty($s)) { if ($limittype) { $num = -1; } else { $status_r = GetTableRows($b_dbname, $btb[$t]); $num = $status_r['Rows']; } } else { $num = (int) $alltotal; } } if ($b_stru && $s) { $dumpsql .= GetTableStructSql($btb[$t], $b_strufour); } if (empty($fnum)) { $return_fr = GetTableFields($b_dbname, $btb[$t], $b_autofield); $fieldnum = $return_fr['num']; $noautof = $return_fr['autof']; $auf = $return_fr['auf']; } else { $fieldnum = $fnum; $noautof = $thenof; } $aufval = (int) $aufval; if ($b_autoauf == 1 && $auf) { $sql = $db->query("select * from `" . $btb[$t] . "` where " . $auf . ">" . $aufval . " order by " . $auf . " limit {$b_bakline}"); } else { $sql = $db->query("select * from `" . $btb[$t] . "` limit {$s},{$b_bakline}"); } $inf = ''; if ($b_beover == 1) { $inf = '(' . GetTableInsertFields($b_dbname, $btb[$t]) . ')'; } $hexf = ''; if ($b_bakdatatype == 1) { $hexf = GetTableStringFields($b_dbname, $btb[$t]); } $b = 0; while ($r = $db->fetch($sql)) { if ($auf) { $lastaufval = $r[$auf]; } $b = 1; $s++; $dumpsql .= "ExcuteSQL(\"into `" . $btb[$t] . "`" . $inf . " values("; $first = 1; for ($i = 0; $i < $fieldnum; $i++) { if (empty($first)) { $dumpsql .= ','; } else { $first = 0; } $myi = $i + 1; if (!isset($r[$i]) || strstr($noautof, ',' . $myi . ',')) { $dumpsql .= 'NULL'; } else { $dumpsql .= GetFieldContent($r[$i], $b_bakdatatype, $myi, $hexf); } } $dumpsql .= ");\");\r\n"; } if (empty($b)) { if (empty($p)) { $p++; $sfile = $path . "/" . $btb[$t] . "_" . $p . ".php"; $dumpsql = $header . $dumpsql . $footer; WriteString2File($sfile, $dumpsql); } FetchFileNumber($p, $btb[$t], $path); $t++; $db->free($sql); echo "<meta http-equiv=\"refresh\" content=\"" . $waitbaktime . ";url=" . $config['sy_weburl'] . "/" . $adminDir . "/index.php?m=database&c=BackupDatabaseRecordNum&s=0&p=0&t={$t}&mypath={$mypath}&stime={$stime}&waitbaktime={$waitbaktime}\">" . $fun_r['OneTableBakSuccOne'] . $btb[$t - 1] . $fun_r['OneTableBakSuccTwo']; exit; } $p++; $sfile = $path . "/" . $btb[$t] . "_" . $p . ".php"; $dumpsql = $header . $dumpsql . $footer; WriteString2File($sfile, $dumpsql); $db->free($sql); echo "<meta http-equiv=\"refresh\" content=\"" . $waitbaktime . ";url=" . $config['sy_weburl'] . "/" . $adminDir . "/index.php?m=database&c=BackupDatabaseRecordNum&s={$s}&p={$p}&t={$t}&mypath={$mypath}&alltotal={$num}&thenof={$noautof}&fieldnum={$fieldnum}&auf={$auf}&aufval={$lastaufval}&stime={$stime}&waitbaktime={$waitbaktime}&collation={$collation}\">" . $fun_r['BakOneDataSuccess'] . EchoBackupProcesser($btb[$t], $count, $t, $num, $s); exit; }
$waitbaktime = (int) $_GET['waitbaktime']; $stime = $_GET['stime']; if (empty($stime)) { $stime = time(); } $t = $_GET['t']; if (empty($t)) { $t = 0; } $p = $_GET['p']; if (empty($p)) { $p = 1; } $btb = explode(",", $b_table); $tbcount = count($btb); if ($p >= $tb[$btb[$t]]) { $t++; if ($t >= $tbcount) { echo "<script>alert('»Ö¸´³É¹¦£¡\\n\\nÓÃʱ" . ToChangeUseTime($stime) . "');self.location.href='" . $config['sy_weburl'] . "/admin/index.php?m=database';</script>"; exit; } $nfile = $btb[$t] . "_1.php"; echo "<meta http-equiv=\"refresh\" content=\"" . $waitbaktime . ";url={$nfile}?t={$t}&p=0&mydbname={$mydbname}&mypath={$mypath}&stime={$stime}&waitbaktime={$waitbaktime}\">" . $fun_r['OneTableReSuccOne'] . $btb[$t - 1] . $fun_r['OneTableReSuccTwo']; exit; } $p++; $nfile = $btb[$t] . "_" . $p . ".php"; echo "<meta http-equiv=\"refresh\" content=\"" . $waitbaktime . ";url={$nfile}?t={$t}&p={$p}&mydbname={$mydbname}&mypath={$mypath}&stime={$stime}&waitbaktime={$waitbaktime}\">" . $fun_r['ReOneDataSuccess'] . EchoBackupProcesserEchoReDataSt($btb[$t], $tbcount, $t, $tb[$btb[$t]], $p); @mysql_close(); $empire = null;