diff --git a/base/classes/helpers/ServerHelper.class.php b/base/classes/helpers/ServerHelper.class.php index 19fcc5d2..dfef68e8 100644 --- a/base/classes/helpers/ServerHelper.class.php +++ b/base/classes/helpers/ServerHelper.class.php @@ -52,27 +52,45 @@ public static function get($atributeName) $_SERVER[$atributeName]=""; } return is_null($_SERVER[$atributeName])?"":trim($_SERVER[$atributeName]); - } - + } + + public static function getFullServerName() + { + $pageURL = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? "https://" : "http://"; + $pageURL = $pageURL.$_SERVER["SERVER_NAME"]; + $pageURL = $pageURL.( ( $_SERVER["SERVER_PORT"] != 80 ) ? ":".$_SERVER["SERVER_PORT"] : "") ; + return $pageURL; + } + /** * https://stackoverflow.com/questions/6768793/get-the-full-url-in-php * - * @param boolean $trim_query_string + * @param boolean $trim_query_string remove query string * @return string|mixed */ - public static function getCurrentUrl( $trim_query_string = false ) + public static function getRequestUri($trim_query_string = false) { - $pageURL = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? "https://" : "http://"; - $pageURL = $pageURL.$_SERVER["SERVER_NAME"]; - $pageURL = $pageURL.( ( $_SERVER["SERVER_PORT"] != 80 ) ? ":".$_SERVER["SERVER_PORT"] : "") ; - $pageURL = $pageURL.$_SERVER["REQUEST_URI"]; - if(! $trim_query_string ) { - return $pageURL; + $uri = ServerHelper::get('REQUEST_URI'); + if( !$trim_query_string ) { + return $uri; } else { - $url = explode('?', $pageURL); + $url = explode('?', $uri); return $url[0]; } } + + /** + * https://stackoverflow.com/questions/6768793/get-the-full-url-in-php + * + * @param boolean $trim_query_string remove query string + * @return string|mixed + */ + public static function getCurrentUrl( $trim_query_string = false ) + { + $serverName = self::getFullServerName(); + $url = $serverName.self::getRequestUri($trim_query_string); + return $url; + } /** * Return string with IP client * https://pt.stackoverflow.com/questions/179389/como-pegar-ip-de-um-usuario-usando-php/179455