<?php
/**
 *类  名：Url
 *文件名：class_url.php
 *编写人：http://Www.HuCart.Com
*/
class Url
{
	var $php_selfval ;  //PHP_SELF;
	var $path_infoval ; //PATH_INFO;
	var $base_url ; 
	var $urlArray = array();
	var $classfile = '';
	function Url()
	{
       $this -> php_selfval 	= 	$_SERVER["PHP_SELF"];
	   if(substr($_SERVER["PHP_SELF"],-4) !='.php' and $_SERVER["PHP_SELF"] !='')
	   {
	   		$this -> php_selfval 	= 	$_SERVER["PHP_SELF"];
	   }elseif( substr($_SERVER["REQUEST_URI"],-4) !='.php' and $_SERVER["REQUEST_URI"] !='')
	   {
	   		$this -> php_selfval 	= 	$_SERVER["REQUEST_URI"];
	   }elseif( substr($_SERVER["URL"],-4) !='.php'  and $_SERVER["URL"] !='')
	   {
	   		$this -> php_selfval 	= 	$_SERVER["URL"];
	   }

	}
	
	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 loadact()
	{
		
		$actfile = $GLOBALS['Reque'] -> 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']);	
			}
			
			//加载执行程序控制操作类文件
			$applicationPath = ROOT_PATH.$GLOBALS['application_path'].'/help/'.$actfile.'.php';
			if(is_file($applicationPath))
			{
				require $applicationPath;
				
				$needact = $GLOBALS['Reque'] -> getval["act"];
		
				if($needact)
				{
					//加载执行程序控制操作类文件
					$actfile = ucwords($actfile);
					$actval =  $actfile.'->'.$needact.'(); ' ;
					call_user_func(array($actfile, $needact));
					//eval($actval);
				}
			}
		}else{
			
			require ROOT_PATH.'includes/languages/'.$GLOBALS['WebConfig']['language'].'/'.$GLOBALS['language_path'].'/config.php';
			$languagesPath = ROOT_PATH.'includes/languages/'.$GLOBALS['WebConfig']['language']."/".$GLOBALS['language_path']."/index.php";
			
			if(is_file($languagesPath))
			{
				require $languagesPath;
				$this -> view ->assign('_LANG',$GLOBALS['_LANG']);	
			}
			
			$applicationPath = ROOT_PATH.$GLOBALS['application_path'].'/help/index.php';
			require $applicationPath;
			$needact = $GLOBALS['Reque'] -> getval["act"];
			if($needact!=''){
				$actval =  '$Index->'.$needact.'(); ' ;
			}else{
				$actval =  '$Index->infolist(); ' ;
			}
			call_user_func(array($actfile, $needact));
			//$this -> view ->display('index_tpl.html');
		}
	}

}

$Url = new Url();

?>