$(document).ready(function(){
var usegroup="";
$.post("getusegroup.php",{},function(data){
	usegroup=data;
									 });
/**配置信息转移开始**/
//转移网站信息
$("#loading").html("正在转移网站数据...");
$.post("getdata.php",{table:"website",key:"name,url,type"},function(data){
  data=data.replace(/\友好/g,"0");
  data=data.replace(/\竞争/g,"1");
  data=data.replace("|",",'1'|");
  data +=",'1'";
  $.post("data_update.php",{table:"site",key:"Site_name,Site_url,Relationship,Status,Use_group",data:data},function(data){
		$("#success").html($("#success").html()+"网站数据转移成功<br/>");
		$("#loading").html("正在转移外链类型数据...");
//转移外链类型
$.post("getdata.php",{table:"linktype",key:"name"},function(data){
  $.post("data_update.php",{table:"link_type",key:"Type_name,Use_group",data:data},function(data){
$("#success").html($("#success").html()+"外链类型数据转移成功<br/>");
$("#loading").html("正在转移频道信息数据...");
//转移频道信息
$.post("getdata.php",{table:"channel",key:"name"},function(data){
  $.post("data_update.php",{table:"channel",key:"Channel_name,Use_group",data:data},function(data){
$("#success").html($("#success").html()+"频道信息数据转移成功<br/>");
$("#loading").html("正在转移平媒选项信息数据...");
//转移平媒选项
$.post("getdata.php",{table:"reportc",key:"name,type"},function(data){
  $.post("data_update.php",{table:"report_set",key:"Set_name,Type_name,Use_group",data:data},function(data){
$("#success").html($("#success").html()+"平煤选项数据转移成功<br/>");
$("#loading").html("正在转移负面监控信息数据...");
//转移负面监控
$.post("getdata.php",{table:"negativeset",key:"username1,password1,username2,password2,mailurl"},function(data){
  $.post("data_update.php",{table:"monitoring_set",key:"Username1,Password1,Username2,Password2,Email_url,Use_group",data:data},function(data){
	$("#success").html($("#success").html()+"负面监控数据转移成功<br/>");
$("#loading").html("正在转移关键字排名数据...");																							
//配置信息转移结束
/**数据信息转移开始**/
//转移关键字
$.post("getdata.php",{table:"paiming",key:"keyword,area"},function(data){
 $.post("data_update.php",{table:"ranking",key:"Keyword,Area,Use_group",data:data},function(data){
	$("#success").html($("#success").html()+"关键字排名数据转移成功<br/>");
$("#loading").html("正在转移文章收录检测数据...");																						
//文章收录数据转移
//频道转换
   var channel_arr=new Array();
$.post("getdata2.php",{table:"channel",key:"Cid,Channel_name,Use_group"},function(channel){
   channel=channel.replace(/\'/g,"");
   channel=channel.split("|");
   var len1=channel.length;
   for(var i=0;i<len1;i++){
   var channel_cells=channel[i].split(",");
   var cid=channel_cells[0];
   var channel_name=channel_cells[1];
   var use_group=channel_cells[2];
   if(use_group==usegroup){
  channel_arr[cid]=channel_name;
   }
   }
   //转移文章收录
$.post("getdata.php",{table:"content",key:"arctitle,url,channel,belong,adddate"},function(data){
  var data_arr=data.split("|");
  var len2=data_arr.length;
  for(var i=0;i<len2;i++){
  var cc=data_arr[i].split(",")[2].replace(/\'/g,"");
  if(isNaN(cc)==true){
  for(var k in channel_arr){
  if(channel_arr[k]==cc){
  var reg=new RegExp("'"+cc+"'","g");
  data=data.replace(reg,"'"+k+"','1'");
  }
  }
  }
  }
 $.post("data_update.php",{table:"article",key:"Title,Url,Cid,Uid,Keyword,Date,Use_group",data:data},function(data){
	$("#success").html($("#success").html()+"文章收录检测数据转移成功<br/>");
$("#loading").html("正在转移网站外链数据...");																									
//外链类型转换
var linktype_arr=new Array();
$.post("getdata2.php",{table:"link_type",key:"Lid,Type_name,Use_group"},function(link_type){
   link_type=link_type.replace(/\'/g,"");
   link_type=link_type.split("|");
   var len3=link_type.length;
   for(var i=0;i<len3;i++){
   var linktype_cells=link_type[i].split(",");
   var lid=linktype_cells[0];
   var typename=linktype_cells[1];
   var use_group=linktype_cells[2];
   if(use_group==usegroup){
  linktype_arr[lid]=typename;
   }
   }
   //转移外链数据
   $.post("getdata.php",{table:"weblink",key:"name,url,linktype,adddate,pr,baidu"},function(data){
   var data_arr=data.split("|");
  var len4=data_arr.length;
  for(var i=0;i<len4;i++){
  var cc=data_arr[i].split(",")[2].replace(/\'/g,"");
  if(isNaN(cc)==true){
  for(var k in linktype_arr){
  if(linktype_arr[k]==cc){
  var reg=new RegExp("'"+cc+"'","g");
  data=data.replace(reg,"'"+k+"','1'");
  }
  }
  }
  }
 $.post("data_update.php",{table:"outlink",key:"Link_name,Link_url,Lid,Uid,Date,Pr,Baidu_shoulu,Use_group",data:data},function(data){
	$("#success").html($("#success").html()+"网站外链数据转移成功<br/>");
$("#loading").html("正在转移外部账号管理数据...");																										
 //外部账号信息转移
 $.post("getdata.php",{table:"blog",key:"name,url,username,password,adddate"},function(data){
 data=data.replace(/\|/g,",'1'|");
 data +=",'1'";
 $.post("data_update.php",{table:"account",key:"Site_name,Site_url,Username,Password,Date,Uid,Use_group",data:data},function(data){
	$("#success").html($("#success").html()+"外部账号管理数据转移成功<br/>");
$("#loading").html("正在转移网站日志分析数据...");																														
 //网站日志数据转移
 $.post("getdata.php",{table:"zhizhu",key:"date,baidu,google,s360,soso,yahoo,bing,youdao,sogou,alexa"},function(data){
 var log_arr=data.split("','");
 var loglen=log_arr.length;
 for(var i=1;i<loglen;i++){
 var logcells=log_arr[i].split(',');
 var tt=(logcells[6].replace("'","")/3600).toFixed(2);
 var sts=logcells[0];
 if(sts=="0")
 sts=1;
 var st=(logcells[6].replace("'","")/sts).toFixed(2);
 data=data.replace(logcells[6],tt+","+st);
 }
data+="'";
 $.post("data_update.php",{table:"log",key:"Date,baidu_log,Google_log,Se360_log,Soso_log,Yahoo_log,Bing_log,Youdao_log,Sogou_log,Alexa_log,Use_group",data:data},function(data){																																									$("#success").html($("#success").html()+"网站日志分析数据转移成功<br/>");
$("#loading").html("正在转移网络负面监控数据...");
//网络负面数据转移
$.post("getdata.php",{table:"negative",key:"keyword,type,frequency,result,sendto"},function(data){
 $.post("data_update.php",{table:"monitoring",key:"Keyword,Result_type,Send_times,result,Receive,Use_group",data:data},function(data){
	$("#success").html($("#success").html()+"网络负面监控数据转移成功<br/>");
$("#loading").html("正在转移流量统计数据...");																															
//获取当前主站
$.post("getdata2.php",{table:"site",key:"Site_url,Relationship,Status,Use_group"},function(data){
var site="";
var site_arr=data.replace(/\'/g,"").split("|");
var len=site_arr.length;
for(var i=0;i<len;i++){
var site_cells=site_arr[i].split(",");
if(site_cells[1]==0&&site_cells[2]==1&&site_cells[3]==usegroup)
site=site_cells[0];
}
//流量数据转移
$.post("getdata.php",{table:"flow",key:"google,baidu,goutlink,boutlink,baiduday,ip,pv,pr,alexa,adddate,webstime,kuaizhao,shouyewailian"},function(data){
data=data.replace(/\|/g,",'"+site+"'|");
data+=",'"+site+"'";
$.post("data_update.php",{table:"flow",key:"Google_shoulu,Baidu_shoulu,Google_link,Baidu_link,Baidu_yshoulu,Ip,Pv,Pr,Alexa,Date,Server_time,Baidu_kuaizhao,Index_link,Site_url,Use_group",data:data},function(data){																																																	$("#success").html($("#success").html()+"流量统计数据转移成功<br/>");
$("#loading").html("正在转移咨询统计数据...");
});
});
//咨询数据转移
$.post("getdata.php",{table:"consulting",key:"date,chengjiao,shangmen,youxiao,zixun,dianji,money"},function(data){
data=data.replace(/\|/g,",'"+site+"'|");
data+=",'"+site+"'";
$.post("data_update.php",{table:"consulting",key:"Date,Clinch,Visit,Effctive,Consulting,Click,Cost,Site_url,Use_group",data:data},function(data){
 $("#success").html($("#success").html()+"咨询统计数据转移成功<br/>");
$("#loading").html("正在转移每周平媒报告数据...");
//每周平媒数据转移
$.post("getdata.php",{table:"report",key:"date,name,leixing,banmian,color,baojia,meiti,fangxiang,zhekou,beizhu"},function(data){
$.post("data_update.php",{table:"advertising",key:"Date,Site_name,Ad_type,Ad_layout,Ad_color,Ad_cost,Ad_name,Ad_direction,Discount,Note,Use_group",data:data},function(data){																																								$("#success").html($("#success").html()+"每周平媒报告数据转移成功<br/>");
$("#loading").html("正在转移行业网络动态数据...");
//行业网络动态数据转移
$.post("getdata.php",{table:"news",key:"date,name,url"},function(data){
$.post("data_update.php",{table:"news",key:"Date,Title,Url,Use_group",data:data},function(data){
$("#success").html($("#success").html()+"行业网络动态数据转移成功<br/>");
$("#loading").html("数据转移完成");
alert("数据转移成功，请重新登录");
window.top.location.href='../login/exit.php';
});
});
});
});
});
});
});
 });
});
 });
 });
 });
 });
 });
   });
});
 });
});
  });
 });
});
  });
});    
  });
});
  });
});
  });
});
  });
});
/*****************************************/
});