Skip to content

Commit

Permalink
🔨 #270 separando os metodos
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinaldo Araujo Barreto Junior committed Jul 6, 2022
1 parent 4f5c463 commit fbc3984
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions base/classes/helpers/ServerHelper.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fbc3984

Please sign in to comment.