<? include('inc/os.php') ?>
<? include('inc/ahead.inc');//包含页头信息，避免出现乱码?>
<? include('inc/dbclass.php');//包含数据库操作类 ?>
<? include('inc/config.php');//包含数据库基本配置信息 ?>
<? include('inc/page.php');//包含分页类 ?>
<? include('inc/fypage.php');//包含分页导航信息栏函数 ?>
<? include('inc/wap_fbpage.php');//包含风格信息 ?>
<? include('inc/addqxq.php');//包含管理员的当前学期 ?>
<? include('inc/tb.php');//表名 ?>
<? include('inc/hack.php');//包含安全信息 ?>
<? include('inc/cphp.php');//包含管理员的当前学期 ?>
<? include('inc/wap_dbconfig.php');//包含管理员的当前学期 ?>
<? //include('wap_header.html');//包含管理员的当前学期 ?>
<?



ini_set("memory_limit","1024M");
$dbgbk="set names gbk";
$db->query($dbgbk);
//$_SESSION["fycount"]=$_SESSION["dfycount"];
$_SESSION["v2path"]='http://127.0.0.1/';
$_SESSION["conquestpath"]='http://127.0.0.1/';
$_SESSION['dzqmjpg']='dzqmjpg/';
//$_SESSION["v2path"]='http://59.53.121.4/';
?>

<?
$dbgbk="set names gbk";
$db->query($dbgbk);

function filelist($dir) //遍历目录
{
	//echo $dir;
//$dir="../wp/".$dir;
//PHP遍历文件夹下所有文件
$handle=opendir($dir.".");
//echo "文件:<br>";
//$i=0;
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
	
$filea=$dir.$file;
$filet=date("Y-m-d H:i:s",filectime($filea)); //文件创建时间

$f[]=$filea;
//echo $file."——".$filet;
//echo "<br>";

}

}
//print_r($file);//输出的就是数组了
closedir($handle);
//echo count($filel);
return $f;
}


$bookmessage="<font color='#FF0000'>提示：1、标记<b><font color='#FF0000'>*</font></b>为必填项。2、图书编号为系统自动生成，不用填写。3、可借数量等原有可借数量+新增的藏书数量</font>";


function createtableinfo($dwbh)
{
global $db;
$tb[0]="fz_bookinfo";
$tb[1]="fz_bookinfo_tmp";
$tb[2]="fz_bookinfo_tmp_book";
$tb[3]="fz_bookinfo_tmp_show";
$tb[4]="fz_dbfl";
$tb[5]="fz_dbjw";
$tb[6]="fz_dczinfo";
$tb[7]="fz_dczinfo_tmp";
$tb[8]="fz_dgroup";
$tb[9]="fz_dsyscfg";
//$tb[10]="fz_duser";
$tb[10]="fz_dzinfo";
$tb[11]="fz_dzinfo_tmp";
$tb[12]="fz_jbook";
$tb[13]="fz_dgs";

for($i=0;$i<=count($tb);$i++)
	{

$oldtb=$tb[$i];
$newtb=$dwbh."_".$oldtb;
$csql="create table $newtb as select * from $oldtb";
$csql="create table $newtb like $oldtb";

$result=$db->query($csql);






	}
echo "<center><font color=red>创建对应单位的数据表成功</font></center>";

}

function insert_xhyp($tbname,$insertid)
{
global $db;
$dwbh_xhyp=$_SESSION['xhyptbf'];
$tbname_xhyp=xhyp_tbname($tbname);
$csql="insert into $tbname_xhyp select $tbname.*,'".$dwbh_xhyp."' from $tbname where id=$insertid";


echo "<br>";
$db->query($csql);
}



function del_xhyp($tbname,$delid)
{
global $db;
//echo $_SESSION['xhyptbf'];
$dwbh=$_SESSION['xhyptbf'];
$tbname_xhyp=xhyp_tbname($tbname);
$csql="delete from $tbname_xhyp where id=$delid and dwbh='".$dwbh."'";
//echo $csql;
$db->query($csql);
}

function xhyp_tbname($tbname)
{

$tbname=$tbname."_xhyp";


$b=strlen($tbname);

$tbname_a=explode("_",$tbname);

$a=strlen($tbname_a[0]);

$a=$a+1;

$c=$b-$a;


$c=$b-$a;

$endname=substr($tbname,$a,$c);



return $endname;

}

//echo $_SESSION['loginid'];




$tb[0]="fz_bookinfo";
$tb[1]="fz_dbfl";
$tb[2]="fz_dbjw";
$tb[3]="fz_dczinfo";
$tb[4]="fz_dgroup";
$tb[5]="fz_dzinfo";
$tb[6]="fz_jbook";
$tb[7]="fz_dgs";
function initmysql($dwbh)
{
global $db;
global $tb;
for($i=0;$i<count($tb);$i++)
	{
$xhyptb=$tb[$i]."_xhyp";
$csql="truncate table ".$xhyptb;
$result=$db->query($csql);
	}

for($ii=0;$ii<count($dwbh);$ii++)
	{
for($i=0;$i<count($tb);$i++)
	{
$dwtb=$dwbh[$ii]."_".$tb[$i];
$xhyptb=$tb[$i]."_xhyp";
$csql="insert into $xhyptb select *,'".$dwbh[$ii]."' from $dwtb";
//echo $csql;
//echo "<br>";
$result=$db->query($csql);
	}
	}
/*
$oldtb=$tb[$i];
$newtb=$dwbh."_".$oldtb;
$csql="create table $newtb as select * from $oldtb";
$csql="create table $newtb like $oldtb";

$result=$db->query($csql);
*/

exit("<center><font color=red>同步数据表成功</font></center>");

}


function dumpmysql()
{
global $db;
global $tb;
for($i=0;$i<count($tb);$i++)
	{
$xhyptb=$tb[$i]."_xhyp";
$csql="truncate table ".$xhyptb;
//echo $csql;
$result=$db->query($csql);
	}

}




$_SESSION["fycount"]=$_SESSION["fycount"]?$_SESSION["fycount"]:20;



//if(!$_SESSION['xhyptbf']){header("location:login.php");exit;}






?>