<?php
class CustomPage extends ComPage {
	public $sTemplatePath='';
	
	public function CustomPage(){
		$this->ComPage();
	}
	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 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);
		
		//-- #Share link --
		$this->sData_LinkShare=array();
		$tmpCacheFlag='nets/options_LinkShare_Groupsale';
		$tmpAR_Cache=$this->sDb->readCache($tmpCacheFlag);
		if(count($tmpAR_Cache)==0){
			$tmpParid=20;
			$tmpSQL=' SELECT A.cltID,A.cltName,A.cltURL,A.cltTarget,B.clctSourceR00
				FROM {Nets.TableHead}cmslink AS A
				INNER JOIN {Nets.TableHead}cmslinkcont AS B ON B.clctIndexID=A.cltID
				WHERE 1=1 AND A.cltRecycle=0 AND A.cltChecked>1 AND A.cltParid={Nets.Parid}
				ORDER BY A.cltOrderBy DESC,A.cltID DESC ';
			$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
			$tmpSTR=str_replace('{Nets.Parid}',$tmpParid,$tmpSTR);
			$this->sData_LinkShare=$this->sDb->Search($tmpSTR);
			
			if($this->sysFileConfig['CacheDbAble']==1){
				$this->sDb->writeCache($tmpCacheFlag,$this->sData_LinkShare);
			}
		}else {
			$this->sData_LinkShare=$tmpAR_Cache;
		}
		
		
		parent::OnInitial();
	}
	public function getMenu($pParid,$pUserTypeid,$pMenuPower){
		$tmpFlag='User';
		return $this->sApp_Menu->getChildMenu($pParid,3,$tmpFlag,'',$pUserTypeid,$pMenuPower);
	}
	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){
			header('Location: '.$this->sysFileConfig['businessLogoutAddress']);
			exit();
		}
		$this->sUserInfo=$tmpDescription;
		$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.'\';" ';
	}
}
?>