diff options
Diffstat (limited to 'h-source/Library/Functions.php')
| -rwxr-xr-x | h-source/Library/Functions.php | 74 | 
1 files changed, 73 insertions, 1 deletions
| diff --git a/h-source/Library/Functions.php b/h-source/Library/Functions.php index 1477680..62a1838 100755 --- a/h-source/Library/Functions.php +++ b/h-source/Library/Functions.php @@ -163,7 +163,9 @@ function sha1Deep($value)  	return array_map('sha1', $value);  } - +function strip_tagsDeep($value) { +	return array_map('strip_tags', $value); +} @@ -294,6 +296,76 @@ function getUserAgent() {  	}  } +//encode a string to drop ugly characters +function encode($url) +{ +	$url = utf8_decode(html_entity_decode($url,ENT_QUOTES,'UTF-8')); +	 +	$temp = null; +	 +	for ($i=0;$i<eg_strlen($url); $i++) +	{ +// 		echo substr($url,$i,1)."<br />"; +		if (strcmp(substr($url,$i,1),' ') === 0) +		{ +			$temp .= '_'; +		} +		else if (strcmp(substr($url,$i,1),"'") === 0) +		{ +			$temp .= ''; +		} +		else +		{ +			if (preg_match('/^[a-zA-Z\_0-9]$/',substr($url,$i,1))) +			{ +				$temp .= substr($url,$i,1); +			} +			else +			{ +				$temp .= '-'; +			} +		} +	} + +	$temp = urlencode($temp); +	return $temp; +} + +function callFunction($function, $string, $caller = "CallFunction") +{ +	if (strstr($function,'::')) //static method +	{ +		$temp = explode('::',$function); +		 +		if (!method_exists($temp[0],$temp[1])) +		{ +			throw new Exception('Error in <b>'.$caller.'</b>: method <b>'.$temp[1].'</b> of class <b>'.$temp[0].'</b> does not exists.'); +		} +		 +		return call_user_func(array($temp[0], $temp[1]),$string); +	} +	else if (strstr($function,'.')) //method +	{ +		$temp = explode('.',$function); +		 +		$obj = new $temp[0]; //new instance of the object +		 +		if (!method_exists($obj,$temp[1])) +		{ +			throw new Exception('Error in <b>'.$caller.'</b>: method <b>'.$temp[1].'</b> of class <b>'.$temp[0].'</b> does not exists.'); +		} +		 +		return call_user_func(array($obj, $temp[1]),$string); +	} +	else //function +	{ +		if (!function_exists($function)) { +			throw new Exception('Error in <b>'.$caller.'</b>: function <b>'.$function.'</b> does not exists.'); +		} +		//apply the function +		return call_user_func($function,$string); +	} +}  function xml_encode($string)  { | 
