<?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/netsMobile.php');
require($netsFileConfig['sysCoreRoot_Real'].'Inc/netsFunc/Func/netsSocket.php');
require($netsFileConfig['sysCoreRoot_Real'].'Inc/netsFunc/Func/netsEmail.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'=>$this->sysTableHead.'netsuserinfo','sttColumnHead'=>'uit'),
			array('sttTableName'=>$this->sysTableHead.'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=='DRegister'){
			$this->OnRegister();
		}
		
	}
	public function OnRegister(){
		$tmpSTR='uitLoginAPI_ID';
		$tmpAR0=$this->AnalyerRequest($tmpSTR.'Txt','',1);
		$this->sUserDescriptions[0]['Columns'][$tmpSTR]['Value']=$tmpAR0[0];
		$tmpSTR='uitName';
		$tmpAR0=$this->AnalyerRequest($tmpSTR.'Txt','',1);
		$this->sUserDescriptions[0]['Columns'][$tmpSTR]['Value']=$tmpAR0[0];
		$tmpSTR='uitNickname';
		$tmpAR0=$this->AnalyerRequest($tmpSTR.'Txt','',1);
		$this->sUserDescriptions[0]['Columns'][$tmpSTR]['Value']=$tmpAR0[0];
		$tmpSTR='uitLoginAPI_Type';
		$tmpAR0=$this->AnalyerRequest($tmpSTR.'Txt','',1);
		$this->sUserDescriptions[0]['Columns'][$tmpSTR]['Value']=$tmpAR0[0];
		
		$this->sUserDescriptions[0]['Columns']['uitTypeid']['Value']=5;
		$this->sUserDescriptions[4]['Columns']['uttType']['Value']=5;
		$this->sUserDescriptions[0]['Columns']['uitUnitid']['Value']=1;
		$this->sUserDescriptions[0]['Columns']['uitCreateBy']['Value']=1;
		//-- ------ #UserRegAble ------ --
		if($this->sysFileConfig['userUserRegAble']==0){
			$this->sJscript=$this->Message('ERROR','用户注册失败','对不起，本平台暂停用户注册，请与管理员联系。','');
			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->sJscript=$this->Message('ERROR','提交失败','验证码错误','');
			return 1;
		}
		if($_SESSION[$tmpSTR]=='' || $_SESSION[$tmpSTR]!=$tmpCCode){
			$this->sJscript=$this->Message('ERROR','提交失败','验证码错误','');
			return 1;
		}
		//-- ------ #Register ------ --
		$this->sApp->sSite=$this->sCode->URL_MakeParameter($this->sysPage,1);
		$tmpINT=$this->sApp->ApiRegister($this->sUserDescriptions);
		if($tmpINT!=0){
			$this->sJscript=$this->Message('ERROR','登陆失败',$this->sApp->sysLastError,'');
			return $tmpINT;
		}
		//-- ------ #Send mail or mobile ------ --
		//#Send check mail
		$this->sysLastMessage='欢迎注册'.$this->sysFileConfig['bussinessMetaTitle'].'通用帐号，登陆中。';
		$tmpEmail=new netsEmail(array($this->sysFileConfig['EmailHost'],
			$this->sysFileConfig['EmailHostPost'],
			$this->sysFileConfig['EmailName'],
			$this->sysFileConfig['EmailPxd'],
			$this->sysCharset,));
		$tmpMobile=new netsMobile(array($this->sysFileConfig['MobileUName'],
			$this->sysFileConfig['MobilePxd'],
			$this->sysFileConfig['MobileSendURL'],
			$this->sysFileConfig['MobileReceiveURL'],
			$this->sysFileConfig['MobileCountURL'],));
			
		//#Get userinfo
		$tmpINT=$this->sApp->GetUserinfo($this->sUserDescriptions,'uitEmail');
		if($tmpINT!=0){
			$this->sJscript=$this->Message('ERROR','重新发送注册认证邮件错误',$this->sApp->sysLastError,'');
			return 1;
		}
		//#Daily setting
		$this->sApp->sDbDescriptions_Other=array(
			array($this->sysDbDescriptions[$this->sysTableHead.'netsuserdaily'],
				$this->sysDbDescriptions[$this->sysTableHead.'netsuserdailycont'],),
			);
		$this->sApp->sDbDescriptions_Other[0][1]['Columns']['udctIpAddress']['Value']=$this->getIP();
		//#Send
		//-- #Send register mail --
		$tmpSTR=$this->sysFileConfig['EmailRegTemplate'];
		$tmpSTR=str_replace('{Nets.Title}',$this->sysFileConfig['bussinessMetaTitle'],$tmpSTR);
		$tmpSTR=str_replace('{Nets.Charset}',$this->sysCharset,$tmpSTR);
		$tmpSTR=str_replace('{Nets.Name}',$this->sUserDescriptions[0]['Columns']['uitName']['Value'],$tmpSTR);
		$tmpSTR=str_replace('{Nets.Page}',$this->sysSiteHome,$tmpSTR);
		$tmpAR0=array(
			$this->sUserDescriptions[0]['Columns']['uitEmail']['Value'],
			$this->sysFileConfig['EmailName'],
			$this->sysFileConfig['bussinessMetaTitle'].' - 欢迎加入',
			$tmpSTR,
			);
		$tmpINT=$tmpEmail->sendSmtp($tmpAR0);
		//-- ------ #Login ------ --
		$this->sUserDescriptions[4]['Columns']['uttType']['Value']='1,2,3,4,5,';
		//-- #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;
		//-- ### --
		$tmpINT=$this->sApp->Login_Api($this->sUserDescriptions);
		
		$this->sJscript=$this->Message('SUCCESS','设置成功',$this->sysLastMessage,$this->sysFileConfig['businessMainAddress']);
		return 0;
	}
	public function OnList(){
		$tmpAR0=$this->AnalyerRequest('DType','SINA',0);
		$this->sDType=$tmpAR0[0];
		$tmpSimpleXml=new netsSimpleXml();
		//-- ------ #Control ------ --
		#-- #0 --
		$this->sUiDescription_Custom0=array();
		$tmpSTR=$this->sUiDescriptionPath.'User/nets/register_openshare.php';
		if(file_exists($tmpSTR)){
			require($tmpSTR);
			$this->sUiDescription_Custom0=$sysUiDescriptions['register_openshare'];
		}
		//-- ------ ### ------ --
		if($this->sDType=='SINA'){
			//-- ------ #SINA ------ --
			$tmpOpenShare_Sina=new openShare_Sina();
			if (isset($_SESSION[$this->sysCookieHead.$this->sysFileConfig['OpenShare_Session'].'SINA'])) {
				$tmpSESSION=$_SESSION[$this->sysCookieHead.$this->sysFileConfig['OpenShare_Session'].'SINA'];
				$tmpAR0=$this->AnalyerRequest('oauth_verifier','',0);
				$tmpSTR=$tmpAR0[0];
				$tmpINT=$tmpOpenShare_Sina->getLastKey($tmpSESSION['oauth_token'],$tmpSESSION['oauth_token_secret'],$tmpSTR);
				$_SESSION[$this->sysCookieHead.$this->sysFileConfig['OpenShare_Session'].'SINA']=null;
				$_SESSION[$this->sysCookieHead.$this->sysFileConfig['OpenShare_Session'].'SINA_LAST']=$tmpOpenShare_Sina->sAR_KEY;
				
			}else if (isset($_SESSION[$this->sysCookieHead.$this->sysFileConfig['OpenShare_Session'].'SINA_LAST'])) {
				$tmpOpenShare_Sina->sAR_KEY=$_SESSION[$this->sysCookieHead.$this->sysFileConfig['OpenShare_Session'].'SINA_LAST'];
				
			}else {
				return 1;
			}
			$tmpSTR=$tmpOpenShare_Sina->getData_Credentials();
			$tmpINT=$tmpSimpleXml->loadXml($tmpSTR);
			$this->sUserDescriptions[0]['Columns']['uitLoginAPI_ID']['Value']=$tmpSimpleXml->sXmlElement->id.'';
			$this->sUserDescriptions[0]['Columns']['uitName']['Value']='SINA_'.$tmpSimpleXml->sXmlElement->id;
			$this->sUserDescriptions[0]['Columns']['uitNickname']['Value']=$tmpSimpleXml->sXmlElement->name.'';
			$this->sUserDescriptions[0]['Columns']['uitLoginAPI_Type']['Value']='1';
			
		}else if ($this->sDType=='TENCENT') {
			//-- ------ #TENCENT ------ --
			$tmpOpenShare_Tencent=new openShare_Tencent();
			if (isset($_SESSION[$this->sysCookieHead.$this->sysFileConfig['OpenShare_Session'].'TENCENT'])) {
				$tmpSESSION=$_SESSION[$this->sysCookieHead.$this->sysFileConfig['OpenShare_Session'].'TENCENT'];
				$tmpAR0=$this->AnalyerRequest('oauth_verifier','',0);
				$tmpSTR=$tmpAR0[0];
				$tmpINT=$tmpOpenShare_Tencent->getLastKey($tmpSESSION['oauth_token'],$tmpSESSION['oauth_token_secret'],$tmpSTR);
				$_SESSION[$this->sysCookieHead.$this->sysFileConfig['OpenShare_Session'].'TENCENT']=null;
				$_SESSION[$this->sysCookieHead.$this->sysFileConfig['OpenShare_Session'].'TENCENT_LAST']=$tmpOpenShare_Tencent->sAR_KEY;
				
			}else if (isset($_SESSION[$this->sysCookieHead.$this->sysFileConfig['OpenShare_Session'].'TENCENT_LAST'])) {
				$tmpOpenShare_Tencent->sAR_KEY=$_SESSION[$this->sysCookieHead.$this->sysFileConfig['OpenShare_Session'].'TENCENT_LAST'];
				
			}else {
				return 1;
			}
			$tmpSTR=$tmpOpenShare_Tencent->getData_Credentials();
			$tmpINT=$tmpSimpleXml->loadXml($tmpSTR);
			$this->sUserDescriptions[0]['Columns']['uitLoginAPI_ID']['Value']=$tmpSimpleXml->sXmlElement->name.'';
			$this->sUserDescriptions[0]['Columns']['uitName']['Value']='TENCENT_'.$tmpSimpleXml->sXmlElement->name;
			$this->sUserDescriptions[0]['Columns']['uitNickname']['Value']=$tmpSimpleXml->sXmlElement->nick.'';
			$this->sUserDescriptions[0]['Columns']['uitLoginAPI_Type']['Value']='2';
			
		}
		
		
		
		//-- ------ #Login ------ --
		$this->sUserDescriptions[4]['Columns']['uttType']['Value']='1,2,3,4,5,';
		//-- #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;
		//-- ### --
		$tmpINT=$this->sApp->Login_Api($this->sUserDescriptions);
		if($tmpINT!=10){
			$this->sJscript=$this->Message('SUCCESS','设置成功','设置成功，正在登陆...',$this->sysFileConfig['businessMainAddress']);
			return 0;
		}
		return 0;
	}
	public function DefUiPanel(&$pColumn,$pFlag){
		parent::DefUiPanel($pColumn,$pFlag);
		if($pColumn['stcotName']=='uitName'){
			$pColumn['Value']=$this->sUserDescriptions[0]['Columns']['uitName']['Value'];
		}else if($pColumn['stcotName']=='uitNickname'){
			$pColumn['Value']=$this->sUserDescriptions[0]['Columns']['uitNickname']['Value'];
		}else if($pColumn['stcotName']=='uitLoginAPI_ID'){
			$pColumn['Value']=$this->sUserDescriptions[0]['Columns']['uitLoginAPI_ID']['Value'];
		}else if($pColumn['stcotName']=='uitLoginAPI_Type'){
			$pColumn['Value']=$this->sUserDescriptions[0]['Columns']['uitLoginAPI_Type']['Value'];
		
			
		}
		return $pColumn;
	}
	
	public function DefUiJscript($pFlag){
?>
function JsDCheck(pPara){
	var tmpControl="";
	var tmpError="";
	var tmpChecker=new netsChecker();
	var tmpActionWithOut=document.getElementById("ActionWithOut");
	document.getElementById(tmpCommon.sysActionTypeF).value=1;
	var Coun0=0;
	//-- ------ #ActionWithOut ------ --
	if(tmpActionWithOut==undefined){
		return true;
	}
	if(tmpActionWithOut.value=="1"){
		return true;
	}else if(tmpActionWithOut.value=="2"){
		return false;
	}
	//-- ------ #Check ------ --
	//#uitName
	tmpINT=tmpUser.OnReg_Name("uitEmail");
	if(tmpINT==1){
		Coun0++;
		tmpError+=Coun0+tmpUser.OnReg_EMessage+tmpCommon.sysSPLIT8;
	}
	//#CCode
	tmpCheckCont=document.getElementById("CCodeTxt");
	tmpCheckCont.value=tmpChecker.Filter(tmpCheckCont.value,0);
	if(tmpCheckCont.value.length!=5){
		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{
		document.getElementById(tmpCommon.sysActionTypeF).value=0;
		return true;
	}
}
<?php
	}
}
?>