<?php
class CustomPage extends ComPage {
	public $sTemplatePath='';
	
	public function CustomPage(){
		$this->ComPage();
	}
	public function OnFirstInitial(){
		$this->resetConfig('corenets,_DemoCore/,nets,xf7vsfk2e,corenets_,localhost,3306,root,6KJ1FJVNS486JJKS,0,corenets_');
	}
	public function OnInitial(){
		//-- ------ #Get db config ------ --
		$this->sDb=new netsDb($this->sConnString);
		$this->sDbCore=new netsDb($this->sConnStringCore);
		//-- ------ #Zone ------ --
		//-- #Require --
		require('../../../Cache/DbCache/Zone/Cache_0.php');
		$this->sZoneCache=$netsAR_Zone;
		//-- #Initial --
		$this->sZoneid=-1;
		$this->sZoneName='所有地区';
		$this->sZoneid_My=-1;
		$this->sZoneName_My='所有地区';
		$this->sApp_Zone=new netssyszone($this->sConnString);
		//-- #Set --
		$tmpAR0=$this->AnalyerRequest($this->sysCookieHead.$this->sysZoneCookieName.'_My','-1,',2);
		If ($tmpAR0[0]==-1) {
			$tmpAR1=array();
			$tmpINT=$this->sApp_Zone->getZone_Byip($this->sysIP,$this->sZoneCache,$tmpAR1);
			$this->sZoneid_My=$tmpAR1['sztID'];
			$this->sZoneName_My=$tmpAR1['sztName'];
		}else {
			$this->sZoneid_My=$tmpAR0[0];
			$this->sZoneName_My=$tmpAR0[1];
		}
		$tmpAR_Require=$this->AnalyerRequest('Zoneid',-1,0);
		$tmpAR_Cookie=$this->AnalyerRequest($this->sysCookieHead.$this->sysZoneCookieName,'-1,',2);
		//-- #Reset --
		$this->sZoneid=$this->sZoneid_My;
		if ($tmpAR_Cookie[0]!=-1) {
			$this->sZoneid=$tmpAR_Cookie[0];
		}
		if ($tmpAR_Require[0]!=-1) {
			$this->sZoneid=$tmpAR_Require[0];
			if ($this->sZoneid==0) {
				$this->sZoneid=-1;
			}
		}
		//-- #Must be --
		if ($this->sysFileConfig['sysZoneMustbe']==1 && $this->sZoneMustbe==1 && $this->sZoneid=-1) {
			header('Location: '.$this->sysFileConfig['PathRoot'].$this->sysFileConfig['sysZoneMustbeURL']);
			exit();
		}
		//-- #Default --
		if ($this->sysFileConfig['Zone_Default_Able']==1 && $this->sZoneid==-1) {
			$this->sZoneid=$this->sysFileConfig['Zone_ID_Default'];
		}
		//-- #Get name --
		$tmpAR0=array();
		$this->sApp_Zone->chooseZone($this->sZoneid,$this->sZoneCache,$tmpAR0);
		$this->sZoneName=$tmpAR0['sztName'];
		$tmpSTR=$this->sZoneid.$this->sysSPLIT1.$this->sZoneName;
		$this->writeCookie($this->sysNormalCookiePath,$this->sysCookieHead.$this->sysZoneCookieName,$tmpSTR);
		$tmpSTR=$this->sZoneid_My.$this->sysSPLIT1.$this->sZoneName_My;
		$this->writeCookie($this->sysNormalCookiePath,$this->sysCookieHead.$this->sysZoneCookieName.'_My',$tmpSTR);
		
		
		
		parent::OnInitial();
	}
	public function OnLoadPreData(){
		parent::OnLoadPreData();
		//-- ------ #Menu ------ --
		//-- #MENU --
		$tmpSTR=str_replace($this->sysSiteHome,'../../../',$this->sysPage);
		$tmpData0=$this->sApp_Menu->getMenuid(0,$tmpSTR,'User');
		if(count($tmpData0)>0){
			$this->sMenuid=$tmpData0[0]['smetID'];
		}
		
		return 0;
	}
	public function getMenu($pParid,$pUserTypeid,$pMenuPower){
		$tmpFlag='User';
		$tmpAR0=explode($this->sysSPLIT1,$pMenuPower);
		array_pop($tmpAR0);
		$tmpSTR='';
		foreach($tmpAR0 as $Row0){
			$tmpSTR.=' OR A.smetID='.$Row0.' ';
		}
		return $this->sMenuApp->getChildMenu($pParid,3,$tmpFlag,'',$pUserTypeid,$tmpSTR);
	}
	public function accMenu($pUserTypeid){
		$this->sAR_Menu=array();
		$tmpFlag='User';
		$tmpData0=$this->sApp_Menu->getParMenu($this->sMenuid,$pUserTypeid,$tmpFlag);
		if (count($tmpData0)>0) {
			$this->sAR_Menu[]=$tmpData0[0];
		}
		$Coun0=0;
		while (count($this->sAR_Menu)>$Coun0) {
			$tmpData0=$this->sApp_Menu->getParMenu($this->sAR_Menu[$Coun0]['smetParid'],$pUserTypeid,$tmpFlag);
			if (count($tmpData0)>0) {
				$this->sAR_Menu[]=$tmpData0[0];
			}
			$Coun0++;
		}
		
		return 0;
	}
	public function checkUser($pType){
		$tmpCode=new netsCode();
		$tmpDescription=array();
		$tmpDescription[0]=$this->sysDbDescriptions[$this->sysTableHead.'netsuserinfo'];
		$tmpDescription[1]=$this->sysDbDescriptions[$this->sysTableHead.'netsuserinfocont'];
		$tmpDescription[2]=$this->sysDbDescriptions[$this->sysTableHead.'netsuserunit'];
		$tmpDescription[3]=$this->sysDbDescriptions[$this->sysTableHead.'netsuserunitcont'];
		$tmpDescription[4]=$this->sysDbDescriptions[$this->sysTableHead.'netsusertype'];
		$tmpDescription[5]=$this->sysDbDescriptions[$this->sysTableHead.'netsusertypecont'];
		$tmpDescription[6]=$this->sysDbDescriptions[$this->sysTableHead.'netsuserdepartment'];
		$tmpDescription[7]=$this->sysDbDescriptions[$this->sysTableHead.'netsuserdepartmentcont'];
		$tmpDescription[8]=$this->sysDbDescriptions[$this->sysTableHead.'netsusergroup'];
		$tmpDescription[9]=$this->sysDbDescriptions[$this->sysTableHead.'netsusergrade'];
		$tmpUserApp=new netsuserinfo($this->sConnString);
		$tmpSTR='uttType';
		$tmpDescription[4]['Columns'][$tmpSTR]['Value']=$pType;

		$tmpINT=$tmpUserApp->ReadUserinfo($tmpDescription);
		if($tmpINT!=0){
			$tmpINT=$this->writeCookie($this->sysNormalCookiePath,$this->sysCookieHead.$this->sysUserPLURLCookieName,$this->sysURL);
			header('Location: '.$this->sysFileConfig['businessLogoutAddress']);
			exit();
		}
		$this->sUserInfo=$tmpDescription;
		if ($this->sFunctionname!='') {
			$tmpUserApp->GetUserPowerArray($this->sUserInfo,$this->sFunctionname,'Mana',$this->sAR_UserPower);
		}
		if (in_array($this->sFunctionname.'_view',$this->sAR_UserPower) && count($this->sAR_UserPower)>1) {
			$tmpINT=$this->writeCookie($this->sysNormalCookiePath,$this->sysCookieHead.$this->sysManaPLURLCookieName,$this->sysURL);
			header('Location: '.$this->sysFileConfig['sysCoreRoot'].$this->sysFileConfig['ManaPageNopower']);
			exit();
		}
		$this->sMainUserid=$tmpCode->Int32($this->sUserInfo[0]['Columns']['uitID']['Value'],0);

		return 0;
	}
	public function checkPagepower($pFlag,$pUsertypePowers){
		$tmpAR0=explode($this->sysSPLIT1,$pUsertypePowers);
		foreach ($tmpAR0 as $Row0){
			if ($Row0==$pFlag) {
				header('Location: '.$this->sysFileConfig['sysCoreRoot'].$this->sysFileConfig['UserPageNopower']);
				exit();
			}
		}
		
		return 0;
	}
	
	public function setControlStyle($pStyle){
		return ' class="SControl1 '.$pStyle.'" onfocus="this.className=\'SControlLight1 '.$pStyle.'\';" onblur="this.className=\'SControl1 '.$pStyle.'\';" ';
	}
	
}
?>