Esempio n. 1
0
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();
}
Esempio n. 2
0
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;
}