<?php 
// 登录页面
include "../core.php";
saxue_getconfigs( 'oauth', 'member' );
if ( empty( $_GET['site'] ) || !isset( $saxueOauth[$_GET['site']] ) || !$saxueOauth[$_GET['site']]['open'] ) {
		saxue_printfail( '登录接口 ' . $saxueOauth[$_GET['site']]['name'] . ' 不存在或者已关闭' );
} 
// 已经登陆
if ( !empty( $_SESSION['saxueUserId'] ) && $_SESSION['saxueUserId'] > 0 ) {
		// 导入oauth接口类
		include SAXUE_ROOT_PATH . "/model/member_oauth.php";
		$oauth_handler = &saxuememberoauthhandler :: getinstance( "saxuememberoauthhandler" );
		if ( $oauth_handler -> getoauth( $_SESSION['saxueUserId'], $_GET['site'] ) != false ) {
				saxue_printfail( '您已绑定 ' . $saxueOauth[$_GET['site']]['name'] . ' 帐号，如果需要绑定其他帐号，请先解除绑定' );
		} 
} 

saxue_freeresource();

if ( !empty( $_SESSION['HTTP_REFERER'] ) && basename( $_SESSION['HTTP_REFERER'] ) != "login.php" ) {
		$_GET['backurl'] = $_SESSION['HTTP_REFERER'];
} elseif ( !empty( $_SERVER['HTTP_REFERER'] ) && basename( $_SERVER['HTTP_REFERER'] ) != "login.php" ) {
		$_GET['backurl'] = $_SERVER['HTTP_REFERER'];
} else {
		$_GET['backurl'] = '/member/';
} 
include SAXUE_ROOT_PATH . '/oauth/' . $_GET['site'] . '.php';
connect_to_site();