<?php
session_start();
include_once('../config/#Config.php');
if(!$_SESSION['UserName']){
die('<script>window.location.href=\''.$config['site']['url'].'index.php\';</script>');
} else {
$get_AD = mysqli_query($conn, "Select * From config_admin WHERE Account = '".$_SESSION['UserName']."'");
if(!mysqli_num_rows($get_AD)){
	die('Khong đủ quyền.');
}
$query_A .= "INSERT INTO ".$_POST['b'].".house (RoleId,HouseData) SELECT RoleId,HouseData FROM ".$_POST['a'].".house<br/>";
$query_A .= "INSERT INTO ".$_POST['b'].".kin_data (KinID,KinName,Info) SELECT KinID,KinName,Info FROM ".$_POST['a'].".kin_data<br/>";
$query_A .= "INSERT INTO ".$_POST['b'].".kin_member_data (RoleID,KinID,Info) SELECT RoleID,KinID,Info FROM ".$_POST['a'].".kin_member_data<br/>";
$query_A .= "INSERT INTO ".$_POST['b'].".mail_box (ID,Info) SELECT ID,Info FROM ".$_POST['a'].".mail_box WHERE ID != 0<br/>";
$query_A .= "INSERT INTO ".$_POST['b'].".Player (ID,PlayerName,Account,SaveTime,BaseInfo,AsyncData,BinData,Ban,BanReason,Plat) SELECT * FROM ".$_POST['a'].".Player<br/>";
$query_AA = mysqli_fetch_array(mysqli_query($conn,"Select cmd_id From ".$_POST['b'].".player_delay_cmd ORDER BY cmd_id DESC LIMIT 1"), MYSQLI_ASSOC);
$query_A .= "SET @rownr = ".$query_AA['cmd_id'].";INSERT INTO ".$_POST['b'].".player_delay_cmd  (cmd_id,role_id,cmd,comment,time) SELECT @rownr:=@rownr+1 AS rowNumber,role_id,cmd,comment,time FROM ".$_POST['a'].".player_delay_cmd<br/>";
$query_A .= "INSERT INTO ".$_POST['b'].".player_query_data (RoleId,Level,KinId,CreateTime,GameTime,LastLogoutTime,HonorLevel,FightPowerRank,VipLevel,TotalCharge,Gold,Coin,Jade,Contrib,ActiveTitleId,Titles,PartnerIds,PartnernPotentials,PartnernSkills,PartnernLevels,Account,Biography,Honor,SkillPoint,FightPower,BestRankBattle,PartnerMisc,PlayerMisc) SELECT * FROM ".$_POST['a'].".player_query_data<br/>";
$query_AAA = mysqli_fetch_array(mysqli_query($conn,"Select id From ".$_POST['b'].".private_msg ORDER BY id DESC LIMIT 1"), MYSQLI_ASSOC);
$query_A .= "SET @rownr = ".$query_AAA['id'].";INSERT INTO ".$_POST['b'].".private_msg (id,RECEIVER,SENDER,SendTime,LinkType,LinkParam,LinkDataSize,MSG) SELECT @rownr:=@rownr+1 AS rowNumber,RECEIVER,SENDER,SendTime,LinkType,LinkParam,LinkDataSize,MSG FROM ".$_POST['a'].".private_msg <br/>";
$query_AAAA = mysqli_fetch_array(mysqli_query($conn,"Select ID From ".$_POST['b'].".rank_board ORDER BY ID DESC LIMIT 1"), MYSQLI_ASSOC);
$query_A .= "SET @rownr = ".$query_AAAA['ID'].";NSERT INTO ".$_POST['b'].".rank_board (ID,Info) SELECT @rownr:=@rownr+1 AS rowNumber,Info FROM ".$_POST['a'].".rank_board<br/>";
$query_A .= "INSERT INTO ".$_POST['b'].".rankbattle (RoleID,RankNo,AsyncData) SELECT RoleID,RankNo,AsyncData FROM ".$_POST['a'].".rankbattle<br/>";
$query_AAAAA = mysqli_fetch_array(mysqli_query($conn,"Select currentid From ".$_POST['a'].".sequence ORDER BY currentid DESC LIMIT 1"), MYSQLI_ASSOC);
$query_A .= "UPDATE ".$_POST['b'].".sequence Set currentid = currentid + ".$query_AAAAA['currentid']."<br/>";
echo $query_A;
}
?>