<?php
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/netsuseroperationrecord.php');
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/netsuseroperationrecordcont.php');
require($netsFileConfig['sysCoreRoot_Real'].'Inc/netsFunc/Func/netsXml.php');
require($netsFileConfig['sysCoreRoot_Real'].'Inc/netsFunc/Func/netsSimpleXml.php');
require($netsFileConfig['sysCoreRoot_Real'].'Inc/netsFunc/Func/openShare/openShare.php');
require($netsFileConfig['sysCoreRoot_Real'].'Inc/netsFunc/Func/openShare/openShare_Sina.php');
require($netsFileConfig['sysCoreRoot_Real'].'Inc/netsFunc/Func/openShare/openShare_Tencent.php');


class PaDefault extends CustomPage {
	private $sysErrorClassID='3001';
	private $sysErrorFuncID=0;
	private $sysErrorID=0;
	public $sUserDescriptions=array();
	
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnBInitial(){
		$this->sMetaTitle='用户登陆';
		$this->getUser('1,2,3,4,5,');
		$this->sTable=array(
			array('sttTableName'=>'netsuserinfo','sttColumnHead'=>'uit'),
			array('sttTableName'=>'netsuserinfocont','sttColumnHead'=>'uict'),);
		
		$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']='';
		$this->sApp=new netsuserinfo($this->sConnString);
	}
	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];
		$tmpCCode=$tmpAR0[0];
		$tmpSTR='uttType';
		$this->sUserDescriptions[4]['Columns'][$tmpSTR]['Value']='1,2,3,4,5,';
		//-- ------ #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 ------ --
		$tmpSTR='CCode';
		$tmpAR0=$this->AnalyerRequest($tmpSTR.'Txt','',1);
		$tmpCCode=$tmpAR0[0];
		$tmpSTR=$tmpSTR.'Txt_IFrame';
		if(!array_key_exists($tmpSTR,$_SESSION)){
			$this->submitLimitWrite($this->sysPage,-1,-1,-1);
			$this->sJscript=$this->Message('ERROR','提交失败','验证码错误','');
			return 1;
		}
		if($_SESSION[$tmpSTR]=='' || $_SESSION[$tmpSTR]!=$tmpCCode){
			$this->submitLimitWrite($this->sysPage,-1,-1,-1);
			$this->sJscript=$this->Message('ERROR','提交失败','验证码错误','');
			return 1;
		}
		//-- #daily setting --
		$this->sApp->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->sApp->sDbDescriptions_Other[1]['Columns']['udctIntroduct']['Value']=$tmpSTR;
		$this->sApp->sDbDescriptions_Other[0]['Columns']['udtType']['Value']=0;
		$this->sApp->sDbDescriptions_Other[1]['Columns']['udctIpAddress']['Value']=$this->getIP();
		$this->sApp->sSite=$this->sysSiteHome;

		//-- #Login --
		$tmpINT=$this->sApp->Login($this->sUserDescriptions);
		if($tmpINT!=0){
			$this->submitLimitWrite($this->sysPage,-1,-1,-1);
			$this->sJscript=$this->Message('ERROR','登陆失败',$this->sApp->sysLastError,'');
			return $tmpINT;
		}
		//-- #Code operation --
		$tmpDbDescriptions=array(
			$this->sysDbDescriptions[$this->sysTableHead.'netsuseroperationrecord'],
			$this->sysDbDescriptions[$this->sysTableHead.'netsuseroperationrecordcont'],
			);
		$tmpDbDescriptions[0]['Columns']['uortName']['Value']='用户登陆积分';
		$tmpDbDescriptions[0]['Columns']['uortCreateBy']['Value']=$this->sUserDescriptions[0]['Columns']['uitID']['Value'];
		$tmpDbDescriptions[0]['Columns']['uortCreateTime']['Value']=date($this->sysTimeFormat);
		$tmpDbDescriptions[0]['Columns']['uorrtIntroduct']['Value']=$tmpDbDescriptions[0]['Columns']['uortName']['Value'];
		$tmpINT=$this->sApp->CalculationCode($tmpDbDescriptions,'Nets_User_Login');
		if($tmpINT!=0){
			$this->submitLimitWrite($this->sysPage,-1,-1,-1);
			$this->sJscript=$this->Message('ERROR','处理用户积分错误',$this->sApp->sysLastError,'');
			return $tmpINT;
		}
		//-- #Write URL cookie --
		$tmpURL=$this->sysFileConfig['businessMainAddress'];
		$tmpAR0=$this->AnalyerRequest($this->sysCookieHead.$this->sysUserPLURLCookieName,'',2);
		if ($tmpAR0[0]!='') {
			$tmpURL=$tmpAR0[0];
		}
		$this->sJscript=$this->Message('SUCCESS','登陆成功','欢迎使用'.$this->sysFileConfig['bussinessMetaTitle'].'用户自助管理平台',$tmpURL);
		return 0;
	}
	public function OnList(){
		//-- ------ #Control ------ --
		$this->sUiDescription_Custom0=array();
		$tmpSTR=$this->sUiDescriptionPath.'User/nets/user_login.php';
		if(file_exists($tmpSTR)){
			require($tmpSTR);
			$this->sUiDescription_Custom0=$sysUiDescriptions['user_login'];
		}
		//-- ------ ### ------ --
		//-- #SINA --
		$tmpOpenShare_Sina=new openShare_Sina();
		$tmpOpenShare_Sina->sPAGE=$this->sysPage;
		$tmpOpenShare_Sina->sPAGE_Callback=$this->sysSiteHome.$this->sysFileConfig['OpenShare_LoginURL'].'?DType=SINA';
		$tmpINT=$tmpOpenShare_Sina->getAuth();
		$this->sURL_OpenShare_Sina=$tmpOpenShare_Sina->getURL_Login();
		$_SESSION[$this->sysCookieHead.$this->sysFileConfig['OpenShare_Session'].'SINA']=$tmpOpenShare_Sina->sAR_KEY;
		//-- #TENCENT --
		$tmpOpenShare_Tencent=new openShare_Tencent();
		$tmpOpenShare_Tencent->sPAGE=$this->sysPage;
		$tmpOpenShare_Tencent->sPAGE_Callback=$this->sysSiteHome.$this->sysFileConfig['OpenShare_LoginURL'].'?DType=TENCENT';
		$tmpINT=$tmpOpenShare_Tencent->getAuth();
		$this->sURL_OpenShare_Tencent=$tmpOpenShare_Tencent->getURL_Login();
		$_SESSION[$this->sysCookieHead.$this->sysFileConfig['OpenShare_Session'].'TENCENT']=$tmpOpenShare_Tencent->sAR_KEY;
		
		
		return 0;
	}
	
	public function DefUiPanel(&$pColumn,$pFlag){
		parent::DefUiPanel($pColumn,$pFlag);
		if ($pColumn['stcotName']=='uitName') {
			$pColumn['Value']=$this->sUserDescriptions[0]['Columns']['uitName']['Value'];
		}
		$pColumn['ControlStyle']='width:270px;';
		return 0;
	}
	public function DefUiJscript($pFlag){
?>
function JsDCheck(pPara){
	var tmpControl="";
	var tmpError="";
	var tmpChecker=new netsChecker();
	var tmpActionWithOut=document.getElementById("ActionWithOut");
	var Coun0=0;
	//-- ------ #ActionWithOut ------ --
	if(tmpActionWithOut==undefined){
		return true;
	}
	if(tmpActionWithOut.value=="1"){
		return true;
	}else if(tmpActionWithOut.value=="2"){
		return false;
	}
	//-- ------ #Check ------ --
	//#uitName
	tmpCheckCont=document.getElementById("uitNameTxt");
	tmpCheckCont.value=tmpChecker.Filter(tmpCheckCont.value,0);
	if(!tmpChecker.CheckLen(tmpCheckCont.value,5,32)){
		Coun0++;
		tmpError+=Coun0+".登陆用户名必须大于5位"+tmpCommon.sysSPLIT8;
	}
	//#uitPxd
	tmpCheckCont=document.getElementById("uitPxdTxt");
	tmpCheckCont.value=tmpChecker.Filter(tmpCheckCont.value,0);
	if(!tmpChecker.CheckLen(tmpCheckCont.value,5,32)){
		Coun0++;
		tmpError+=Coun0+".登陆密码名必须大于5位"+tmpCommon.sysSPLIT8;
	}
	//#CCode
	tmpCheckCont=document.getElementById("CCodeTxt");
	tmpCheckCont.value=tmpChecker.Filter(tmpCheckCont.value,0);
	if(!tmpChecker.CheckLen(tmpCheckCont.value,5,32)){
		Coun0++;
		tmpError+=Coun0+".验证码必须为5位"+tmpCommon.sysSPLIT8;
	}
	//-- ------ #Result ------ --
	if(tmpError!=""){
		tmpSTR="<span class=\"FStrong\">对不起，您提交的内容存在以下错误:</span>"+tmpCommon.sysSPLIT8+tmpError;
		tmpFrames.showMessage("系统消息 - <?php echo ($this->sysFileConfig['bussinessMetaTitle']); ?>",tmpSTR,"","0");
		return false;
	}else{
		return true;
	}
}
<?php
	}
}
?>