From a93461b231fb94f3a6a9df09a30557732201ddcc Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Mon, 14 Oct 2013 16:06:56 +0000 Subject: added new EasyGiant Library --- h-source/Library/Functions.php | 74 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) (limited to 'h-source/Library/Functions.php') 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"; + 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 '.$caller.': method '.$temp[1].' of class '.$temp[0].' 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 '.$caller.': method '.$temp[1].' of class '.$temp[0].' does not exists.'); + } + + return call_user_func(array($obj, $temp[1]),$string); + } + else //function + { + if (!function_exists($function)) { + throw new Exception('Error in '.$caller.': function '.$function.' does not exists.'); + } + //apply the function + return call_user_func($function,$string); + } +} function xml_encode($string) { -- cgit v1.2.3