<?php
/*
Runtime Envirment file
位置: /passport
*/
require('../rte.php');
define('MODULE','passport');
define('WORK_DIR',ROOT.MODULE."/");
require(WORK_DIR.'config/baseconfig.php');
$Lang -> LoadLangFromFile('i18n_passport');

$return = $return ? $return : ($forward ? $forward : '');

#整合UC后跳转到UC其他网站登陆
if ($rtc['uc_use']) {
	ShowMessage('',GetLoginurl(),0,0);
}

$username = trim($username);
if (isset($Submit)) {
	
	if ($rtc['login_gdcode']) {
		Iimport('CheckNum');
		$checknum = new CheckNum();
		if (!$checknum -> Check($gdcode)) {
			ShowMessage('gdcode.error',-1,1);
		}
	}
	
	Iimport('PassPort_User');
	$passport = new PassPort_User();
	if($passport -> CheckUserUniqID($username,$password)) {
		$passport -> PassCheckRebuild();
		$passport -> PutLoginedInfo();
		
		//passport api
		if ($base_config['passport_method'] == 2 && $base_config['passport_api_address']) {
			
			#变量约定
			
			//动作标记
			$inter_action = 'login';
			//传送数据
			$inter_db = array(
				'username' => $username,
				'password'=> $passport -> U[$passport -> U_PasswordKey],
				'email' => $passport -> U['email'] ,
				'time' => $timestamp,
			);
			//跳转地址
			$inter_forward = $forward ? $forward : ($return ? $return : $base_config['passport_root']) ;
			
			//验证签名,在模块中计算.
			$Inter_verify = '';
			
			#变量约定
			
			$interface_file = WORK_DIR.'api/passport_interface/'.$base_config['passport_api_program'].'_interface.php';
			if (file_exists($interface_file)) {
				define('passport_safe',1);
				require($interface_file);
			}
		}
		
		//passport api
		
		if($return) {
			ShowMessage('passport.login.success',$return,0,0);
		}else {
			ShowMessage('passport.login.success','./',0,0);
		}
		exit;
	}else {
		ShowMessage('passport.login.fail');
	}
}else {
	Iimport('template');
	$tpl = new Template();
	$tpl -> LanguageAssign('title','passport.login');
	$tpl -> DisPlay('login');
}
?>