<?php
require('../../../QPlatform/Common/Component/ComInitialHead.php');
require($netsFileConfig['sysCoreRoot_Real'].'Inc/netsFunc/Func/netsXml.php');
require($netsFileConfig['sysCoreRoot_Real'].'Inc/netsFunc/Func/netsSimpleXml.php');


class PaDefault extends CustomPage {
	private $sysErrorClassID='3001';
	private $sysErrorFuncID=0;
	private $sysErrorID=0;
	public $sUserDescriptions=array();
	
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnLoadModel(){
		$this->sysMetaTitle='用户登陆';
		$this->sUserDescriptions[0]=$this->sysDbDescriptions[$this->sysTableHead.'netsuserinfo'];
		$this->sUserDescriptions[1]=$this->sysDbDescriptions[$this->sysTableHead.'netsuserinfocont'];
		$this->sUserDescriptions[2]=$this->sysDbDescriptions[$this->sysTableHead.'netsuserunit'];
		$this->sUserDescriptions[3]=$this->sysDbDescriptions[$this->sysTableHead.'netsuserunitcont'];
		$this->sUserDescriptions[4]=$this->sysDbDescriptions[$this->sysTableHead.'netsusertype'];
		$this->sUserDescriptions[5]=$this->sysDbDescriptions[$this->sysTableHead.'netsusertypecont'];
		$this->sUserDescriptions[6]=$this->sysDbDescriptions[$this->sysTableHead.'netsuserdepartment'];
		$this->sUserDescriptions[7]=$this->sysDbDescriptions[$this->sysTableHead.'netsuserdepartmentcont'];
		$this->sUserDescriptions[8]=$this->sysDbDescriptions[$this->sysTableHead.'netsusergroup'];
		$this->sUserDescriptions[9]=$this->sysDbDescriptions[$this->sysTableHead.'netsusergrade'];
		$this->sUserDescriptions[0]['Columns']['uitName']['Value']='vir@unionnets.com';
		$this->sAppCore=new netsuserinfo($this->sConnStringCore);
	}
	public function OnBEvent(){
		if($this->sActionTypeF=='DLogin'){
			$this->OnLogin();
		}
	}
	public function OnLogin(){
		$tmpSTR='uitName';
		$tmpAR0=$this->AnalyerRequest($tmpSTR.'Txt','',1);
		$this->sUserDescriptions[0]['Columns'][$tmpSTR]['Value']=$tmpAR0[0];
		$tmpSTR='uitPxd';
		$tmpAR0=$this->AnalyerRequest($tmpSTR.'Txt','',1);
		$this->sUserDescriptions[0]['Columns'][$tmpSTR]['Value']=$tmpAR0[0];
		$tmpSTR='CCode';
		$tmpAR0=$this->AnalyerRequest($tmpSTR.'Txt','',1);
		$tmpCCode=$tmpAR0[0];
		$tmpSTR='uttType';
		$this->sUserDescriptions[4]['Columns'][$tmpSTR]['Value']='1,2,3,';
		//-- ------ #Submit limit check ------ --
		$tmpINT=$this->submitLimitRead($this->sysPage,-1,-1,-1);
		if($tmpINT!=0){
			//$this->sJscript=$this->Message('SUCCESS','','对不起，您登陆次数过多，请'.$this->sysFileConfig['SubmitLimitFreeze'].'秒后再尝试登陆。','');
			//return 1;
		}
		//-- ------ #CCode ------ --
		if(!array_key_exists('NetsCCode',$_SESSION)){
			$this->submitLimitWrite($this->sysPage,-1,-1,-1);
			$this->sJscript=$this->Message('ERROR','登陆失败','验证码错误','');
			return 1;
		}
		if($_SESSION['NetsCCode']=='' || $_SESSION['NetsCCode']!=$tmpCCode){
			$this->submitLimitWrite($this->sysPage,-1,-1,-1);
			$this->sJscript=$this->Message('ERROR','登陆失败','验证码错误','');
			return 1;
		}
		//daily setting
		$this->sAppCore->sDbDescriptions_Other=array(
			$this->sysDbDescriptions[$this->sysTableHead.'netsuserdaily'],
			$this->sysDbDescriptions[$this->sysTableHead.'netsuserdailycont'],
			);
		$tmpSTR=$this->sysFileConfig['UserLogTemplate'];
		$tmpSTR=str_replace('{Nets.Time}',date($this->sysTimeFormat),$tmpSTR);
		$tmpSTR=str_replace('{Nets.ActionType}','登陆',$tmpSTR);
		$tmpSTR=str_replace('{Nets.Platform}','核心平台',$tmpSTR);
		$this->sAppCore->sDbDescriptions_Other[1]['Columns']['udctIntroduct']['Value']=$tmpSTR;
		$this->sAppCore->sDbDescriptions_Other[0]['Columns']['udtType']['Value']=0;
		$this->sAppCore->sDbDescriptions_Other[1]['Columns']['udctIpAddress']['Value']=$this->getIP();
		$this->sAppCore->sSite=$this->sysSiteHome;
		
		$tmpINT=$this->sAppCore->Login($this->sUserDescriptions);
		if($tmpINT!=0){
			$this->submitLimitWrite($this->sysPage,-1,-1,-1);
			$this->sJscript=$this->Message('ERROR','登陆失败',$this->sAppCore->sysLastError,'');
			return $tmpINT;
		}
		
		$tmpURL=$this->sysFileConfig['sysUiCoreRoot'].$this->sysFileConfig['QPlatformMainAddress'];
		$tmpAR0=$this->AnalyerRequest($this->sysCookieHead.$this->sysManaPLURLCookieName,'',2);
		if ($tmpAR0[0]!='') {
			$tmpURL=$tmpAR0[0];
		}
		$this->sJscript=$this->Message('SUCCESS','登陆成功','欢迎使用网集(unionNet.com)管理平台',$tmpURL);
		return 0;
	}
}
//-- ------ #Instanct ------
$tmpDefault=new PaDefault();
$tmpDefault->OnPage();
$tmpDefault->sysMetaTitle.=' - '.$tmpDefault->sysFileConfig['sysTitle'];
require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysQPlatformTemplatePath.'Component/Head_1.php');
require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysQPlatformTemplatePath.'Template/Login.php');
require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysQPlatformTemplatePath.'Component/End_1.php'); ?>