<?php
/**
 *类  名：Weburl
 *文件名：class_weburl.php
 *编写人：http://Www.HuCart.Com
 *类功能：分解URL地址
 */
class WebUrl
{
	//var $php_selfval ; //PHP_SELF;
	var $urlArray = array();
	var $getval   = array();
	
	function WebUrl()
	{
		$getcount = count($_GET);
		if( $getcount > 0  ) //and $getcount < 3
		{
			foreach((array)$_GET as $gkey => $gval)
			{
				if($gkey == 'page' and $gval > 0 )
				{
					$this -> getval["page"] = intval(trim($gval));
				}else if( $gkey !='' and $gval =='')
				{
					$actid = $gkey;
				}else{
					$this -> getval[$gkey] = trim($gval);
				}
			}
		}
		
		if(substr($actid , -5) =='_html' )
		{ 
			$stract 	= substr($actid,0,-5);
			$actArray 	= explode("-",$stract);
		}
		
		$arr = array('item','article','help','download','invite','resume','vote','picture','video','forum','thread','reply','message','search','aboutus','company','agreement','ajaxarea','comment','contactus','copyright','link','map','personal','book','security');
		//'view','doc','info','doc','detail','pay','shop', 'file',//还未使用预留。
		//var_dump($arr);
		if( in_array($actArray[0],$arr) )
		{
			$this -> getval["load"] 	= trim($actArray[0]);
		}else if( $actArray[0]=='')
		{
			$this -> getval["load"]  = 'index';
		}else{
			$this -> getval["load"]  = false;
		}
		if(trim($actArray[1])=='list')
		{
			$this -> getval["act"]    = 'list';
			$this -> getval["idval"]  = intval(trim($actArray[2]));
		}else if($actArray[2]=='')
		{
			//可能是自定义内容
			$this -> getval["idval"]  = trim($actArray[1]);

		}
	    
	}
	
	function checkact( $val)
	{
		$arr = array('item','article','help','download','invite','resume','vote','picture','video','forum','thread','replay','message','search');  
		//'view','doc','info','doc','detail','pay','company','shop', 'file',//还未使用预留。
		if(in_array($val,$arr))
		{
			return true;
		}else{
			return false;
		}
	}
	
	function getvalue()
	{
		$getcount = count($_GET);
		if( $getcount > 0  and $getcount < 3 )
		{
			foreach((array)$_GET as $gkey => $gval)
			{
				if($gkey == 'page' and $gval > 0 )
				{
					$page = $gval;
				}else if( $gkey !='' and $gval =='')
				{
					$actid = $gkey;
				}
			}
		}
		if(substr($actid , -5) =='_html' )
		{ 
			$stract	  =  substr($actid,0,-5);
			$actArray = explode("-",$stract);
		}
		$actval = trim($actArray[0]);
		$idval  = intval(trim($actArray[1]));
		
	}
	
	
	function urlexplode()
	{
		
		$arrphp_selfval = explode("/",$this -> php_selfval);

		foreach($arrphp_selfval as $key => $val)
		{
			if($val!='')
			{
				$this->urlArray = array_merge( $this->urlArray , explode("-",$val) );
			}
		}
		return $this->urlArray; 
	}
	
	function loadfiles()
	{

		if($this -> getval["load"]=='')
		{
			$actfile = $GLOBALS['Reque'] -> getval["load"] = 'index';
			//404error
		}else{
			$actfile = $this -> getval["load"];
		}

		if($actfile)
		{
			//加载语言包
			require ROOT_PATH.'includes/languages/'.$GLOBALS['WebConfig']['language'].'/'.$GLOBALS['language_path'].'/config.php';
			$languagesPath = ROOT_PATH.'includes/languages/'.$GLOBALS['WebConfig']['language']."/".$GLOBALS['language_path']."/".$actfile.'.php';
			if(is_file($languagesPath))
			{
				require $languagesPath;
			}
			$this -> view ->assign('_LANG',$GLOBALS['_LANG']);
		}
	}
}

$Webur = new WebUrl();



?>