<?php
require(dirname(__FILE__)."/"."global.php");
$_GET['_fromurl'] && $_fromurl=$_GET['_fromurl'];
//處理同步登錄
if($webdb[passport_type])
{
	if($action=="quit")
	{
		if( ereg("^dzbbs",$webdb[passport_type]) )
		{
			//5.0使用$tablepre,5.5使用$cookiepre
			set_cookie("{$cookiepre}auth","");
			set_cookie("{$cookiepre}sid","");
			set_cookie("{$tablepre}auth","");
			set_cookie("{$tablepre}sid","");
			set_cookie("passport","");
			setcookie("adminID","",0,"/");	//同步後台退出
			$login=uc_user_synlogout();
			refreshto("$FROMURL","succeed退出$login",1);
			//header("location:$FROMURL");
			//以下是跳到退出前的頁面,你可以把上一句刪除,把下一句的//去掉即可
			//header("location:$FROMURL");
			exit;
		}
		elseif( ereg("^pwbbs",$webdb[passport_type]) )
		{
			set_cookie(CookiePre().'_winduser',"");
			setcookie("adminID","",0,"/");	//同步後台退出
			if(!$fromurl){
				$fromurl="$webdb[www_url]/";
			}
			header("location:$fromurl");
			//以下是跳到退出前的頁面,你可以把上一句刪除,把下一句的//去掉即可
			//header("location:$FROMURL");
			exit;
		}
		elseif( ereg("^dvbbs",$webdb[passport_type]) )
		{
			set_cookie("{$cookieprename}userid","");
			set_cookie("{$cookieprename}username","");
			set_cookie("{$cookieprename}password","");
			setcookie("adminID","",0,"/");	//同步後台退出
			header("location:$FROMURL");
			//以下是跳到退出前的頁面,你可以把上一句刪除,把下一句的//去掉即可
			//header("location:$FROMURL");
			exit;
		}
		else
		{
			setcookie("adminID","",0,"/");	//同步後台退出
			header("location:$TB_url/$TB_quit");
			exit;
		}
	}
}

//退出
if($action=="quit")
{
	set_cookie("passport","");
	setcookie("adminID","",0,"/");	//同步後台退出
	if(!$fromurl){
		$fromurl="$webdb[www_url]/";
	}
	echo "<META HTTP-EQUIV=REFRESH CONTENT='0;URL=$fromurl'>";
	//以下是跳到退出前的頁面,你可以把上一句刪除,把下一句的//去掉即可
	//header("location:$FROMURL");
	exit;
}
else
{	//登錄
	if($lfjid){
		showerr("你已經登錄了,請不要重復登錄,要重新登錄請點擊<A HREF='$webdb[www_url]/do/login.php?action=quit'>安全退出</A>");
	}
	if($step==2){
		$login=user_login($username,$password,$cookietime);
		if($login==-1){
			showerr("當前用戶不存在,請重新輸入");
		}elseif($login==0){
			showerr("密碼不正確,點擊重新輸入");
		}
		if($fromurl&&!eregi("login\.php",$fromurl)&&!eregi("reg\.php",$fromurl)){
			$jumpto=$fromurl;
		}elseif($FROMURL&&!eregi("login\.php",$FROMURL)&&!eregi("reg\.php",$FROMURL)){
			$jumpto=$FROMURL;
		}else{
			$jumpto="$webdb[www_url]/";
		}
		refreshto("$jumpto","登錄succeed",1);
	}
	require(PHP168_PATH."inc/head.php");
	require(html("login"));
	require(PHP168_PATH."inc/foot.php");
}
?>