<?php
require($netsFileConfig['sysCoreRoot'].'Inc/netsFunc/Func/netsSocket.php');
require($netsFileConfig['sysCoreRoot'].'Inc/netsFunc/Func/netsEmail.php');
require($netsFileConfig['sysCoreRoot'].'Inc/m_Nets/User/netsuserunit.php');

class PaDefault extends CustomPage {
	private $sysErrorClassID='3001';
	private $sysErrorFuncID=0;
	private $sysErrorID=0;
	
	public $sError='';
	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.'netsuserdepartment'];
		$this->sUserDescriptions[5]=$this->sysDbDescriptions[$this->sysTableHead.'netsuserdepartmentcont'];
		$this->sUserDescriptions[6]=$this->sysDbDescriptions[$this->sysTableHead.'netsusertype'];
		$this->sUserDescriptions[7]=$this->sysDbDescriptions[$this->sysTableHead.'netsusergroup'];
		$this->sUserDescriptions[8]=$this->sysDbDescriptions[$this->sysTableHead.'netsusergrade'];
		$this->sUserDescriptions[0]['Columns']['uitEmail']['Value']='';
		$this->sApp=new netsuserinfo($this->sConnString);
		
		$this->sTemplatePath='User/OffUser_Submit.php';
	}
	public function OnBEvent(){
		if($this->sActionTypeF=='DSubmit'){
			$this->OnSubmit();

		}
	}
	public function OnSubmit(){
		$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];
		//-- ------ #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;
		}
		//-- ------ #Get Encryption string ------ --
		//daily setting
		$this->sApp->sDbDescriptions_Other=array(
			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[0][1]['Columns']['udctIntroduct']['Value']=$tmpSTR;
		$this->sApp->sDbDescriptions_Other[0][0]['Columns']['udtType']['Value']=3;
		$this->sApp->sDbDescriptions_Other[0][1]['Columns']['udctIpAddress']['Value']=$this->getIP();
		
		$tmpINT=$this->sApp->OffUser($this->sUserDescriptions);
		if($tmpINT!=0){
			$this->sJscript=$this->Message('ERROR','注销用户失败','对不起，您所填写的用户名不存在或密码错误','');
			return 1;
		}
		$tmpEncryption=$this->sUserDescriptions[0]['Columns']['uitPxd']['Value'];
		//-- ------ #Send Email ------ --
		$tmpEmail=new netsEmail(array($this->sysFileConfig['EmailHost'],
			$this->sysFileConfig['EmailHostPost'],
			$this->sysFileConfig['EmailName'],
			$this->sysFileConfig['EmailPxd'],
			$this->sysCharset,));
		$tmpSTR=$this->sysFileConfig['EmailOffTemplate'];
		$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);
		$tmpSTR=str_replace('{Nets.Encryption}',$tmpEncryption,$tmpSTR);
		$tmpAR0=array(
			$this->sUserDescriptions[0]['Columns']['uitEmail']['Value'],
			$this->sysFileConfig['EmailName'],
			$this->sysFileConfig['bussinessMetaTitle'].' - 用户注销邮件',
			$tmpSTR,
			);
		$tmpINT=$tmpEmail->sendSmtp($tmpAR0);
		$this->sJscript=$this->Message('ERROR','用户注销','您的用户已成功注销，您可以用您注销的用户名再次注册，或参与平台的完善计划。',$this->sysFileConfig['businessLoginAddress']);
		return 0;
	}
	
	public function OnList(){
		//-- ------ #Control ------ --
		#-- #0 --
		$this->sUiDescription_Custom0=array();
		$tmpSTR=$this->sUiDescriptionPath.'User/nets/offuser_submit.php';
		if(file_exists($tmpSTR)){
			require($tmpSTR);
			$this->sUiDescription_Custom0=$sysUiDescriptions['offuser_submit'];
		}
		
	}
	public function DefUiPanel(&$pColumn,$pFlag){
		parent::DefUiPanel($pColumn,$pFlag);
		if($pColumn['stcotName']=='soudtName'){
			
		}
		return $pColumn;
	}
	
	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("uitEmailTxt");
	tmpCheckCont.value=tmpChecker.Filter(tmpCheckCont.value,0);
	if(!tmpChecker.CheckLen(tmpCheckCont.value,5,64)){
		Coun0++;
		tmpError+=Coun0+".用户名必须大于5位"+sysSPLIT8;
	}
	//#uitPxd
	tmpCheckCont=document.getElementById("uitPxdTxt");
	tmpCheckCont.value=tmpChecker.Filter(tmpCheckCont.value,0);
	if(!tmpChecker.CheckLen(tmpCheckCont.value,5,32)){
		Coun0++;
		tmpError+=Coun0+".密码名必须大于5位"+sysSPLIT8;
	}
	//#CCode
	tmpCheckCont=document.getElementById("CCodeTxt");
	tmpCheckCont.value=tmpChecker.Filter(tmpCheckCont.value,0);
	if(tmpCheckCont.value.length!=5){
		Coun0++;
		tmpError+=Coun0+".验证码必须为5位"+sysSPLIT8;
	}
	//-- ------ #Result ------ --
	if(tmpError!=""){
		tmpSTR="<span class=\"FStrong\">对不起，您提交的内容存在以下错误:</span>"+sysSPLIT8+tmpError;
		showMessage("系统消息 - <?php echo ($this->sysFileConfig['bussinessMetaTitle']); ?>",tmpSTR,"","0");
		return false;
	}else{
		return true;
	}
}
<?php
	}
}
?>