<?php
class ID
{
public $host;
public $thishost;
public $urlinfo = array();
	
	function __construct($url){
		$this -> thishost = $url;
		$this -> host = $_SERVER["HTTP_HOST"];
		$this -> urlinfo = $this->ActionType();
	}  
	function getSiteId(){
	$siteid = $this->siteId();
	if($siteid != NULL){
			return $siteid;
		}
		die("Error:Can't get siteid!Please tell to Administrator!");
	}
	
	function isSysHost(){
	$array = explode('|',$this->thishost);
        foreach($array as $value){
		  if($this->host == $value){
		    return TRUE;
			}
		  }
		 return FALSE;
	}
	function siteId(){
	if(!$this->isSysHost())
		{
    $sql = "SELECT id,siteid,url,zhuanfa,go_url FROM urlzf WHERE url='{$this->host}'";
    $result = mysql_query($sql);
    if($result && mysql_num_rows($result)>0){
        list($id,$siteid,$url,$zhuanfa,$go_url) = mysql_fetch_row($result);
		if($zhuanfa == 'YES'){header("location:".$go_url);exit();}
			if($this->isSite($siteid))
			{
				return $siteid;
			}
			die("哎呀，一不小心到火星了，您要访问的网站还没有被申请或者已经被删除！");
        }
		die("Error:No Find This Page!");
		}
		if($this->isSite('1000'))
		{
		return '1000';
		}
		die("用户数据没有导入，请重新安装！");
	}
	function isSite($siteid){
		$sql = "SELECT id,stitle,qsid,name,site_u FROM user WHERE id='{$siteid}' AND site='YES'";
		$result = mysql_query($sql);
        if($result && mysql_num_rows($result) > 0)
		{
			return	TRUE;
        }
			return FALSE;
	}
	
	function getId(){
		if($this->urlinfo[0] != NULL)
		{
			$id = explode("-",$this->urlinfo[0]);
			return $id;
		}
		return array();
	}
	function getAc(){
		$id = explode("-",$this->urlinfo[1]);
		return $id;
	}
	function ActionType(){
		$urlinfo = explode('/',$_GET['cid']);
		return $urlinfo;
	}
}