<?php
!function_exists('html') && exit('ERR');

if($action=="set"&&$Apower[blend_set])
{
	if($webdbs[passport_type]){
		if(strstr($webdbs[passport_pre],'.')&&eregi("^[0-9]+",$webdbs[passport_pre])){
			$d=explode(".",$webdbs[passport_pre]);
			$webdbs[passport_pre]="`{$d[0]}`.$d[1]";
		}
		if(eregi("^pwbbs",$webdbs[passport_type])||eregi("^dzbbs",$webdbs[passport_type])){
			if(!$db->get_one("SELECT * FROM $webdbs[passport_pre]members LIMIT 1")){
				showmsg("數據表前綴不對,請檢查之");
			}
		}
		if(eregi("^dzbbs",$webdbs[passport_type])){
			if(!is_file(PHP168_PATH."$webdbs[passport_path]/config.inc.php")){
				showmsg("外部系統程序相對整站程序目錄位置不對,請檢查之");
			}
		}elseif(eregi("^pwbbs",$webdbs[passport_type])){
			if(!is_file(PHP168_PATH."$webdbs[passport_path]/data/bbscache/config.php")){
				showmsg("外部系統程序相對整站程序目錄位置不對,請檢查之");
			}
		}
	}
	write_config_cache($webdbs);
	jump("修改succeed",$FROMURL);
}
elseif($job=="set"&&$Apower[blend_set])
{
	$webdb[passport_type] || $webdb[passport_type]=0;
	$passport_type='';
	$passport_type["$webdb[passport_type]"]=' checked ';
	require(dirname(__FILE__)."/"."head.php");
	require(dirname(__FILE__)."/"."template/blend/menu.htm");
	require(dirname(__FILE__)."/"."template/blend/set.htm");
	require(dirname(__FILE__)."/"."foot.php");
}

elseif($action=="other2this"&&$Apower[blend_set])
{
	$rows=100;
	if(!$page){
		$page=1;
		$db->query("TRUNCATE TABLE `{$pre}members`");
	}
	$min=($page-1)*$rows;
	
	$query = $db->query("SELECT *,$TB[uid] AS uid,$TB[username] AS username,$TB[password] AS password FROM $TB[table] ORDER BY $TB[uid] ASC LIMIT $min,$rows");
	while($rs = $db->fetch_array($query)){
		
		$db->query("INSERT INTO `{$pre}members` ( `uid` , `username` , `password` ) VALUES ('$rs[uid]', '$rs[username]', '$rs[password]')");
		
		$rss=$db->get_one("SELECT * FROM {$pre}memberdata WHERE uid='$rs[uid]'");
		if(!$rss){
			Add_memberdata($rs[username],0);
		}
		$ckk++;
	}
	$page++;
	if($ckk){
		echo "正在處理當中...<META HTTP-EQUIV=REFRESH CONTENT='0;URL=index.php?lfj=$lfj&action=$action&page=$page'>";
		exit;
	}else{
		jump("導入完畢","index.php?lfj=blend&job=set",50);
	}
}
elseif($job=="other2this"&&$Apower[blend_set])
{
	if(!$webdb[passport_type]){
		showmsg("你並沒有整合其他系統,所以不能導入數據");
	}
	require(dirname(__FILE__)."/"."head.php");
	require(dirname(__FILE__)."/"."template/blend/menu.htm");
	require(dirname(__FILE__)."/"."template/blend/other2this.htm");
	require(dirname(__FILE__)."/"."foot.php");
}
?>